Open selaselah opened 1 week ago
A awful solution: user can create another layer, and draw mask into it. This solution is cumbersome and error-prone: the number of layer must exact 2; user must put image into layer#1 and draw brush into layer#2
The layers menu can be disabled with layers=False
, so users can't make new layers.
import gradio as gr
demo = gr.Interface(
fn=lambda img: img["layers"][0],
inputs=[gr.ImageEditor(layers=False)],
outputs=[gr.Image()],
)
demo.launch()
cc @pngwn in case we want to make this addition in v5?
I don't think we need to add anything here.
Setting layers=False
means the user can upload an image and draw a mask. The. You can use the background key for the bg image and the single layer as the mask layer.
Maybe we need to update the gr.ImageMask
template to match this.
in v3, mask editor can be implements by
the mask value can to access via
in v4, tool is replaces with ImageEditor
The value of ImageEditor only contains
no mask (brush only) can be get. check changed pixel value is not working, because the color of pixels maybe same as brush.
A awful solution: user can create another layer, and draw mask into it. This solution is cumbersome and error-prone: the number of layer must exact 2; user must put image into layer#1 and draw brush into layer#2
I think add a "brushed" item to ImageEditor's value dict, which only contains the effect of all brush drawing, can solve this problem.