Skip to content

Repository files navigation

🦾 YOLO Model Selection and Detection System

A comprehensive tool built on top of Ultralytics YOLO that provides both automatic image detection and model comparison capabilities. This software allows you to select from multiple trained models, process images with detection, and compare model performance across different datasets.


πŸš€ Features

  • 🎯 Dynamic Model Selection - Choose from multiple model folders and files
  • πŸ” Automatic Image Detection - Process images with selected YOLO models
  • πŸ“Š Model Comparison - Compare performance of multiple models
  • πŸ“‚ Organized Output - All results saved in structured output folder
  • 🎬 Video Generation - Create videos from detection results
  • 🧠 Dynamic Class Loading - Automatically loads classes from model folders
  • πŸ“ YOLO Format Support - Generates standard YOLO annotation files

πŸ“Έ Screenshots

Main Interface

Main Interface

Detection Results

Detection Results


🎯 Precision & Accuracy

Detection Accuracy

Detection Accuracy

Model Performance

Model Performance

πŸ”§ Requirements

  • Python 3.13.2
  • Ultralytics YOLO
  • OpenCV
  • Pandas (for model comparison)

Install dependencies:

pip install ultralytics opencv-python pandas pyyaml

πŸš€ How to Use

0. Setup Virtual Environment

First, create and activate a virtual environment:

# Create virtual environment
python -m venv venv

# Activate virtual environment
# On Windows:
venv\Scripts\activate

# On macOS/Linux:
source venv/bin/activate

1. Setup Your Models

Organize your trained models in the following structure:

models/
β”œβ”€β”€ cars/
β”‚   β”œβ”€β”€ best1.pt
β”‚   β”œβ”€β”€ best2.pt
β”‚   β”œβ”€β”€ best3.pt
β”‚   └── classes.txt
└── receipts/
    β”œβ”€β”€ best1.pt
    └── classes.txt

2. Prepare Your Dataset

Place your images and labels in the dataset/ folder:

dataset/
β”œβ”€β”€ image1.jpg
β”œβ”€β”€ image1.txt
β”œβ”€β”€ image2.jpg
β”œβ”€β”€ image2.txt
└── ...

3. Run the System

Make sure your virtual environment is activated, then run:

# Ensure virtual environment is activated (you should see (venv) in your terminal)
python main.py

πŸ“‹ Workflow

Step 1: Feature Selection

Choose between two main features:

  • Process Images (Detection) - Run object detection on your dataset
  • Compare Models - Compare performance of multiple models

Step 2: Model Folder Selection

Select the model folder (e.g., "cars" or "receipts") containing your trained models.

Step 3: Processing

For Detection:

  1. Select specific model file (e.g., "best1.pt")
  2. System loads model and classes automatically
  3. Processes all images in dataset folder
  4. Generates results in organized output structure

For Model Comparison:

  1. System automatically finds all models in selected folder
  2. Creates comparer dataset structure
  3. Evaluates each model on validation data
  4. Generates comparison report

πŸ“ Project Structure

project/
β”œβ”€β”€ main.py                 # Main entry point
β”œβ”€β”€ Engine/                 # Core engine files
β”‚   β”œβ”€β”€ start.py           # Detection processing
β”‚   β”œβ”€β”€ yolo_detection.py  # YOLO detection logic
β”‚   β”œβ”€β”€ create_video.py    # Video generation
β”‚   β”œβ”€β”€ compare.py         # Model comparison
β”‚   β”œβ”€β”€ data.yaml          # Dynamic data configuration
β”‚   └── comparer/          # Comparison dataset (auto-created)
β”‚       β”œβ”€β”€ images/val/    # Validation images
β”‚       └── labels/val/    # Validation labels
β”œβ”€β”€ models/                # Your trained models
β”‚   β”œβ”€β”€ cars/
β”‚   β”‚   β”œβ”€β”€ best1.pt
β”‚   β”‚   β”œβ”€β”€ best2.pt
β”‚   β”‚   └── classes.txt
β”‚   └── receipts/
β”‚       β”œβ”€β”€ best1.pt
β”‚       └── classes.txt
β”œβ”€β”€ dataset/               # Input images and labels
β”œβ”€β”€ output/                # All generated results
β”‚   β”œβ”€β”€ saved/            # Images with detections
β”‚   β”œβ”€β”€ labels/           # YOLO annotation files
β”‚   β”œβ”€β”€ output_video.mp4  # Generated video
β”‚   └── model_comparison.csv # Comparison results
└── README.md

✨ Output Format

Detection Results

Images with Bounding Boxes

  • Saved in output/saved/
  • Shows detected objects with confidence scores
  • Color-coded by class

YOLO Annotation Files

  • Saved in output/labels/
  • Standard YOLO format: <class_id> <x_center> <y_center> <width> <height>
  • Normalized coordinates (0-1)

Classes File

  • output/labels/classes.txt
  • Lists all class names used by the model

Model Comparison Results

CSV Report

  • Saved as output/model_comparison.csv
  • Contains metrics: Precision, Recall, mAP50, mAP50-95
  • Easy to analyze in Excel or other tools

🎯 Example Workflow

Detection Example:

1. Run: python main.py
2. Select: "1. Process Images (Detection)"
3. Select: "1. cars" (model folder)
4. Select: "1. best1.pt" (specific model)
5. Results: Images with detections in output/saved/

Comparison Example:

1. Run: python main.py
2. Select: "2. Compare Models"
3. Select: "1. cars" (model folder)
4. Results: Comparison report in output/model_comparison.csv

🧠 Dynamic Features

Automatic Class Loading

  • Reads classes.txt from model folder
  • Automatically configures detection classes
  • No manual class configuration needed

Dynamic Data Configuration

  • Creates data.yaml automatically for model comparison
  • Uses classes from selected model folder
  • Configures validation paths correctly

Organized Output

  • All results saved in output/ folder
  • Automatic folder creation and cleanup
  • Consistent file organization

πŸ›‘ Error Handling

The system includes comprehensive error handling:

  • Model validation before processing
  • Class file verification
  • Dataset folder existence checks
  • Clear error messages for troubleshooting

πŸ›‘ License

MIT License


πŸ‘¨β€πŸ’» Author

Built with ❀️ in Pakistan

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages