Spaces:
Paused
Paused
Download app.py from soniyayadav/first: direct link, hf CLI and curl.
- Browser
- Download file 791 Bytes
-
https://huggingface.co/spaces/soniyayadav/first/resolve/main/app.py
- Command line
-
hf download hf://spaces/soniyayadav/first/app.py
-
curl -L -o app.py https://huggingface.co/spaces/soniyayadav/first/resolve/main/app.py
791 Bytes
| import gradio as gr | |
| import joblib | |
| import numpy as np | |
| model = joblib.load("knn_model.pkl") | |
| scaler = joblib.load("scaler.pkl") | |
| def predict_iris(sepal_length, sepal_width, petal_length, petal_width): | |
| data = np.array([[ | |
| sepal_length, | |
| sepal_width, | |
| petal_length, | |
| petal_width | |
| ]]) | |
| data_scaled = scaler.transform(data) | |
| prediction = model.predict(data_scaled) | |
| return prediction[0] | |
| demo = gr.Interface( | |
| fn=predict_iris, | |
| inputs=[ | |
| gr.Number(label="Sepal Length (cm)"), | |
| gr.Number(label="Sepal Width (cm)"), | |
| gr.Number(label="Petal Length (cm)"), | |
| gr.Number(label="Petal Width (cm)") | |
| ], | |
| outputs=gr.Textbox(label="Predicted Species"), | |
| title="Iris Flower Classification using KNN" | |
| ) | |
| demo.launch() |