Skip to content

duonghieu7104/Yolo-Vision-Hub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Yolo Vision Hub

A comprehensive computer vision project featuring face recognition, object detection, and image processing algorithms. This project integrates multiple vision tasks into a unified Streamlit web application.

πŸ“‹ Project Overview

This repository contains three main tasks, each demonstrating different computer vision techniques:

  1. Face Recognition System (Folder 1/)
  2. YOLO Object Detection (Folder 2/)
  3. Image Processing Algorithms (Folder 3/)

πŸš€ Features

Task 1: Face Recognition System (1/)

A complete face recognition pipeline using OpenCV's YuNet face detector and SFace face recognizer, combined with an SVM classifier.

Components:

  • Buoc1 (1/Buoc1/get_face.py): Face detection and extraction from video stream

    • Real-time face detection from IP camera
    • Automatic face alignment and cropping
    • Saves detected faces to dataset folder
  • Buoc2 (1/Buoc2/Training.py): Model training

    • Extracts 128-dimensional face embeddings using SFace
    • Trains LinearSVC classifier on face embeddings
    • Saves trained model (svc.pkl) for recognition
  • Buoc3 (1/Buoc3/predict.py): Real-time face recognition

    • Live face recognition from video stream
    • Displays recognized person names in real-time
    • Visualizes face landmarks and bounding boxes

Models Used:

  • face_detection_yunet_2023mar.onnx: Face detection model
  • face_recognition_sface_2021dec.onnx: Face recognition/embedding model
  • svc.pkl: Trained SVM classifier

Dataset:

  • Face images organized by person in 1/image/ directory
  • Currently includes: DaiLong, MinhHieu, MinhHoang, VanThang, caothang

Usage:

# Step 1: Collect face images
cd 1/Buoc1
python get_face.py --video http://192.168.0.100:8080/video

# Step 2: Train the classifier
cd ../Buoc2
python Training.py

# Step 3: Run face recognition
cd ../Buoc3
python predict.py --video http://192.168.0.101:8080/video

Task 2: YOLO Object Detection (2/)

YOLO v8-based object detection system for fruit recognition.

Features:

  • Training Script (2/train_yolo.py): Custom YOLO model training
  • GUI Application (2/yolo_detector_gui.py): Tkinter-based desktop application
    • Image upload and prediction
    • Real-time object detection with bounding boxes
    • Confidence score display

Classes Detected:

  1. SauRieng (Durian)
  2. Tao (Apple)
  3. ThanhLong (Dragon Fruit)
  4. Chuoi (Banana)
  5. Kiwi

Dataset:

  • Training data: 2/data/TraiCayx5-640x640_OK/
    • Train set: 288 images
    • Validation set: 72 images
  • Raw images: 2/data/TraiCayScratch/
  • Model: 2/model/best.onnx

Usage:

# Train YOLO model
cd 2
python train_yolo.py

# Run GUI application
python yolo_detector_gui.py

Task 3: Image Processing Algorithms (3/)

Comprehensive collection of image processing algorithms organized into three chapters.

Chapter 3: Basic Image Enhancement (3/chapter3.py)

  • Point Operations:

    • Negative transformation
    • Logarithmic transformation
    • Power-law (gamma) transformation
    • Piecewise linear transformation
  • Histogram Processing:

    • Histogram visualization
    • Histogram equalization (grayscale & color)
    • Local histogram equalization
    • Histogram statistics-based enhancement
  • Spatial Filtering:

    • Smoothing filters (Box, Gaussian)
    • Median filter
    • Sharpening filters (Laplacian, Unsharp masking)
    • Gradient computation

Chapter 4: Frequency Domain Filtering (3/chapter4.py)

  • FFT spectrum visualization
  • Frequency domain filtering
  • Moire pattern removal
  • Motion blur simulation
  • Interference removal

Chapter 9: Morphological Operations (3/chapter9.py)

  • Erosion
  • Dilation
  • Boundary extraction
  • Contour detection and visualization

Usage:

cd 3
python test_c3_4_9.py

🌐 Streamlit Web Application

A unified web interface (streamlit/app.py) that integrates all three tasks:

Features:

  1. Face Recognition (NhαΊ­n diện khuΓ΄n mαΊ·t)

    • Image upload
    • Video upload
    • Real-time webcam streaming (WebRTC)
  2. Object Detection (NhαΊ­n diện Δ‘α»‘i tượng)

    • Fruit detection using YOLO model
    • Real-time prediction with confidence scores
  3. Image Processing (Xα»­ lΓ½ αΊ£nh sα»‘)

    • Interactive UI for all Chapter 3, 4, and 9 operations
    • Before/after image comparison
    • Export processed images
  4. Handwriting OCR (Đọc chữ viết tay)

    • Handwritten text recognition using LSTM-based model

Running the Streamlit App:

cd streamlit
pip install -r requirements.txt
streamlit run app.py

The app will be available at http://localhost:8501


πŸ“ Project Structure

Yolo-Vision-Hub/
β”œβ”€β”€ 1/                          # Face Recognition Task
β”‚   β”œβ”€β”€ Buoc1/                  # Face collection
β”‚   β”‚   β”œβ”€β”€ get_face.py
β”‚   β”‚   └── get_face - Copy.py
β”‚   β”œβ”€β”€ Buoc2/                  # Training
β”‚   β”‚   └── Training.py
β”‚   β”œβ”€β”€ Buoc3/                  # Prediction
β”‚   β”‚   └── predict.py
β”‚   β”œβ”€β”€ image/                  # Face dataset
β”‚   β”‚   β”œβ”€β”€ caothang/
β”‚   β”‚   β”œβ”€β”€ DaiLong/
β”‚   β”‚   β”œβ”€β”€ MinhHieu/
β”‚   β”‚   β”œβ”€β”€ MinhHoang/
β”‚   β”‚   └── VanThang/
β”‚   └── model/                  # Pre-trained models
β”‚       β”œβ”€β”€ face_detection_yunet_2023mar.onnx
β”‚       β”œβ”€β”€ face_recognition_sface_2021dec.onnx
β”‚       └── svc.pkl
β”‚
β”œβ”€β”€ 2/                          # YOLO Object Detection
β”‚   β”œβ”€β”€ data/                   # Training dataset
β”‚   β”‚   β”œβ”€β”€ TraiCayScratch/     # Raw images
β”‚   β”‚   └── TraiCayx5-640x640_OK/  # Processed dataset
β”‚   β”œβ”€β”€ model/                  # YOLO model
β”‚   β”‚   └── best.onnx
β”‚   β”œβ”€β”€ train_yolo.py          # Training script
β”‚   β”œβ”€β”€ train_yolo_v8n(2).ipynb
β”‚   β”œβ”€β”€ yolo_detector_gui.py   # GUI application
β”‚   └── yolo2.py
β”‚
β”œβ”€β”€ 3/                          # Image Processing
β”‚   β”œβ”€β”€ chapter3.py            # Basic enhancement
β”‚   β”œβ”€β”€ chapter4.py            # Frequency domain
β”‚   β”œβ”€β”€ chapter9.py            # Morphology
β”‚   β”œβ”€β”€ test_c3_4_9.py        # Test script
β”‚   └── image_test/            # Test images
β”‚
β”œβ”€β”€ 4/                          # OCR Model Training
β”‚   β”œβ”€β”€ data_test/
β”‚   β”œβ”€β”€ model/
β”‚   β”‚   └── best_model.h5
β”‚   └── train.ipynb
β”‚
└── streamlit/                  # Web application
    β”œβ”€β”€ app.py                 # Main Streamlit app
    β”œβ”€β”€ chapter3.py, chapter4.py, chapter9.py
    β”œβ”€β”€ face_recognition_utils.py
    β”œβ”€β”€ video_processor.py
    β”œβ”€β”€ stream_processor.py
    β”œβ”€β”€ ocr_utils.py
    β”œβ”€β”€ requirements.txt
    └── model/                 # All models
        β”œβ”€β”€ best_model.h5      # OCR model
        β”œβ”€β”€ best.onnx          # YOLO model
        β”œβ”€β”€ face_detection_yunet_2023mar.onnx
        β”œβ”€β”€ face_recognition_sface_2021dec.onnx
        └── svc.pkl            # Face recognition classifier

πŸ› οΈ Dependencies

Core Libraries:

  • opencv-python / opencv-contrib-python - Computer vision operations
  • numpy - Numerical operations
  • scikit-learn - Machine learning (SVM classifier)
  • ultralytics - YOLO v8 implementation
  • joblib - Model serialization

For Streamlit App:

  • streamlit - Web application framework
  • streamlit-webrtc - Real-time video streaming
  • keras / tensorflow - Deep learning (OCR model)

Installation:

# Install core dependencies
pip install opencv-python opencv-contrib-python numpy scikit-learn ultralytics joblib

# Install Streamlit dependencies
cd streamlit
pip install -r requirements.txt

πŸ“ Usage Examples

Face Recognition Pipeline:

  1. Collect face data: Run 1/Buoc1/get_face.py with your IP camera
  2. Train model: Execute 1/Buoc2/Training.py to train the SVM classifier
  3. Recognize faces: Use 1/Buoc3/predict.py for real-time recognition

YOLO Fruit Detection:

  1. Train model: Use 2/train_yolo.py or the Jupyter notebook
  2. Run GUI: Launch 2/yolo_detector_gui.py for desktop application
  3. Use in Streamlit: Access through the web interface

Image Processing:

  1. Import functions from chapter3.py, chapter4.py, or chapter9.py
  2. Use the Streamlit web interface for interactive processing
  3. Or run test_c3_4_9.py for batch processing

🎯 Key Technologies

  • Face Recognition: OpenCV DNN (YuNet + SFace) + SVM
  • Object Detection: YOLO v8 (Ultralytics)
  • Image Processing: OpenCV + NumPy
  • Web Interface: Streamlit + WebRTC
  • OCR: LSTM-based neural network (Keras/TensorFlow)

πŸ“„ License

This project is for educational and research purposes.


πŸ‘€ Author

Demo by HieuDuong


πŸ”— Model Sources


πŸ“Œ Notes

  • IP camera URLs need to be configured in the scripts
  • Model paths may need adjustment based on your system
  • Ensure all model files are present in the respective model/ directories
  • For best results, use high-quality images and proper lighting conditions

About

πŸš€ Computer Vision Hub: Real-time face recognition (OpenCV + SVM), YOLO object detection, and advanced image processing with Streamlit UI

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors