MCPcopy Index your code
hub / github.com/computer-vision-with-marco/yolo-training-template

github.com/computer-vision-with-marco/yolo-training-template @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
28 symbols 142 edges 8 files 24 documented · 86%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

YOLO Training Template

This repository provides a template for training YOLO models on any Kaggle dataset and performing inference. It includes scripts for command-line use and a notebook-style script for interactive environments.

https://github.com/user-attachments/assets/a953e6a4-c97b-4149-994d-188aeb5dd398

Files

Setup

  1. Install dependencies: pip install -r requirements.txt
  2. For training: Run python scripts/main.py --dataset <kaggle-handle> --nc <num-classes> --names <class-names>
  3. For training with preprocessing: Run python scripts/main.py --dataset <kaggle-handle> --nc <num-classes> --names <class-names> --preprocess
  4. For training with NCNN export: Run python scripts/main.py --dataset <kaggle-handle> --nc <num-classes> --names <class-names> --export-ncnn
  5. For inference: Run python scripts/inference.py --model <model-path> --input <image/video/webcam>
  6. For the Streamlit app: Run streamlit run streamlit_app.py
  7. For non-technical setup: Please see docs/QUICKSTART-GUIDE.md

Data Preprocessing

The template includes optional data preprocessing capabilities for cleaning and augmenting your dataset:

  • Data Cleaning: Remove corrupted images, validate annotations, check bounding box validity
  • Data Augmentation: Apply various transformations (flips, rotations, color adjustments, noise) while properly updating YOLO labels

Preprocessing Options

  • --preprocess: Run cleaning and augmentation before training
  • --augment-only: Only run augmentation (creates augmented dataset without training)
  • --preprocess-config: Specify custom preprocessing configuration file (default: preprocessing_config.yaml)

Configuration

Edit preprocessing_config.yaml to customize preprocessing behavior:

cleaning:
  remove_corrupted_images: true
  validate_annotations: true
  check_bbox_validity: true
  min_bbox_size: 1
  max_bbox_size_ratio: 0.9

augmentation:
  enabled: true
  augment_factor: 2  # Number of augmented versions per image
  transforms:
    horizontal_flip:
      p: 0.5  # Probability
    # ... other transforms

Model Export

The template supports exporting trained YOLO models to different formats for deployment on various platforms.

Export Options

  • --export-ncnn: Export the trained model to NCNN format after training (suitable for edge hardware like mobile devices)

Usage

To train and export to NCNN:

python scripts/main.py --dataset <kaggle-handle> --nc <num-classes> --names <class-names> --export-ncnn

Streamlit App

The Streamlit app includes an "Export" page where you can upload a trained model and export it to NCNN format for download.

Notes on NCNN

  • NCNN is optimized for mobile and embedded devices, providing efficient inference with low latency.
  • Exported models include .param and .bin files in a directory (e.g., model_ncnn/).
  • Use ONNX Runtime or NCNN's inference engine for deployment.

Contributing

We welcome contributions! Please see docs/CONTRIBUTING.md for guidelines on how to contribute, report issues, and run the notebook on Google Colab.

Core symbols most depended-on inside this repo

preprocess_dataset
called by 4
scripts/preprocessing.py
augment_dataset
called by 2
scripts/preprocessing.py
parse_yolo_labels
called by 2
scripts/dataset_explorer.py
draw_annotations
called by 2
scripts/dataset_explorer.py
load_model
called by 2
scripts/inference.py
train_model
called by 2
scripts/main.py
create_yolo_dataset
called by 1
autolabeling/auto-label.py
main
called by 1
autolabeling/auto-label.py

Shape

Function 20
Method 7
Class 1

Languages

Python100%

Modules by API surface

scripts/preprocessing.py9 symbols
scripts/main.py6 symbols
scripts/inference.py5 symbols
scripts/dataset_explorer.py5 symbols
autolabeling/auto-label.py2 symbols
scripts/select_blurring.py1 symbols

For agents

$ claude mcp add yolo-training-template \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page