Skip to content

Using gr.update(value=np.array(...)) Disables Brush Painting in gr.ImageMask #10614

Closed
@gkalstn000

Description

@gkalstn000

Describe the bug

When using the gr.ImageMask component in a Gradio interface, the brush painting functionality works as expected when an image is uploaded via the web interface. However, if the component is updated programmatically with gr.update(value=np.array(...)), the brush painting feature stops working entirely.

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

Steps to Reproduce:

  1. Initialize the component:
canvas = gr.ImageMask(sources='upload', type="numpy")

Upload an image through the web interface.
Use the brush tool to paint on the canvas (this should work normally).

Update the component internally using:

image = gr.Image(sources='upload', type="numpy")
canvas = gr.ImageMask(sources='upload', type="numpy")

image.upload(fn=update_cnavas, inputs=image, outputs=canvas)

def update_cnavas(image) :
    return gr.update(value=image)

Observe that after the update, the brush painting functionality is completely disabled.

Screenshot

2025-02-18.3.02.34.mov

Logs

System Info

Gradio version: 5.16.0
Browser: chrome
Operating System: Ubuntu 24.04 LTS

Severity

I can work around it

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions