Spaces:
Build error
Build error
Download app.py from GustavoFunchal/StepClassDeploy: direct link, hf CLI and curl.
- Browser
- Download file 716 Bytes
-
https://huggingface.co/spaces/GustavoFunchal/StepClassDeploy/resolve/main/app.py
- Command line
-
hf download hf://spaces/GustavoFunchal/StepClassDeploy/app.py
-
curl -L -o app.py https://huggingface.co/spaces/GustavoFunchal/StepClassDeploy/resolve/main/app.py
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() |