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

Cannot override upload image + sketch, NoneType attributeerror. #4088

Closed
1 task done
Symbiomatrix opened this issue May 6, 2023 · 1 comment
Closed
1 task done
Labels
bug Something isn't working

Comments

@Symbiomatrix
Copy link

Symbiomatrix commented May 6, 2023

Describe the bug

I created an image component with source = upload, type = numpy, tool = sketch.
Then, attempted to override its upload method with a simple edit diversion.
However, this broke the regular upload functionality, with any simple png image (which obviously worked before) - apparently it's trying to read the mask content in components.preprocess, but doesn't have a fallback in case mask is None, as is the case for the input images I used.

A simple exception clause when setting mask_im should suffice, I think.
Another assertion breaks in preprocess if I set this image via another component's update: assert isinstance(x, dict) . For that one there at least seems to be a workaround of setting the component to a dict in the first place (with a null mask).
Actually looks like I can't, because postprocess expects only images, no dict. 🤦‍♂️
Note that the preprocess assertion error occurs after 2-3 overwrites, receives a base64 str.

Is there an existing issue for this?

  • I have searched the existing issues

Reproduction

import gradio as gr
def detect_image_colours(img):
    return img

with gr.Blocks() as demo:
    with gr.Row():
        with gr.Column():
            sketch = gr.Image(source = "upload", mirror_webcam = False, type = "numpy", tool = "sketch")
    sketch.upload(fn = detect_image_colours, inputs = [sketch], outputs = [sketch])

if __name__ == "__main__":
    demo.launch()
  1. Attempt to upload png image to sketch component.

Screenshot

No response

Logs

Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
Traceback (most recent call last):
  File "C:\Python38\lib\site-packages\gradio\routes.py", line 338, in run_predict
    output = await app.get_blocks().process_api(
  File "C:\Python38\lib\site-packages\gradio\blocks.py", line 1013, in process_api
    inputs = self.preprocess_data(fn_index, inputs, state)
  File "C:\Python38\lib\site-packages\gradio\blocks.py", line 911, in preprocess_data
    processed_input.append(block.preprocess(inputs[i]))
  File "C:\Python38\lib\site-packages\gradio\components.py", line 1508, in preprocess
    mask_im = processing_utils.decode_base64_to_image(mask)
  File "C:\Python38\lib\site-packages\gradio\processing_utils.py", line 53, in decode_base64_to_image
    content = encoding.split(";")[1]
AttributeError: 'NoneType' object has no attribute 'split'

System Info

Gradio = 3.16.2
OS = Windows 10
Browser = Chrome

Severity

annoying

@abidlabs
Copy link
Member

@space-nuko created the same issue here: #3623, closing

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

Successfully merging a pull request may close this issue.

2 participants