Download app.py from sunil11r/irisapp: direct link, hf CLI and curl.
- Browser
- Download file 940 Bytes
-
https://huggingface.co/spaces/sunil11r/irisapp/resolve/main/app.py
- Command line
-
hf download hf://spaces/sunil11r/irisapp/app.py
-
curl -L -o app.py https://huggingface.co/spaces/sunil11r/irisapp/resolve/main/app.py
940 Bytes
| import gradio as gr | |
| import numpy as np | |
| import pickle | |
| # Load the trained model | |
| model = pickle.load(open('model.pkl', 'rb')) | |
| iris_labels = ['Setosa', 'Versicolor', 'Virginica'] | |
| # Define the prediction function | |
| def predict_iris(sepal_length, sepal_width, petal_length, petal_width): | |
| data = np.array([[sepal_length, sepal_width, petal_length, petal_width]]) | |
| prediction = model.predict(data)[0] | |
| return f"Predicted Iris Species: {iris_labels[prediction]}" | |
| # Create the Gradio interface | |
| iface = 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="text", | |
| title="Iris Species Predictor", | |
| description="Enter the flower's measurements to predict the Iris species." | |
| ) | |
| # Launch the app | |
| if __name__ == "__main__": | |
| iface.launch() | |