expected str, bytes or os.PathLike object, not Sequential
See original GitHub issueI am trying to deploy my Image Classification model and facing this issue while reading the selected image.
Code snippet:
def prediction(model):
image_file = st.file_uploader("Choose a bird image..", type="jpg")
if(image_file is not None):
image = Image.open(image_file)
st.image(image, width=40, caption='Uploaded bird image', use_column_width=True)
np_image = np.array(image).astype('float32')/255
np_image = transform.resize(np_image, (224, 224, 3))
np_image = np.expand_dims(np_image, axis=0)
model = load_model(model)
prediction = model.predict(img.reshape(1,224,224,3))
if(np.argmax(prediction)==0.0):
st.write('According to Model, it can be: COVID-19 with an Accuracy of {0:.2f}%'.format(np.max(prediction)*100))
elif(np.argmax(prediction)==1.0):
st.write('According to Model, it can be: Normal with an Accuracy of {0:.2f}%'.format(np.max(prediction)*100))
elif(np.argmax(prediction)==2.0):
st.write('According to Model, it can be: Pneumonia with an Accuracy of {0:.2f}%'.format(np.max(prediction)*100))
I executed the same code a month ago, and it worked fine—Donno why I am facing this error now.
Debug info
- Streamlit version: 0.72.0
- Python version: Python 3.7.5
- Tensorflow Version: tensorflow==2.4.1
- Keras Version: Keras==2.3.1
- Using IDLE
- OS version: Windows
- Browser version: Chrome
Issue Analytics
- State:
- Created 3 years ago
- Comments:9
Top Results From Across the Web
TypeError: expected str, bytes or os.PathLike object, not _io ...
I think it has to do with your second element in storbinary . You are trying to open file , but it is...
Read more >Expected str, bytes or os.PathLike object, not TextIOWrapper
The Python "TypeError: expected str, bytes or os.PathLike object, not TextIOWrapper" occurs when we pass a file object instead of a string when ......
Read more >Backups to remote storage fail with "expected str, bytes or os ...
Username: TITLE Backups to remote storage fail with "expected str, bytes or os.PathLike object, not int" PRODUCT, VERSION, OPERATING SYSTEM.
Read more >expected str, bytes or os.PathLike object, not function - Reddit
I have this task: load_io_monthly_billing_to_snowflake = SnowflakeLoadOperator( task_id='load_io_monthly_billing_to_Snowflake'…
Read more >TypeError: expected str, bytes or os.PathLike object, not int #6
When I used the command “python setup.py install” to download the mimkl package, an error occurred: "TypeError: expected str, bytes or os.
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
Yes @kmcgrady , I did use
file.read()
code:
image = Image.open(io.BytesIO(file.read()))
.I came across some working code as given below:
Right now, I’m facing two issues.
Issue-1: Here, the Model is wrongly predicting images on Streamlit. I tested the model on Jupyter notebook, and it predicted correctly there.
Issue-2: This worked fine without any errors for images in the same directory but raising errors for images on other directories as below images.
I am going to close this issue after not hearing anything back. Feel free to reopen it if you are still seeing issues.