protobuf::FatalException when trying to deploy Tensorflow model



I am trying to build an image recognition web-app using Tensorflow and Streamlit, and when I run the Streamlit app, I get the following error message (It also shows a connection error in the app running on localhost):

Error Message

***[libprotobuf FATAL google/protobuf/] CHECK failed: target + size == res: ***
***libc++abi: terminating due to uncaught exception of type google::protobuf::FatalException: CHECK failed: target + size == res: ***
zsh: abort python -m streamlit run

Some more information:

I am trying to load an image and predict. The app runs, loads the image, uses the stored Tensorflow model, and then shows the above error when trying to predict on the uploaded image. My laptop is a Mac M1.

Code Snippet

import streamlit as st
from tensorflow.keras.models import load_model
from tensorflow.keras.preprocessing.image import load_img,img_to_array

upload = st.file_uploader('Insert image for classification', type=['png','jpg'])

model = load_model(<model_file>)

if upload is not None:

     img = load_img(upload, target_size=(x,y))
     img = img_to_array(img)
     img = np.expand_dims(img,axis = 0)
     st.write(model.predict(img, verbose=0)[0][0])

Versions (python==3.8.16)


1 Like

Hi @pancham,

Thanks for posting!

Can you provide more information on the error, requirements file, and code snippet?

Please check out our guidelines on how to post an effective question here and update your post to help the community answer your question.

1 Like

I added more details… let me know if this is sufficient!

Hi @pancham,

Thanks for the update. Can you confirm the protobuf and grpc module versions you are using?

Try using version 4.2 or greater if you are not already.

Hey @tonykip I was using protobuf 4.23.2… still running into the error… it is likely an issue with the Tensorflow install on Mac M1… I got the streamlit app to run successfully from Google Colab. I’ll keep trying on local, I’ll make a clean env and see…

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.