Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The module gr.Sketchpad,ImageMask cannot obtain the binary image normally. #8198

Open
1 task done
JunchuanYu opened this issue May 2, 2024 · 1 comment
Open
1 task done
Labels
bug Something isn't working

Comments

@JunchuanYu
Copy link

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? 🔎

  • 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()

Screenshot

111

Logs

No response

System Info

gradio==4.24.0
windows

Severity

I can work around it

@JunchuanYu JunchuanYu added the bug Something isn't working label May 2, 2024
@JunchuanYu
Copy link
Author

gradio==4.27.0
windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant