gradio icon indicating copy to clipboard operation
gradio copied to clipboard

When the gradio_client is used to call the API, the uploaded image will always be renamed image.webp

Open 2265865006 opened this issue 1 year ago • 3 comments

Describe the bug

When gradio_client is used to call the API, the uploaded images will always be changed to image.webp, even if I upload images with a png suffix, I have tried to adjust format in gr. image, which is invalid, how can I keep the Image name and suffix?

Have you searched existing issues? 🔎

  • [X] I have searched and found no existing issues

Reproduction

import gradio as gr

Screenshot

No response

Logs

No response

System Info

gradio                  4.31.4
gradio_client           0.16.4

Severity

Blocking usage of gradio

2265865006 avatar May 23 '24 12:05 2265865006

Hi @2265865006 - can you share the demo you are trying to use via the client? If the demo has an Image component with format='webp', then this behavior is expected. The app author controls the format that images are saved in.

freddyaboulton avatar May 23 '24 14:05 freddyaboulton

Hello@freddyaboulton, thank you for your answer Sure, this is a simple call that I just implemented. Here's demo.py

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)

This is my code for calling the api

from gradio_client import Client, file

client = Client("http://127.0.0.1:7860/")
result = client.predict(
		img=file('https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png'),
		api_name="/process"
)
print(result)

When I execute the call api, here is its output,You can see that bus.png becomes image.webp image

2265865006 avatar May 24 '24 02:05 2265865006

Thanks I understand the issue now @2265865006 !

freddyaboulton avatar May 24 '24 14:05 freddyaboulton

Thanys,It looks fine now

2265865006 avatar May 27 '24 02:05 2265865006

Let’s actually keep this open until we get the PR merged in into main

abidlabs avatar May 27 '24 03:05 abidlabs