Error during deploying app

Why I am getting this error, not sure…
Can anyone help me to understand this? would be a great help… It is working completely fine locally using streamlit.

Thanks you!

Hi @samachakole,

Can you paste the link to the GitHub you’re deploying from and a copy of the log file?

(in your image: bottom right corner has 3 dots, press it and select Download log button)

Happy Streamlit-ing!
Marisa

1 Like

Hi @samachakole :wave:

Problem

The error is triggered due to lines 48-50, where you use cv2.imshow() to display images.

Description

OpenCV tries to:

  1. Find an attached display on the “headless” server (Streamlit Cloud)
  2. Open a window on the display to show the image

It fails because the container the app is deployed to is a “headless” server – meaning there’s no video card, no “display” attached. In contrast, the app worked fine locally because you have an attached monitor.

Solution

The solution is to instead use st.image() to display images. Here are the steps to get it working:

  1. Delete your app on Streamlit Cloud
  2. Replace lines 48-50 of drawing_diff_rev1.py with the following:
    st.image(img1, caption="Actual1")
    st.image(img2, caption="Actual2")
    
  3. Re-deploy your app

Once you follow the above steps, your app should not throw the error when you hit the Get Comparison button. :tada:

Happy Streamlit-ing! :balloon:
Snehan

2 Likes

Thanks, Snehan,

It is working… : smiley: