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.
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.
- 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.
- Framework: FastAPI
- Web Server: Uvicorn
- Data Validation: Pydantic
- Frontend: Streamlit
- Containerization: Docker & Docker Compose
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).
git clone https://github.com/kr-shobhit/ML_Model_Backend_FastAPI.gitcd ML_Model_Backend_FastAPIpython -m venv .venv # For Windows# python3 -m venv .venv # For Mac/Linux.venv\Scripts\activate # Windowssource .venv/bin/activate # Mac/Linuxpip install -r requirements.txtNote: This will require two indivisual terminals to run frontend and backend of the project.
uvicorn main:app --reloadThe backend is now running at http://127.0.0.1:8000 .
cd frontend
streamlit run visual.pyThe frontend should automatically open in your browser at http://localhost:8501 .
├── 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 documentationContributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch
(git checkout -b feature/AmazingFeature) - Commit your Changes
(git commit -m 'Add some AmazingFeature') - Push to the Branch
(git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the MIT License. See LICENSE for more information.