Spaces:
Build error
Build error
File size: 716 Bytes
a4e9c05 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 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() |