StepClassDeploy / app.py
GustavoFunchal's picture
[add] initial code
a4e9c05 verified
Raw History Blame Contribute Delete
716 Bytes
import pickle
import gradio as gr
# reading the trained model from file
with open('fruit_classifier.pkl', 'rb') as file:
trained_model = pickle.load(file)
# list of all available colors
list_colors = ['Green','Yellow','Red'] # 0=Green, 1=Yellow, 2=Red
def classify_fruits(weight, color, diameter):
# convert color 'text' to number
color_number = list_colors.index(color)
results = trained_model.predict([[weight, color_number, diameter]])
return results[0]
# color options
color_radio = gr.Radio(choices=list_colors, label="choose a color")
# creating basic interface
app = gr.Interface(fn=classify_fruits, inputs=['number',color_radio,'number'], outputs=['text'])
# running the app
app.launch()