My App is constantly throwing the same error since its deployed ! ๐Ÿ˜ž

Weeks ago, I created magical image art app which worked fine locally & then I deployed it on Streamlit Cloud.

This error has been constant since deployment, and now Iโ€™m very confused at this point because I canโ€™t really figure out what is the actual issue here.

:link: Github repo: GitHub - ShruAgarwal/Magical_Image_Art: Try this Streamlit App and receive three different styled effects out of an Image! ๐Ÿ˜‰๐ŸŒˆ

Earlier errors I came across & solved as well:

  • correct use of opencv library in requirements.txt file
  • removing the latest version of streamlit because of compatibility
  • reducing the use of image-comparison component due to ugly output on the final app.

It will be a great help if someone could point out the actual error of this app :pray:
Thanks :slightly_smiling_face:

As a quick thing to try, have you tried deleting and then redeploying the app?

1 Like

Yes, I have did this twice. Also, I have rebooted the app three times!

Sorry about that. Looks like a really cool app! Let me see what I can figure out.

1 Like

It seems that the issue is here:
File โ€œ/home/appuser/venv/lib/python3.9/site-packages/streamlit/scriptrunner/script_runner.pyโ€, line 557, in _run_script
exec(code, module.dict)
File โ€œst_app.pyโ€, line 135, in
cartoon_img = cartoon_style(display_image)
File โ€œst_app.pyโ€, line 93, in cartoon_style
cartoon_image = cv2.stylization(image_1, sigma_s=150, sigma_r=0.25)
cv2.error: OpenCV(4.6.0) :-1: error: (-5:Bad argument) in function โ€˜stylizationโ€™

  • Overload resolution failed:
  • src data type = 17 is not supported
  • Expected Ptrcv::UMat for argument โ€˜srcโ€™
1 Like

Odd, I just forked the repo and it deployed in Streamlit Cloud without issues. Link to app.


edit: using streamlit 1.12.2 works fine as well


edit2: without changing anything, the app now fails showing the same issue in the logs :hushed:


edit3: refactored the code a little bit to reboot the app in Streamlit Cloud. Itโ€™s working againโ€ฆ but it might break again? I suspect the problem comes from the streamlit-image-comparison component that writes opencv images that are supposed to be temporal but are never cleaned, and possibly never released.

1 Like

After keeping the errors mentioned by @Alex_Toader & @edsaac in mind, I tried โ€“

  • Adding try-except blocks in cartoon_style & waterColor_style functions.
  • Changed the code for cartoon_style function as it cv2.stylization was throwing several errors.
  • Removed st-image-comparison component from requirements.txt & st_app.py files
  • Deleted the app & Redeployed it again HERE

Now, itโ€™s showing these logs :point_down:

[12:07:29] ๐Ÿ Python dependencies were installed from /app/magical_image_art/requirements.txt using pip.
[12:07:29] ๐Ÿ“ฆ Processed dependencies!
[12:07:32] ๐Ÿ–ฅ Provisioning machine...
[12:07:33] ๐ŸŽ› Preparing system...
[12:07:33] โ›“ Spinning up manager process...
[12:07:33] ๐Ÿ”„ Updated app!
python: malloc.c:2379: sysmalloc: Assertion `(old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed.
[12:09:38] โ—๏ธ Streamlit server consistently failed status checks
[12:09:38] โ—๏ธ Please fix the errors, push an update to the git repo, or reboot the app.

Please help me where Iโ€™m going wrong :pray:

Thanks, @blackary :slightly_smiling_face: Please let me know where Iโ€™m going wrongโ€ฆ

Itโ€™s been a couple days and the version from my fork has not failed yet. The only meaningful change was that the image processing only gets triggered when both st.button('See the Magic! ๐ŸŽ‰') and st.file_uploader("UPLOAD AN IMAGE") evaluate to True. In the earlier version, only the st.button('See the Magic! ๐ŸŽ‰') was checked, so if the app was run without an uploaded file, it would throw an exception.

:link: Run it in Streamlit cloud

:link: GitHub repository with my forked version

st_imagesfork

1 Like

Thanks for your constant update @edsaac :slightly_smiling_face: Right now, even my new app link is working fine!
Letโ€™s see how long it works wellโ€ฆ

Update: Today, the same error occurred. Please let me know whatโ€™s the issue :pray:

Just to double-check, itโ€™s still showing this error in the logs? Or something else?

[quote=โ€œShruAgarwal, post:7, topic:30535โ€]

python: malloc.c:2379: sysmalloc: Assertion `(old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed.

Hereโ€™s the error:

2022-09-16 19:48:40.280 Uncaught app exception
Traceback (most recent call last):
  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/scriptrunner/script_runner.py", line 557, in _run_script
    exec(code, module.__dict__)
  File "st_app.py", line 161, in <module>
    pop_art(display_image)
  File "st_app.py", line 50, in pop_art
    image = cv2.cvtColor(original, cv2.COLOR_BGR2GRAY)
cv2.error: OpenCV(4.6.0) :-1: error: (-5:Bad argument) in function 'cvtColor'
> Overload resolution failed:
>  - src data type = 17 is not supported
>  - Expected Ptr<cv::UMat> for argument 'src'
malloc(): invalid size (unsorted)
[12:25:04] โ—๏ธ Streamlit server consistently failed status checks
[12:25:04] โ—๏ธ Please fix the errors, push an update to the git repo, or reboot the app.

That looks like it might be a different error than before, so thatโ€™s interesting. Have you tried this suggestion python - cv2.error: OpenCV(4.5.2) ๐Ÿ‘Ž error: (-5:Bad argument) in function 'cvtColor' - Stack Overflow?

Yes, I tried but it doesnโ€™t seem to solve the actual issue :sweat_smile: Right now, my app is running without any issues. Iโ€™ll keep monitoring how long it works wellโ€ฆ

:frowning_face: Sorry to hear it didnโ€™t solve the issue, but glad to hear itโ€™s running without any issues.