Skip to content

Ranjit-Saha/vehicle-damage-detection-microservice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚗 Vehicle Damage Detection System (Decoupled Microservice)

Live Web Application API Backend Python PyTorch Docker

A production-grade Computer Vision pipeline utilizing a decoupled architecture. A FastAPI PyTorch backend serves asynchronous inference to a lightweight Streamlit client.


📷 Application Preview

Vehicle Damage Detection System Live Demo
Figure 1: Reactive UI displaying seamless digital asset upload and remote API classification results.


🏗️ System Architecture: True Decoupling

Standard AI portfolio projects often rely on monolithic scripts that crash under concurrent user load. This system is engineered as a robust, distributed microservice, demonstrating industry-standard separation of concerns.

Component Responsibility Technology Stack Hosting Environment
Client UI (frontend/) Renders UI, handles asset uploads, and manages network requests. Contains zero machine learning logic. Streamlit, Requests, python-dotenv Streamlit Cloud
Inference Engine (backend/) Caches a fine-tuned ResNet50 model in global memory to asynchronously process tensor matrices. FastAPI, Uvicorn, PyTorch, PIL Hugging Face Spaces (Docker)

✨ Engineering Features

  • Deep Learning Backbone: Transfer-learned PyTorch ResNet50 with a Softmax distribution layer for exact mathematical confidence scoring.
  • Zero-Disk Overhead: Atomic memory streaming processes binary uploads directly in RAM, eliminating I/O bottlenecks and local storage leakage.
  • Failure-Aware Networking: The frontend client utilizes strict HTTP timeouts, JSON structure validation, and specific exception handling to fail gracefully during server cold-starts.
  • Runtime Security Configuration: Hardcoded configurations are stripped from the source code. API URLs are injected dynamically at runtime via .env files and Streamlit Secrets.

📂 Monorepo Structure

vehicle-damage-detection/
│
├── backend/                        # 🧠 Deep Learning API Service
│   ├── model/
│   │   └── saved_model.pth         # Cached PyTorch weights (Ignored in Git)
│   ├── server.py                   # FastAPI Routing Engine
│   ├── model_helper.py             # Tensor pre-processing & Softmax logic
│   ├── Dockerfile                  # Linux Container instructions
│   └── requirements.txt            # Isolated Backend Dependencies
│
├── frontend/                       # 🖥️ User Interface Service
│   ├── assets/                     # Application Preview
│   ├── app.py                      # Streamlit UI & Network Client
│   └── requirements.txt            # Isolated Frontend Dependencies
│
├── .gitignore                      # Security and cache exclusions
└── README.md                       # Master Documentation

💻 Local Developer Setup

To run this microservice architecture locally, you must initialize both nodes in separate terminals and configure your local environment variables.

1. Initialize the Backend API (Terminal 1)
Navigate to the backend directory, install dependencies, and boot the Uvicorn server.
(Note: You must manually download the saved_model.pth file from the Hugging Face Model Registry and place it inside the backend/model/ directory before booting).

cd backend
python -m venv venv
source venv/bin/activate  # On Windows use: venv\Scripts\activate
pip install -r requirements.txt

# Boot the API server on localhost:8000
uvicorn server:app --host 127.0.0.1 --port 8000

2. Configure Environment Variables
Inside the frontend/ directory, create a .env file to securely route your network requests.

# frontend/.env
API_URL=http://127.0.0.1:8000/predict 

(Note: For production deployment, update this URL to your live Hugging Face .hf.space endpoint).

3. Initialize the Frontend UI (Terminal 2)
Open a new terminal window, navigate to the frontend directory, and boot the Streamlit client:

cd frontend
python -m venv venv
source venv/bin/activate  # On Windows use: venv\Scripts\activate
pip install -r requirements.txt

# Boot the UI client
streamlit run app.py

👨‍💻 Author

Ranjit Saha
Geo-Computational Product Engineer
Building high-performance spatial computation engines and automated risk assessment pipelines.



About

A decoupled Computer Vision microservice featuring an asynchronous FastAPI inference engine (ResNet50) and a lightweight Streamlit client for vehicle damage assessment.

Topics

Resources

License

Stars

Watchers

Forks

Contributors