So I am making a voice assisstant for fast food restaurants and to train the dataset on a model I have used distilbert. After training and saving the model in pickle file, now I testing it on web app via Gradio.
Here is the Gradio code
‘’’
import gradio as gr
import pickle
def make_prediction(text):
with open(“model.pickle”, “rb”) as f:
clf = pickle.load(f)
preds = clf.Trainer.predict([text]) # Assuming your model accepts a single text input
if preds == 1:
return “Sure I will add your order, that will be $30, anything else?”
elif preds == 2:
return “I have added newer items in the list as well that will be $55.”
elif preds == 3:
return “That’s a great choice, you want in the veg or non-veg section?”
elif preds == 4:
return “Your order will be ready in 20 mins”
elif preds == 5:
return “Okay, I will make the quantity according to the specified number of people”
output = gr.Textbox()
app = gr.Interface(fn=make_prediction, inputs=“text”, outputs=output)
app.launch()
‘’’
After running this I get following error
raise AttributeError(“‘{}’ object has no attribute ‘{}’”.format(
AttributeError: ‘BERT_Arch’ object has no attribute 'Trainer
Please can someone tell how to fix this…I completely new in ML