gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
33.43k stars 2.53k forks source link

Drawing a bounding ellipse on output image to become input #7824

Closed datquocha closed 7 months ago

datquocha commented 7 months ago

I am looking for a feature where the user can draw a bounding ellipse over an output image of a Gradio component. Then, this drawn shape will become the input for the next sequence, where another component is run to receive the final output. It can be thought of as equivalent to this feature in MATLAB:

https://www.mathworks.com/help/images/ref/images.roi.ellipse.html

I have searched previously here and found options to draw a rectangular bounding box, as well as creating custom component. However, I am not seen other geometries being supported and whether the information of the bounding box can be retrieved as input for the next component.

Thank you so much for everyone's help in advance!

abidlabs commented 7 months ago

Hi @datquocha this is fairly niche so I don't think we'd add this as a core Gradio component, but I think this would be a great case for a custom component!

we've made it possible for Gradio users to create their own custom components -- meaning that you can write some Python and JavaScript (Svelte), and publish it as a Gradio component. You can use it in your own Gradio apps, or share it so that anyone can use it in their Gradio apps.

Here's an example of a Gradio custom component: https://github.com/PhyscalX/gradio-image-prompter -- it lets you upload images and process points or draw boxes on top of the image like you described.

If you'd like to create your own, we've put together a Guide: https://www.gradio.app/guides/five-minute-guide, and we're happy to help.