Spaces:
Sleeping
Sleeping
Download app.py from JhunBrian/iris_docker: direct link, hf CLI and curl.
- Browser
- Download file 1.14 kB
-
https://huggingface.co/spaces/JhunBrian/iris_docker/resolve/main/app.py
- Command line
-
hf download hf://spaces/JhunBrian/iris_docker/app.py
-
curl -L -o app.py https://huggingface.co/spaces/JhunBrian/iris_docker/resolve/main/app.py
1.14 kB
| from flask import Flask, render_template, request | |
| import iris_model | |
| app = Flask(__name__) | |
| def basic(): | |
| if request.method == 'POST': | |
| sepal_length = request.form['sepallength'] | |
| sepal_width = request.form['petalwidth'] | |
| petal_length = request.form['petallength'] | |
| petal_width = request.form['petalwidth'] | |
| y_pred = [[sepal_length, sepal_width, petal_length, petal_width]] | |
| trained_model = iris_model.training_model() | |
| prediction_value = trained_model.predict(y_pred) | |
| setosa = 'The flower is classified as Setosa' | |
| versicolor = 'The flower is classified as Versicolor' | |
| virginica = 'The flower is classified as Virginica' | |
| if prediction_value == 0: | |
| return render_template('index.html', setosa=setosa) | |
| elif prediction_value == 1: | |
| return render_template('index.html', versicolor=versicolor) | |
| else: | |
| return render_template('index.html', virginica=virginica) | |
| return render_template('index.html') | |
| if __name__ == '__main__': | |
| app.run(host="0.0.0.0", port=7860) |