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
541 stars 83 forks source link

Page reloading continuously when st_canvas function is called. #137

Open sciprashanth96 opened 11 months ago

sciprashanth96 commented 11 months ago

Page keeps reloading automatically and randomly stops after 5-15 reloads whevenver st_canvas is called.

streamlit version: 1.25.0 (Tried 1.20.0, 1.23.0, 1.24.0 also does the same) streamlit-drawable-canvas version - 0.9.0 (tried with 0.7.0, 0.9.2 and 0.9.3 also. same problem)

This is highly crucial for our project

Trying to convert my plotly figure into an image and annotate on it

image = pio.to_image(fig)
img = Image.open(io.BytesIO(image))
cols = st.columns([4,1])
with cols[0]:
    tabs = st.tabs(['Plotly','Canvas'])
    with tabs[0]:
        plot_controls = st.container()
        with plot_controls:
            # Add config to fig
            config = ['drawline','drawopenpath','drawclosedpath','drawcircle','drawrect','eraseshape']
            fig.update_layout(modebar_add=config,height = 800,width = 800)
            st.plotly_chart(fig, use_container_width=True)    
        with tabs[1]:
            st_canvas(background_image = img)
            print('Canvas')
            uploaded_image = st.file_uploader('Upload Image',type=['png','jpg','jpeg'],key='uploaded_image'+function_code)
irumata commented 9 months ago

I've found the rootcasue of this problem for my side: the the problem is in empty container. If you have an empty container anywhere on the website this canvas wouldn't work

oneil512 commented 4 months ago

Any progress on this? Very annoying issue