Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add image selector #238

Merged
merged 9 commits into from
Aug 6, 2024
Merged

Add image selector #238

merged 9 commits into from
Aug 6, 2024

Conversation

arnaudmiribel
Copy link
Owner

@arnaudmiribel arnaudmiribel commented Aug 1, 2024

New extra!

image

Copy link

netlify bot commented Aug 1, 2024

Deploy Preview for phenomenal-crepe-0effec ready!

Name Link
🔨 Latest commit 8559961
🔍 Latest deploy log https://app.netlify.com/sites/phenomenal-crepe-0effec/deploys/66b221d6efeed3000876f057
😎 Deploy Preview https://deploy-preview-238--phenomenal-crepe-0effec.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.


@extra
def image_selector(
image: Image.Image,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggesiton: It would be nice to make this a bit more flexible, and handle image strings as well as Image objects. I think that would make people a lot more likely to use it, and it would be easy to just go ahead and convert to a PIL image as-needed.

Copy link
Collaborator

@blackary blackary left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is great! I would love to also see support for string image paths, ideally either URLs or local paths -- you could even borrow code from https://github.com/blackary/streamlit-image-coordinates/blob/main/src/streamlit_image_coordinates/__init__.py#L53 if you want.

But, even as-is, it's an excellent extra!

@arnaudmiribel
Copy link
Owner Author

Good point @blackary - see f3568f9

selection (dict): Selection coordinates, output of `image_selector`
"""

image_array = np.array(image)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean to convert to Image and then array? Otherwise a string will fail.

dict: Selection coordinates
"""

image = convert_to_pil_image(image)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: My preference is to avoid overloading a variable name if it changes type

Copy link
Collaborator

@blackary blackary left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, one nit and one bug (I think) in the show_selection function

Copy link
Collaborator

@blackary blackary left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the show_image function if you actually want it to work with strings. Didn't mean to approve :)

Copy link
Collaborator

@blackary blackary left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

queue-reaction-s-gif

@arnaudmiribel arnaudmiribel merged commit 70cbe9c into main Aug 6, 2024
14 checks passed
@arnaudmiribel arnaudmiribel deleted the image-selector branch August 6, 2024 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants