protobuf::FatalException when trying to deploy Tensorflow model

Summary

Hello,

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/message_lite.cc:353] 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 check_img.py

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)

streamlit==1.23.1
tensorboard==2.12.3
tensorboard-data-server==0.7.0
tensorboard-plugin-wit==1.8.1
tensorflow==2.12.0
tensorflow-estimator==2.12.0
tensorflow-io-gcs-filesystem==0.32.0
tensorflow-macos==2.12.0
tensorflow-metal==1.0.0

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.