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

Image component preprocessing problem #8412

Closed
1 task done
2265865006 opened this issue May 30, 2024 · 5 comments
Closed
1 task done

Image component preprocessing problem #8412

2265865006 opened this issue May 30, 2024 · 5 comments

Comments

@2265865006
Copy link

2265865006 commented May 30, 2024

Describe the bug

I have some doubts about the current Image component, I may be too entangled in the details. When I upload an image on the web page, if my suffix is jpg and Gradio receives an image with the suffix jpeg, and the md5 of the two is different, I guess some pre-processing may be done on the image. But I think the Image component should not make additional changes to the uploaded content, and the Image component should only focus on displaying or passing the content. Is there any additional consideration? I now use gr. File as a substitute

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

import gradio as gr

def img_test(img):
    print(img)


with gr.Blocks() as demo:
    image_debug = gr.Image(visible=True,height=500,width="auto",interactive=False,label="output",format="png",type="filepath")

    btn= gr.Button(value="process")

    btn.click(fn=img_test,inputs=[image_debug],api_name="process")


if __name__ == '__main__':
    demo.title = "Demo"
    demo.queue(api_open=True).launch(share=False,server_port=7860)

Screenshot

No response

Logs

No response

System Info

gradio                  4.31.4
gradio_client           0.16.4

Severity

Blocking usage of gradio

@2265865006 2265865006 added the bug Something isn't working label May 30, 2024
@pngwn
Copy link
Member

pngwn commented Jun 9, 2024

The image does do some processing because we need to get the image into a format that the user can do something with (turn it into a np array, PIL image, or file path with a corresponding file). We need to do this because we don't know if a user wants the image exactly as it is or wants to process it in some way.

What is the actual bug here?

@pngwn pngwn added pending clarification and removed bug Something isn't working labels Jun 9, 2024
@2265865006
Copy link
Author

@pngwn From my current requirements for using the gr.Image component, when I want the corresponding file path, I want to get the image path without any processing, which may be helpful for alignment with the results of other programs. But now I have an alternative plan, so I do not have a strong demand for the solution of this problem, just to discuss the possible unreasonable.

@pngwn
Copy link
Member

pngwn commented Jun 12, 2024

You can set preprocess false on the image to disable any processing and you will get a dictionary including the file path to the original image.

@2265865006
Copy link
Author

@pngwn Thank you. This will help me

@jbojar
Copy link

jbojar commented Jul 17, 2024

@pngwn

You can set preprocess false on the image to disable any processing and you will get a dictionary including the file path to the original image.

Little clarification: you disable preprocessing when defining an event handler, eg.:

image.upload(..., preprocessing = False)

You cannot disable preprocessing on Image component itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants