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.41k stars 2.53k forks source link

EXR support #3193

Closed Jerry-Master closed 10 months ago

Jerry-Master commented 1 year ago

I'd like to have EXR support so that gradio is valid for production environments. The sRGB space and 8-bit color depth is not enough for production environment, where it is needed to have full control of your images.

There is a library: JERI that implements EXR format for web browsers. Maybe it can be integrated inside gradio?

abidlabs commented 1 year ago

Can you elaborate a little more on what the use case is, ideally with a representative code snippet? I'm not familiar with EXR.

Jerry-Master commented 1 year ago

I was trying to use stable diffusion web ui locally with exr files for img2img processing. That is my concrete use case. If I simply load the exr image like that the src attribute of the img is set to data:application/octet-stream prior to sending the src attribute to gradio Image preprocessing function. That string can be rewritten to a file and then re-read using opencv or OpenEXR. The problem is that the browser already embeds that src attribute and it cannot be modified. As a consequence, the image is not displayed.

It would be interesting that gradio also supports that file format, so that I can upload exr files easily, otherwise it is quite difficult for VFX artists to use.

abidlabs commented 1 year ago

I see. To confirm, you'd like the Image component to be able to accept EXR files as inputs as well as display them as outputs?

Jerry-Master commented 1 year ago

I want the Image component to behave the same with EXR files as with PNG or JPG files. That means, being able to read and display the image it contains, yes.

abidlabs commented 11 months ago

Hey! We've now 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 are some examples of custom Gradio components:

You can see the source code for those components by clicking the "Files" icon and then clicking "src". The complete source code for the backend and frontend is visible. In particular, its very fast if you want to build off an existing component. We've put together a Guide: https://www.gradio.app/guides/five-minute-guide, and we're happy to help. Hopefully this will help address this issue.

abidlabs commented 10 months ago

I'll go ahead and close this issue since we are not planning to include this in the core Gradio library. But happy to help if you are interested in making this a custom Gradio component (feel free to ask questions in this issue).