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
32.49k stars 2.44k forks source link

.input() listener not working as intended for ImageEditor #8601

Open YBYBZhang opened 3 months ago

YBYBZhang commented 3 months ago

Describe the bug

Description

I am encountering an issue where the input trigger linked to an ImageEditor component does not activate when the image is edited. I expected the trigger to fire and update a connected Number component, but there is no response.

Steps to Reproduce

  1. Start the Gradio app using the provided code snippet.
  2. Edit the image in the ImageEditor component.
  3. Observe that the Number component does not update as expected.

Expected Behavior

When the image is edited, the Number component should update its value based on the trigger function linked to the ImageEditor.

Actual Behavior

The Number component remains unchanged regardless of the edits made in the ImageEditor.

Have you searched existing issues? 🔎

Reproduction

import gradio as gr

def predict(im):
    return im["composite"]

with gr.Blocks() as demo:
    with gr.Row():
        im = gr.ImageEditor(
            type="numpy",
            crop_size="1:1",
        )
        im_preview = gr.Image()
    n_input = gr.Number(0, label="Number of input events", step=1)

    im.input(lambda x: x + 1, outputs=n_input, inputs=n_input)
    im.input(predict, outputs=im_preview, inputs=im, show_progress="hidden")

if __name__ == "__main__":
    demo.launch()

Screenshot

No response

Logs

No response

System Info

Gradio Environment Information:
------------------------------
Operating System: Linux
gradio version: 4.36.1
gradio_client version: 1.0.1

------------------------------------------------
gradio dependencies in your environment:

aiofiles: 23.2.1
altair: 5.1.2
fastapi: 0.111.0
ffmpy: 0.3.1
gradio-client==1.0.1 is not installed.
httpx: 0.25.0
huggingface-hub: 0.23.4
importlib-resources: 6.1.0
jinja2: 3.1.2
markupsafe: 2.1.1
matplotlib: 3.7.1
numpy: 1.25.0
orjson: 3.9.7
packaging: 23.1
pandas: 2.1.1
pillow: 9.4.0
pydantic: 2.7.4
pydub: 0.25.1
python-multipart: 0.0.9
pyyaml: 6.0
ruff: 0.4.9
semantic-version: 2.10.0
tomlkit==0.12.0 is not installed.
typer: 0.12.3
typing-extensions: 4.12.2
urllib3: 2.2.2
uvicorn: 0.23.2
authlib; extra == 'oauth' is not installed.
itsdangerous; extra == 'oauth' is not installed.

gradio_client dependencies in your environment:

fsspec: 2023.6.0
httpx: 0.25.0
huggingface-hub: 0.23.4
packaging: 23.1
typing-extensions: 4.12.2
websockets: 11.0.3

Severity

Blocking usage of gradio

abidlabs commented 3 months ago

I noticed this as well. It also does not fire if a user sketches on an image

YBYBZhang commented 3 months ago

Thank you for confirming the issue. My project relies on this feature, so any updates on a potential fix would be greatly appreciated!