Spaces:
Sleeping
Sleeping
Download app.py from Rahul23232/iris_project_tutorial: direct link, hf CLI and curl.
- Browser
- Download file 655 Bytes
-
https://huggingface.co/spaces/Rahul23232/iris_project_tutorial/resolve/main/app.py
- Command line
-
hf download hf://spaces/Rahul23232/iris_project_tutorial/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Rahul23232/iris_project_tutorial/resolve/main/app.py
655 Bytes
| import gradio as gr | |
| import pickle | |
| # Load model | |
| model = pickle.load(open("model.pkl", "rb")) | |
| flowers = ["Setosa", "Versicolor", "Virginica"] | |
| def predict(sepal_length, sepal_width, petal_length, petal_width): | |
| data = [[sepal_length, sepal_width, petal_length, petal_width]] | |
| pred = model.predict(data)[0] | |
| return flowers[pred] | |
| # UI | |
| interface = gr.Interface( | |
| fn=predict, | |
| inputs=[ | |
| gr.Number(label="Sepal Length"), | |
| gr.Number(label="Sepal Width"), | |
| gr.Number(label="Petal Length"), | |
| gr.Number(label="Petal Width") | |
| ], | |
| outputs="text", | |
| title="🌸 Flower Prediction App" | |
| ) | |
| interface.launch() |