Skip to content

Latest commit

Β 

History

History
117 lines (85 loc) Β· 3.51 KB

File metadata and controls

117 lines (85 loc) Β· 3.51 KB

ML Deployment Suite: FastAPI & Streamlit Integration

This repository contains a full-stack implementation for serving and interacting with a Machine Learning model. The project demonstrates a robust MLOps pipeline by integrating a high-performance FastAPI backend with an interactive Streamlit frontend.

🎯 Project Goal

The primary objective of this project is to bridge the gap between model training and production deployment. It wraps a pre-trained machine learning model in a production-grade API and provides a user-friendly web interface for real-time predictions.


πŸš€ Key Features

  • Real-time Prediction: Instant model inference via API.
  • Interactive UI: User-friendly form for data entry using Streamlit.
  • Data Validation: Robust input validation using Pydantic models.
  • Containerized: Fully Dockerized for easy deployment and scalability.
  • API Documentation: Automatic interactive swagger documentation.

πŸ› οΈ Tech Stack


πŸ“¦ Running Project

If you prefer to run the application, follow these steps. You will need two separate terminal windows (one for the backend, one for the frontend).

1. Setup Environment

git clone https://github.com/kr-shobhit/ML_Model_Backend_FastAPI.git
cd ML_Model_Backend_FastAPI

2. Create Virtual Environment

python -m venv .venv        # For Windows
# python3 -m venv .venv     # For Mac/Linux

3. Activate Virtual Environment

.venv\Scripts\activate      # Windows
source .venv/bin/activate # Mac/Linux

4. Install Dependencies

pip install -r requirements.txt

5. Run Project

Note: This will require two indivisual terminals to run frontend and backend of the project.

uvicorn main:app --reload

The backend is now running at http://127.0.0.1:8000 .

cd frontend
streamlit run visual.py

The frontend should automatically open in your browser at http://localhost:8501 .


Folder Structure

β”œβ”€β”€ frontend/
β”‚   └── visual.py          # Streamlit application
β”œβ”€β”€ model/
β”‚   β”œβ”€β”€ model.pkl          # Pre-trained ML model
β”‚   └── trained_model.ipynb # Model training notebook
β”œβ”€β”€ validation/
β”‚   └── data_validation.py # Pydantic schemas
β”œβ”€β”€ dataset/               # Raw data files
β”œβ”€β”€ main.py                # FastAPI backend entry point
β”œβ”€β”€ requirements.txt       # Python dependencies
β”œβ”€β”€ Dockerfile.backend     # Backend Docker configuration
β”œβ”€β”€ Dockerfile.frontend    # Frontend Docker configuration
β”œβ”€β”€ docker-compose.yml     # Docker orchestration
└── README.md              # Project documentation

🀝 Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ License

Distributed under the MIT License. See LICENSE for more information.