File size: 6,348 Bytes
9b941f6 201b13c 9b941f6 201b13c 9b941f6 201b13c c36c5e5 201b13c c36c5e5 201b13c a3abb2d 201b13c c36c5e5 201b13c c36c5e5 201b13c c36c5e5 201b13c a3abb2d 201b13c c36c5e5 201b13c a3abb2d 201b13c c36c5e5 a3abb2d c36c5e5 a3abb2d 201b13c c36c5e5 201b13c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | ---
title: Manufacturing Monitoring System
emoji: 🏭
colorFrom: blue
colorTo: gray
sdk: docker
app_port: 7860
---
# Manufacturing Monitoring System
Manufacturing Monitoring System is a full-stack industrial monitoring platform for steel surface inspection. It generates automated reports, streams live updates over WebSockets, and exposes a production-style dashboard for real-time manufacturing visibility.
## Highlights
- Real-time defect detection for steel surface images
- Browser camera inspection and uploaded image inspection
- Fast real-time inspection mode with optional deep AI analysis
- Hosted or local AI recommendations with automatic fallback to rule-based guidance
- FastAPI backend with REST and WebSocket streaming
- Local JSON report persistence with optional PostgreSQL logging
- React + Vite + Tailwind monitoring dashboard
- Analytics, history, alerts, and live command center views
## Tech Stack
- Backend: FastAPI, Uvicorn, OpenCV, Ultralytics YOLO
- LLM: LangGraph + OpenRouter, Ollama, or Hugging Face Inference Providers
- Frontend: React, Vite, Tailwind CSS, Recharts
- Realtime: WebSocket broadcast pipeline
- Storage: Local reports plus optional PostgreSQL or Supabase
## Project Structure
```text
api/ FastAPI app and WebSocket server
agent/ Recommendation and decision helpers
core/ Config, logging, constants, database access
inspection/ Inference, formatting, reporting, service layer
dashboard/ React monitoring dashboard
models/ Trained defect detection model
training/ Experimental training utilities
test_images/ Sample images for local testing
live_camera.py Simulation runner for offline inspection playback
main.py Python entry point
```
## Features
### Dashboard
- Live decision status and connection health
- Inspection KPIs and critical alert banners
- Organized architecture and backend overview panels
### Live Monitoring
- Upload an image and run inspection
- Use browser camera feed for auto or manual live inspection
- Annotated preview output for every inspected frame
- Fast mode for real-time inspection and optional deep AI analysis toggle
- PASS, REVIEW, and FAIL guidance with visible operator feedback
- Camera calibration guidance for top-view steel inspection
### History
- Searchable inspection log
- Decision filtering
- Defect-level report detail view
### Analytics
- Severity distribution
- Decision distribution
- Defect-type frequency
- Timeline charts for inspection trends
## Backend API
### Main endpoints
- `GET /health`
- `GET /reports`
- `GET /reports/latest`
- `GET /analytics/summary`
- `POST /inspect/image`
- `POST /inspect/frame`
- `WS /ws`
## Environment Setup
Copy `.env.example` to `.env` if you want to configure PostgreSQL logging.
```env
DATABASE_URL=postgresql://username:password@hostname:6543/postgres
CORS_ORIGINS=http://127.0.0.1:5173,http://localhost:5173
ENABLE_LLM_REPORTS=true
LLM_PROVIDER=auto
OLLAMA_BASE_URL=http://127.0.0.1:11434
OLLAMA_MODEL=llama3
OLLAMA_TIMEOUT_SECONDS=6
HF_TOKEN=
HF_CHAT_MODEL=meta-llama/Llama-3.1-8B-Instruct:cerebras
HF_ROUTER_BASE_URL=https://router.huggingface.co/v1
OPENROUTER_API_KEY=
OPENROUTER_MODEL=openrouter/free
OPENROUTER_BASE_URL=https://openrouter.ai/api/v1
MAX_UPLOAD_SIZE_MB=8
```
`DATABASE_URL` is optional. If it is not set, the system still works and stores reports locally inside `reports/`.
If `ENABLE_LLM_REPORTS=true`, the system can use:
- `LLM_PROVIDER=auto` to prefer a hosted provider when configured and fall back automatically
- `LLM_PROVIDER=ollama` for local development with Ollama
- `LLM_PROVIDER=huggingface` for cloud deployment with `HF_TOKEN`
- `LLM_PROVIDER=openrouter` for low-volume free cloud demos with `OPENROUTER_API_KEY`
If the configured provider is unavailable, the app falls back to a rule-based recommendation path automatically.
## Camera Calibration
For the best live-monitoring performance, position the camera so the steel surface is clearly visible in a stable top view with minimal background clutter. This project is currently optimized around that operating assumption for public deployment.
## Deployment
For a single public URL without needing any local computer:
- Deploy the whole app as one Docker service
- The included [Dockerfile](/Users/ravindranadhm/Documents/Projects/steel-surface-inspection copy/Dockerfile) builds the React frontend and serves it from FastAPI
- Best free option: Hugging Face Docker Spaces
- Best frontend-only option: Vercel, if you later want a split architecture
Recommended Hugging Face Space environment variables:
```env
ENABLE_LLM_REPORTS=true
LLM_PROVIDER=auto
HF_TOKEN=your_huggingface_token
HF_CHAT_MODEL=meta-llama/Llama-3.1-8B-Instruct:cerebras
```
In deployed mode, keep deep AI analysis off for continuous live camera monitoring and enable it only for manual review or uploaded images.
## Local Run
### 1. Backend
```bash
cd "/Users/ravindranadhm/Documents/Projects/steel-surface-inspection copy"
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
venv/bin/uvicorn api.main:app --host 127.0.0.1 --port 8000
```
### 2. Frontend
```bash
cd "/Users/ravindranadhm/Documents/Projects/steel-surface-inspection copy/dashboard"
npm install
npm run dev -- --host 127.0.0.1 --port 5173
```
### 3. Open the app
- Frontend: `http://127.0.0.1:5173`
- Backend health: `http://127.0.0.1:8000/health`
## Verification
Recommended checks:
```bash
python -m compileall api core inspection agent live_camera.py main.py
```
```bash
cd dashboard
npm run lint
npm run build
```
## Notes
- The provided model file `models/steel_inspection.pt` is included in the project and is small enough for a standard GitHub repository.
- Browser camera inspection requires camera permission in your browser.
- Live camera mode is optimized to always return a visible inspection result, even when no defects are found.
- The frontend automatically uses the same origin as the backend when deployed as a single Docker service.
## Resume-Friendly Summary
Built an AI-powered manufacturing monitoring system for steel surface inspection using FastAPI, React, WebSocket streaming, OpenCV, Ultralytics YOLO, analytics dashboards, and live browser camera inspection.
|