gradio icon indicating copy to clipboard operation
gradio copied to clipboard

.change() listener not working as intended for ImageEditor (Paint, Image, ImageEditor, Sketchpad)

Open Ichigo3766 opened this issue 1 year ago • 6 comments

Describe the bug

I am trying to use sketchpad and using the .change listener so every time I draw anything and let go, it runs a function. This used to work just fine before (v 3.50.2) but is broken now where I have to press this "save changes" button every single time I want it to run.

I am not sure if this is a bug or intended and if it's intended, then what listener event can I use to perform a real-time change? I have pasted a basic function where everything i draw gets returned as is but it should be doing it automatically while im drawing which is not happening.

As you can tell in the image, the green checkmark is what im having to press each time. image

Have you searched existing issues? 🔎

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

Reproduction

import gradio as gr

async def gen(image):
    return image["composite"]

with gr.Blocks() as demo:
    with gr.Row(variant="default"):
        with gr.Column():
            #img = gr.Sketchpad(height="512", width="1024", type="pil", scale=1, brush=gr.Brush(color_mode="defaults")) # type: ignore
            img = gr.Paint(image_mode="RGB",type="pil", interactive=True)
        with gr.Column():
            sktout = gr.Image(
                show_label=False,
                type="pil",
                interactive=False,
                height=512,
                width=768,
                elem_id="sktout",
            )
    img.change(fn=gen, inputs=[img],outputs=[sktout], show_progress="hidden")

demo.queue().launch(inline=False, share=False, server_name="0.0.0.0")

Screenshot

No response

Logs

No response

System Info

Gradio Environment Information:
------------------------------
Operating System: Linux
gradio version: 4.15.0
gradio_client version: 0.8.1

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

aiofiles: 23.2.1
altair: 5.0.1
fastapi: 0.102.0
ffmpy: 0.3.1
gradio-client==0.8.1 is not installed.
httpx: 0.24.1
huggingface-hub: 0.20.2
importlib-resources: 6.0.1
jinja2: 3.1.3
markupsafe: 2.1.3
matplotlib: 3.8.2
numpy: 1.24.1
orjson: 3.9.5
packaging: 23.2
pandas: 2.0.3
pillow: 9.3.0
pydantic: 2.2.1
pydub: 0.25.1
python-multipart: 0.0.6
pyyaml: 6.0
ruff: 0.1.14
semantic-version: 2.10.0
tomlkit==0.12.0 is not installed.
typer: 0.9.0
typing-extensions: 4.9.0
uvicorn: 0.23.2
authlib; extra == 'oauth' is not installed.
itsdangerous; extra == 'oauth' is not installed.


gradio_client dependencies in your environment:

fsspec: 2023.12.2
httpx: 0.24.1
huggingface-hub: 0.20.2
packaging: 23.2
typing-extensions: 4.9.0
websockets: 11.0.3

Severity

Blocking usage of gradio

Ichigo3766 avatar Jan 21 '24 20:01 Ichigo3766

This is something we'll need to explicitly design for. Tagging @pngwn to take a look at this when he has bandwidth (might be a few weeks out)

abidlabs avatar Jan 22 '24 18:01 abidlabs

Thank you for providing insight. Yea odd that it was working just fine before but has been changed after the new updates to Image stuff. Will look forward to it as there does not seem to be a way to use eraser on v3.50.2 which is the main reason for upgrading to latest.

Ichigo3766 avatar Jan 23 '24 00:01 Ichigo3766

Hello, checking in to see if there are any updates regarding this.

Ichigo3766 avatar Feb 03 '24 19:02 Ichigo3766

Not yet. For context, we change this behaviour because of how gradio handle media content. We upload files to the server, which introduces quite a bit of overhead, so we didn't want to bombard the network in cases like this.

I'll look into a more optimal approach to handling this kind of data when I look more closely into this issue. No eta but I should have bandwidth soon.

pngwn avatar Feb 04 '24 00:02 pngwn

Hello! Just checking in if there are any updates regarding this?

Ichigo3766 avatar Feb 21 '24 01:02 Ichigo3766

Nope, we'll update the issue when we do.

pngwn avatar Feb 21 '24 15:02 pngwn