Skip to content
dalaldia5Public

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

5 Commits

Folders and files

Repository files navigation

๐Ÿš— ParkSight - Intelligent Parking Management System

React Flask YOLOv8 Python

Real-time AI-powered parking management using YOLOv8 deep learning with 99%+ accuracy. Upload parking lot images for instant detection with color-coded bounding boxes, occupancy statistics, and interactive booking.


๐ŸŒŸ Features

  • ๐ŸŽฏ Real-time Detection - Process images in < 2 seconds
  • ๐Ÿง  YOLOv8m AI - 99.30% mAP50 accuracy
  • ๐ŸŽจ Visual Feedback - Green (empty) / Red (occupied) boxes
  • ๐Ÿ“Š Live Statistics - Real-time occupancy tracking
  • ๐ŸŽซ Smart Booking - Interactive slot reservation
  • ๐Ÿ“ฑ Modern UI - React 19 with Framer Motion
  • โšก Fast Inference - 50-200ms GPU, 500-1000ms CPU

๐Ÿ—๏ธ Architecture

Frontend (React 19)              Backend (Flask + YOLOv8)
http://localhost:5173            http://localhost:5001
        โ”‚                                 โ”‚
        โ”‚  POST /detect (image)           โ”‚
        โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€>โ”‚
        โ”‚                                 โ”‚ 1. Receive image
        โ”‚                                 โ”‚ 2. Run YOLOv8 inference  
        โ”‚                                 โ”‚ 3. Draw bounding boxes
        โ”‚                                 โ”‚ 4. Calculate statistics
        โ”‚                                 โ”‚ 5. Return JSON + base64
        โ”‚<โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
        โ”‚  {annotated_image_b64, stats}   โ”‚
        โ”‚                                 โ–ผ
                                    best.pt (52MB)
                                    YOLOv8m Model

๐Ÿš€ Quick Start

Prerequisites

  • Node.js โ‰ฅ 18
  • Python โ‰ฅ 3.10
  • npm/yarn

1. Clone & Install

# Clone repository
git clone https://github.com/dalaldia5/ParkSight
cd SmartPark

# Backend setup
cd backend
python -m venv venv
.\venv\Scripts\activate  # Windows
pip install -r requirements.txt

# Frontend setup
cd ../frontend
npm install

2. Obtain Model File (best.pt)

Option A: Kaggle Training (FREE GPU)

  1. Go to Kaggle
  2. Upload parking-lot-prediction.ipynb
  3. Add dataset: Search "pklot-yolov8"
  4. Enable GPU: Settings โ†’ GPU T4
  5. Run Cell 4 (2-3 hours)
  6. Download best.pt โ†’ Place in backend/

Option B: Download Pre-trained

  • Check project releases

3. Run Application

# Terminal 1: Backend
cd backend
C:/DevProjects/ParkSight/.venv/Scripts/python.exe app.py

# Terminal 2: Frontend  
cd frontend
npm run dev

4. Access


๐Ÿ“– User Guide

Detecting Parking Spaces

  1. Navigate to http://localhost:5173/parking
  2. Upload parking lot image (JPG/PNG, < 10MB)
  3. View Results:
    • Annotated image with bounding boxes
    • Confidence badge (typically 95-96%)
    • Statistics: Total/Occupied/Available counts
  4. Interactive Grid:
    • Each slot shows confidence score
    • Green slots = Available (clickable to book)
    • Red slots = Occupied (non-clickable)

Booking a Spot

  1. Click any green (available) slot in the grid
  2. Select duration (1-4 hours)
  3. Enter vehicle number
  4. Choose payment method
  5. Confirm booking โ†’ Download parking pass

๐Ÿ”Œ API Reference

Endpoints

GET  /health                    # Health check
POST /detect                    # Full detection (JSON + image)
POST /infer                     # Frontend-optimized
POST /detect/json               # JSON only
POST /detect/image              # Image only
GET  /download/<filename>       # Retrieve saved images

Request Example

curl -X POST http://localhost:5001/detect \
  -F "image=@parking_lot.jpg" \
  -F "confidence=0.25"

Response Example

{
  "success": true,
  "timestamp": "2024-01-15T10:30:00Z",
  "annotated_image_b64": "iVBORw0KGgoAAAA...",
  "occupied_count": 27,
  "free_count": 1,
  "per_spot": [true, true, false, true, ...],
  "confidence": [0.96, 0.95, 0.94, ...],
  "statistics": {
    "total_spaces": 28,
    "occupancy_rate": 96.43
  }
}

๐Ÿ“ Project Structure

ParkSight/
โ”œโ”€โ”€ frontend/                   # React 19 application
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ pages/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Parking.jsx    # โญ Main detection UI
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Booking.jsx    # Booking system
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Home.jsx       # Landing page
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Analytics.jsx  # Dashboard
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ Traffic.jsx    # Traffic monitor
โ”‚   โ”‚   โ””โ”€โ”€ components/         # Reusable components
โ”‚   โ””โ”€โ”€ package.json
โ”‚
โ”œโ”€โ”€ backend/                    # Flask API
โ”‚   โ”œโ”€โ”€ app.py                 # โญ Main API (601 lines)
โ”‚   โ”œโ”€โ”€ requirements.txt       # Python dependencies
โ”‚   โ”œโ”€โ”€ best.pt                # โš ๏ธ Model weights (REQUIRED)
โ”‚   โ”œโ”€โ”€ uploads/               # Temp storage
โ”‚   โ””โ”€โ”€ outputs/               # Results
โ”‚
โ”œโ”€โ”€ parking-lot-prediction.ipynb  # โญ Training notebook
โ”œโ”€โ”€ docs/                       # Additional documentation
โ”‚   โ”œโ”€โ”€ TRAINING_GUIDE.md      # Detailed training guide
โ”‚   โ”œโ”€โ”€ QUICK_START.md         # Quick reference
โ”‚   โ”œโ”€โ”€ ACCURACY_IMPROVEMENTS.md
โ”‚   โ”œโ”€โ”€ INTEGRATION_STATUS.md
โ”‚   โ””โ”€โ”€ INTEGRATION_COMPLETE.md
โ””โ”€โ”€ README.md                   # This file (main documentation)

๐ŸŽฏ Model Performance

Trained on PKLot Dataset (10,000+ images):

Metric Score Description
mAP50 99.30% Detection accuracy at 50% IoU
Precision 99.87% Correct positive predictions
Recall 99.14% Actual positives detected
F1-Score 99.50% Precision-recall harmonic mean

Classes: space-occupied (red), space-empty (green)
Confidence: Typically 94-97% per detection
Speed: 50-200ms (GPU), 500-1000ms (CPU)


๐Ÿ› ๏ธ Tech Stack

Frontend

  • React 19.1.1 with Vite 7.1.7
  • Styling: TailwindCSS 3.4
  • Animation: Framer Motion 12
  • Icons: Lucide React
  • Routing: React Router DOM 7
  • Charts: Recharts 3

Backend

  • Flask 3.0 with Flask-CORS
  • ML: YOLOv8m (Ultralytics)
  • Vision: OpenCV, Pillow
  • DL: PyTorch 2.0+, TorchVision
  • Data: NumPy, PKLot Dataset

๐Ÿ”ง Configuration

Backend (app.py)

MODEL_PATH = "best.pt"            # Model file
CONFIDENCE_THRESHOLD = 0.25       # Detection threshold
UPLOAD_FOLDER = "uploads"         # Temp storage
OUTPUT_FOLDER = "outputs"         # Results

COLORS = {
    'space-empty': (0, 255, 0),   # Green
    'space-occupied': (0, 0, 255) # Red
}

Frontend (Parking.jsx)

const API_URL = "http://localhost:5001";
const MAX_FILE_SIZE = 10 * 1024 * 1024;  // 10MB
const ACCEPTED_FORMATS = ['.jpg', '.png'];

๐Ÿ› Troubleshooting

Model Not Found

โŒ FileNotFoundError: best.pt

Solution: Train on Kaggle or download from releases. Place in backend/

No Detections

โš ๏ธ 0 objects detected

Solution: Lower CONFIDENCE_THRESHOLD to 0.15 in app.py

CORS Errors

โŒ Access-Control-Allow-Origin blocked

Solution: Verify backend running on localhost:5001

Port In Use

โŒ Port 5001 already in use

Solution:

Get-Process -Id (Get-NetTCPConnection -LocalPort 5001).OwningProcess | Stop-Process

๐Ÿ“š Additional Documentation

Detailed documentation is available in the docs/ folder:


๐Ÿš€ Deployment

Docker Deployment

Backend Dockerfile:

FROM python:3.10-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
EXPOSE 5001
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:5001", "app:app"]

Frontend Dockerfile:

FROM node:18-alpine as build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80

docker-compose.yml:

version: '3.8'
services:
  backend:
    build: ./backend
    ports:
      - "5001:5001"
    volumes:
      - ./backend/best.pt:/app/best.pt
  
  frontend:
    build: ./frontend
    ports:
      - "80:80"
    depends_on:
      - backend

๐Ÿค Contributing

Contributions welcome! Please:

  1. Fork the repository
  2. Create feature branch: git checkout -b feature/amazing-feature
  3. Commit changes: git commit -m 'Add amazing feature'
  4. Push to branch: git push origin feature/amazing-feature
  5. Open Pull Request

๐Ÿ“„ License

MIT License - See LICENSE file


๐Ÿ‘ฅ Team

Project Owner: Dia Dalal Repository: github.com/dalaldia5/ParkSight

Acknowledgments

  • YOLOv8: Ultralytics
  • PKLot Dataset: Federal University of Paranรก

๐Ÿ”ฎ Roadmap

v2.0 (Planned)

  • Real-time video stream support
  • Mobile app (React Native)
  • Multi-camera management
  • Payment gateway integration
  • Email/SMS notifications
  • Admin dashboard

v3.0 (Future)

  • License plate recognition
  • Vehicle type classification
  • IoT sensor integration
  • Cloud deployment templates

๐Ÿ“ž Support

Need Help?

  1. Documentation: Check guides in repository
  2. Issues: GitHub Issues
  3. Discussions: GitHub Discussions

FAQ

Q: How accurate is detection?
A: 99.30% mAP50, 99.87% precision, 99.14% recall

Q: Can I use commercially?
A: Yes, under MIT License terms

Q: Does it work with video?
A: Currently images only. Video support planned for v2.0

Q: GPU required?
A: Optional. CPU works but 5-10x slower



Made with โค๏ธ by the ParkSight Team

Report Bug โ€ข Request Feature โ€ข Documentation

โญ Star us on GitHub โ€” it motivates us a lot!


Version 1.0.0 | Status: Production Ready ๐Ÿš€ | Last Updated: November 25, 2025

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages