I am trying to run this code sample code
import streamlit as st
from PIL import Image
import pandas as pandas
from clarifai_grpc.grpc.api import service_pb2, resources_pb2
from clarifai_grpc.grpc.api.status import status_code_pb2
from clarifai_grpc.channel.clarifai_channel import ClarifaiChannel
from clarifai_grpc.grpc.api import service_pb2_grpc
stub = service_pb2_grpc. V2Stub( ClarifaiChannel.get_grpc_channel())
st.title("IMAGE Demo")
st.header("Step 1: Enter an App Key")
key = st.text_input("App Key")
if key == '':
st.warning("An app key has not been entered")
st.stop()
else:
st.write("App Key has been uploaded!")
file_data = st.file_uploader("Upload Image",type=\['jpg'\])
if file_data == None:
st.warning("File needs to be uploaded")
st.stop()
else:
image = Image.open(file_data)
st.image(image)
metadata = (('authorization', 'Key {}'.format(key)),)
request = service_pb2.PostModelOutputsRequest(model_id='9504135848be0dd2c39bdab0002f78e9',
inputs=\[ resources_pb2.Input(data=resources_pb2.Data(image=resources_pb2.Image(base64=file_data.getvalue()))) \])
response = stub.PostModelOutputs(request, metadata=metadata)
if response.status.code != status_code_pb2.SUCCESS:
raise Exception("Request failed, status code: "+ str(response.status.code))
names = \[\]
confidences = \[\]
for concept in response.outputs\[0\].data.concepts:
names.append(concept.name)
confidences.append(concept.value)
df = pandas.DataFrame({"Concept Name":names,"Model
Confidence":confidences
})
st.dataframe(df)
but i keep getting this error
Traceback (most recent call last):
File "f:\IBMF project\web-design-course-restaurant-master - Copy\food.py", line 6, in <module>
from clarifai_grpc.grpc.api import service_pb2, resources_pb2
File "C:\Users\Ashraf\anaconda3\lib\site-packages\clarifai_grpc\grpc\api\service_pb2.py", line 16, in <module>
from clarifai_grpc.grpc.api import resources_pb2 as proto_dot_clarifai_dot_api_dot_resources__pb2
File "C:\Users\Ashraf\anaconda3\lib\site-packages\clarifai_grpc\grpc\api\resources_pb2.py", line 16, in <module>
from clarifai_grpc.grpc.api.status import status_pb2 as proto_dot_clarifai_dot_api_dot_status_dot_status__pb2
File "C:\Users\Ashraf\anaconda3\lib\site-packages\clarifai_grpc\grpc\api\status\status_pb2.py", line 15, in <module>
from clarifai_grpc.grpc.auth.util import extension_pb2 as proto_dot_clarifai_dot_auth_dot_util_dot_extension__pb2
File "C:\Users\Ashraf\anaconda3\lib\site-packages\clarifai_grpc\grpc\auth\util\extension_pb2.py", line 15, in <module>
from clarifai_grpc.grpc.auth.scope import scope_pb2 as proto_dot_clarifai_dot_auth_dot_scope_dot_scope__pb2
File "C:\Users\Ashraf\anaconda3\lib\site-packages\clarifai_grpc\grpc\auth\scope\scope_pb2.py", line 21, in <module>
_S = DESCRIPTOR.enum_types_by_name['S']
AttributeError: 'NoneType' object has no attribute 'enum_types_by_name'
I installed all required packages for the cod to run I am using python 3.9.12 on Windows 10 I try to downgrade version of protobuf from 3.20.x to 3.15.6 when i try check the protobuf version and i got this
Name: protobuf
Version: 3.15.6
Summary: Protocol Buffers
Home-page: https://developers.google.com/protocol-buffers/
Author:
Author-email:
License: 3-Clause BSD License
Location: c:\users\ashraf\anaconda3\lib\site-packages
Requires: six
Required-by: streamlit, googleapis-common-protos, google-api-core, gcloud, clarifai-grpc
I don't understand what to do