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

Cannot drag and drop image from Gallery to Image #4377

Closed
1 task done
Hantang-Li opened this issue May 31, 2023 · 3 comments
Closed
1 task done

Cannot drag and drop image from Gallery to Image #4377

Hantang-Li opened this issue May 31, 2023 · 3 comments
Labels
bug Something isn't working 🖼️ image Image component

Comments

@Hantang-Li
Copy link

Describe the bug

If my image in the gallery module is a URL, then I cannot do drag and drop. But if the image is a local image or an uploaded one, then the drag-and-drop function works as expected.

I have reproduced the bug below.

Is there an existing issue for this?

  • I have searched the existing issues

Reproduction

import gradio as gr

def predict(inp):
return [inp]

gr.Interface(fn=predict,
inputs=gr.Image(type="pil"),
outputs=gr.Gallery(value=["https://raw.githubusercontent.com/gradio-app/gradio/main/readme_files/header-image.jpg"])).launch(show_api=False, server_name="0.0.0.0", server_port=80, debug=True)

Screenshot

No response

Logs

No logs

System Info

gradio==3.32.0
gradio_client==0.2.5
Chrome==Version 113.0.5672.127
System==Ubuntu 20.04.5

Severity

annoying

@Hantang-Li Hantang-Li added the bug Something isn't working label May 31, 2023
@abidlabs
Copy link
Member

Hi @Hantang-Li I don't understand this issue. Can you include a GIF showing what you are trying to do? It would be great if you can include both examples, one where it is working properly and one where it is not. Thanks

@abidlabs abidlabs added pending clarification and removed bug Something isn't working labels May 31, 2023
@Hantang-Li
Copy link
Author

Hantang-Li commented May 31, 2023

Hi @abidlabs,

Thanks for your swift response!
Here I attached a gif to clarify the issue.

Not work:
not_work
Working properly:
work

I am deploying the code under the Reproduction section. The gallery uses a Groot image from the URL "https://raw.githubusercontent.com/gradio-app/gradio/main/readme_files/header-image.jpg" as the default image, and I am not able to drag and drop the Groot image to the upload image section.

But if the Gallery module gets an image locally, I can use the drag-and-drop function.

@abidlabs abidlabs added enhancement New feature or request bug Something isn't working and removed pending clarification enhancement New feature or request labels Jun 2, 2023
@abidlabs abidlabs added this to the Component Cleanup milestone Jul 9, 2023
@abidlabs abidlabs added the 🖼️ image Image component label Jul 31, 2023
@abidlabs
Copy link
Member

Hi @Hantang-Li. I looked into this and I believe that its a browser issue, not a Gradio issue, that prevents dragging and dropping certain kinds of images.

As a workaround, you can use the .select() event of the Gallery component to have the image populate when you click on it. I put together a quick example for you:

import gradio as gr

url = "https://raw.githubusercontent.com/gradio-app/gradio/main/readme_files/header-image.jpg"

def image_click(images, evt: gr.SelectData):
    print(images)
    return images[evt.index]['name']

with gr.Blocks() as demo:
    with gr.Row():
        g = gr.Gallery([url], allow_preview=False)
        i = gr.Image()
        g.select(image_click, g, i)
        
demo.launch()

Let us know if this doesn't work for you and we can try to offer a different solution or reopen this issue for further investigation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 🖼️ image Image component
Projects
None yet
Development

No branches or pull requests

2 participants