CoolFace
Apppublic

LovnishVerma/ONNX

sourceHugging Facemitupdated 1y agoView on Hugging Face
1likes
App README

๐ŸŒธ Iris Flower Classifier (Flask + ONNX)

This project is a simple Flask web application that predicts the species of an Iris flower based on its measurements using a pre-trained Logistic Regression model. The model is exported in ONNX (Open Neural Network Exchange) format, allowing for efficient, framework-independent inference.


๐Ÿš€ Model Training Colab Notebook

https://github.com/lovnishverma/Python-Getting-Started/blob/main/ONNXModelwithYourDataset.ipynb

๐Ÿš€ Live Demo

๐Ÿ“Œ Enter sepal length, sepal width, petal length, and petal width ๐Ÿ“Œ Get predicted Iris species: Setosa, Versicolor, or Virginica

๐Ÿ“ Project Structure

.
โ”œโ”€โ”€ app.py                  # Flask web app
โ”œโ”€โ”€ iris_model.onnx         # ONNX-trained model
โ”œโ”€โ”€ Dockerfile              # Dockerfile For HuggingFace   
โ”œโ”€โ”€ class_labels.json       # Class label mapping
โ”œโ”€โ”€ requirements.txt        # Required Python packages
โ””โ”€โ”€ templates/
    โ””โ”€โ”€ index.html          # HTML form for input

image/png

๐Ÿ’ก Features

  • โ€”๐Ÿง  Trained with scikit-learn Logistic Regression
  • โ€”๐Ÿ”„ Converted to ONNX for optimized runtime inference
  • โ€”๐ŸŒ Deployed with Flask and HTML frontend
  • โ€”๐Ÿช„ Clean input form with real-time result display

๐Ÿ“ฆ Setup Instructions

  1. 1.Clone the Repository
bash
   git clone https://github.com/lovnishverma/iris-onnx-flask.git
   cd iris-onnx-flask
  1. 1.Install Dependencies
bash
   pip install -r requirements.txt
  1. 1.Run the Flask App
bash
   python app.py
  1. 1.Open in Browser
   http://127.0.0.1:5000

๐Ÿงช Test Example

Try the following values:

text
Sepal Length: 5.7
Sepal Width: 3.2
Petal Length: 5.2
Petal Width: 1.9

Output:

Predicted Flower Type: virginica

๐Ÿค– Why ONNX instead of Pickle or Joblib?

FeaturePickle/JoblibONNX
๐Ÿ”’ SecurityUnsafe for web apps (can execute code)Safer (no code execution risk)
๐Ÿ”„ InteroperabilityPython onlyWorks across platforms/languages
โšก SpeedOK in PythonFaster inference (especially with ONNX Runtime)
โ˜๏ธ DeploymentLimitedIdeal for production, Docker, or cloud
๐Ÿ“ฆ Size & FormatPython-specificEfficient binary format, language-independent
โœ… ONNX is preferred when deploying machine learning models in production or cross-platform environments.

๐Ÿ“š Requirements

txt
flask
onnxruntime
numpy
gunicorn

๐Ÿ“œ License

This project is licensed under the MIT License.


๐Ÿ™‹โ€โ™‚๏ธ Author

Made with โค๏ธ by Lovnish Verma