I want to obtain a binarized mask file through handwriting (with background as 0 and foreground as 1). However, when using gr.Sketchpador gr.ImageMask , if the image mode is set to "L", the output is an array of all zeros.
when i change the color of the pencil to white, the output is correct, but i can't see what is draw.
I found that this is because the program defaults to a background of all zeros and the pen default value is also zero, so the handwritten content cannot be seen. This is different from the old version of sketchpad.
Have you searched existing issues? 🔎
[X] I have searched and found no existing issues
Reproduction
import gradio as gr
import numpy as np
def sleep(im):
a=im["composite"]
b=a.shape
c=np.max(a)
return a, f'the image size is {b},\n the max value is {c}'
with gr.Blocks() as demo:
with gr.Group():
with gr.Row():
out=gr.Textbox()
with gr.Row():
im = gr.Sketchpad(type="numpy",image_mode="L")
im_out_1 = gr.Image(type="pil")
im.change(sleep, outputs=[im_out_1, out], inputs=im)
demo.launch()
Describe the bug
I want to obtain a binarized mask file through handwriting (with background as 0 and foreground as 1). However, when using gr.Sketchpador gr.ImageMask , if the image mode is set to "L", the output is an array of all zeros. when i change the color of the pencil to white, the output is correct, but i can't see what is draw. I found that this is because the program defaults to a background of all zeros and the pen default value is also zero, so the handwritten content cannot be seen. This is different from the old version of sketchpad.
Have you searched existing issues? 🔎
Reproduction
Screenshot
Logs
No response
System Info
Severity
I can work around it