andfanilo / streamlit-drawable-canvas

Do you like Quick, Draw? Well what if you could train/predict doodles drawn inside Streamlit? Also draws lines, circles and boxes over background images for annotation.
https://drawable-canvas.streamlit.app/
MIT License
576 stars 88 forks source link

TypeError: string indices must be integers #57

Closed andfanilo closed 3 years ago

andfanilo commented 3 years ago

Reported on https://discuss.streamlit.io/t/drawable-canvas/3671/29

Hey there! It seems like something happened to the Streamlit Drawable Canvas code today. I use streamlit-drawable-canvas for educational purposes. Earlier today, the canvas was working for my program (it's been working perfectly fine for the past several months). I define the canvas as follows:

canvas_result = st_canvas(
    fill_color="rgba(255, 165, 0, 0.3)",  # Fixed fill color with some opacity
    stroke_width=stroke_width,
    stroke_color=stroke_color,
    background_color= bg_color,
    # background_image=Image.open(bg_image) if bg_image else None,
    update_streamlit=realtime_update,
    width = 500,
    height= 500,
    drawing_mode=drawing_mode,
    key="canvas",
)

and then this afternoon, I get this error:

2021-07-01 23:00:34.341 Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/streamlit/script_runner.py", line 349, in _run_script
    exec(code, module.__dict__)
  File "/content/app.py", line 37, in <module>
    key="canvas"
  File "/usr/local/lib/python3.7/dist-packages/streamlit_drawable_canvas/__init__.py", line 138, in st_canvas
    w = component_value["width"]
TypeError: string indices must be integers

Do you know if any updates might have caused this? I haven't touched this code in a while and then it broke.

drprajapati commented 3 years ago

I got the same error too.

andfanilo commented 3 years ago

Hmmmm it seems it breaks on Streamlit 0.84, if you downgrade to 0.83 it should work again, lemme investigate more

EDIT: yup error was reported here: https://github.com/streamlit/streamlit/issues/3507 in the meantime downgrade to 0.83 to fix

I'll close this one when the Streamlit issue is resolved

harshitpal660 commented 3 years ago

yeah please tell me if you got any solution

andfanilo commented 3 years ago

Hey everyone this should be fixed with Streamlit 0.84.1 https://github.com/streamlit/streamlit/issues/3507#issuecomment-878668945. I've tested on the demo app and it works well, so it should work on your side too!

Fanilo