can't read an image uploaded with st.file_uploader()
See original GitHub issueI get my hand on the new feature that we all have been waiting for.
I tested it to upload an image and read it with OpenCV (cv.VideoCapture) but unfortunately, I encounter an error. The type of the uploaded image is <_io.BytesIO object at 0x7f4c7adc7db0>
Error message
TypeError: an integer is required (got type _io.BytesIO)
Traceback:
File "/usr/local/lib/python3.6/site-packages/streamlit/ScriptRunner.py", line 324, in _run_script
exec(code, module.__dict__)
File "/workspaces/inveesion/main.py", line 767, in <module>
cap = Config().input_output_data(guiParam)
File "/workspaces/inveesion/main.py", line 508, in input_output_data
cap = cv.VideoCapture(file_path)
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Can't read an image uploaded with st.file_uploader() - Streamlit
I tested it to upload an image and read it with OpenCV (cv.VideoCapture) but unfortunately, I encounter an error. The type of the...
Read more >getting an error from streamlit file_uploader - Stack Overflow
i can't figure in which file type the streamlit is uploading the file. Please help me with how I can upload a custom...
Read more >Working with File Uploads in Streamlit Python - JCharisTech
To work with the file uploads you will have to use the st.file_uploader() function. Let us see how the st.file_uploader() functions works.
Read more >Python Streamlit: Uploading and Using Files - Level Up Coding
Streamlit provides a file_uploader , which is accessible with st.file_uploader and looks like this: Streamlit file picker. Code for the file picker, ...
Read more >Working with File Uploads In Streamlit Python - YouTube
In this indepth tutorial we will be working with the file uploads feature of streamlit - how to process Images,PDF,Docx,Txt,CSV etc.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Dear @robmarkcole,
You need to check that
img_file_buffer
is notNone
before trying toImage.open()
it. Otherwise, you will get anAttributeError
.P.S. Thanks for the suggested example!
Edit - just noticed this thread with solution https://discuss.streamlit.io/t/png-bytes-io-numpy-conversion-using-file-uploader/1409/2
Suggested example for the docs: