Skip to content

naz23/YOLO-code

Repository files navigation

YOLO Leaf Color Detection & Object Tracking

This repository contains a collection of scripts for training, converting, and running YOLO object detection models. It includes utilities for creating leaf color datasets (Green, Yellow, Brown), running real-time webcam/video detection, exporting to ONNX, and a full-featured Streamlit web application.

🚀 Getting Started

Prerequisites

Ensure you have the required dependencies installed:

pip install ultralytics opencv-python numpy streamlit onnxruntime

Training

To train the YOLO model on your dataset, use the following command:

yolo detect train data=dataset/data.yaml model=yolov8n.pt epochs=100 imgsz=640 device=0

📂 Scripts & Usage

1. Streamlit Web App (streamlit_app.py)

A fast, cached web interface for testing YOLO models on webcams, videos, and images.

streamlit run streamlit_app.py

2. Video & Webcam Detection (yolo_video.py)

Run YOLO object detection on a video file or webcam stream.

# Run on webcam (default)
python yolo_video.py --model yolo11n.pt --source 0 --conf 0.8

# Run on a video file
python yolo_video.py --model yolo11n.pt --source test_video.mp4 --conf 0.5

3. Multi-Threaded ONNX Detection (yolo_onx.py)

Captures frames and processes them concurrently using ThreadPoolExecutor for ONNX models.

python yolo_onx.py

4. SORT Object Tracking (yoloon.py)

Combines YOLO ONNX detection with a Kalman Filter-based SORT algorithm to track objects (like persons) across video frames.

python yoloon.py

5. ONNX Export (convert_onxx.py)

Exports a trained PyTorch model (.pt) to ONNX format.

python convert_onxx.py

6. Dataset Converters

Convert your image datasets into YOLO format.

Color-Based Segmentation (cv_yolo_convert.py) Filters leaves by HSV ranges (Green, Yellow, Brown) and generates bounding box annotations.

python cv_yolo_convert.py --image_folder dataset/images/train --output_folder dataset/labels/train --show

Full-Image Bounding Boxes (convert_to_yolo.py) Treats entire images as single bounding boxes for classification-style YOLO training.

python convert_to_yolo.py --base_folder dataset/images/train --output_folder dataset/labels/train

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages