Add multi-framework dataset setup for RF-DETR, YOLOX, and YOLOv6
- Create dataset_coco/ for RF-DETR (COCO format) - Rename dataset_split/ to dataset_yolo/ for clarity - Add setup_datasets.py script for automated multi-format setup - Update YOLOv6 script with correct 10-class configuration - Update README with framework comparison and training instructions - Update .gitignore to exclude both dataset directories
This commit is contained in:
83
README.md
83
README.md
@ -31,7 +31,9 @@ This repository contains a complete wood defect detection system using YOLOX/YOL
|
||||
- Valid: 2,027 images
|
||||
- Test: 2,029 images
|
||||
|
||||
**Format**: YOLO format (images/ and labels/ subdirectories with data.yaml configuration)
|
||||
**Formats Available**:
|
||||
- `dataset_coco/` → COCO format for RF-DETR
|
||||
- `dataset_yolo/` → YOLO format for YOLOX, YOLOv6, YOLOv8
|
||||
|
||||
## 🚀 Quick Start
|
||||
|
||||
@ -48,21 +50,19 @@ source .venv/bin/activate
|
||||
|
||||
# Install dependencies
|
||||
pip install -U pip
|
||||
pip install ultralytics gradio
|
||||
pip install ultralytics gradio rfdetr
|
||||
```
|
||||
|
||||
### 2. Download Dataset
|
||||
|
||||
The dataset is not included in the repository due to size. Download from Kaggle and organize as follows:
|
||||
### 2. Setup Datasets
|
||||
|
||||
```bash
|
||||
# Download from Kaggle (requires Kaggle API)
|
||||
# Download dataset from Kaggle (requires Kaggle API)
|
||||
kaggle datasets download -d kirs0816/wood-surface-defects
|
||||
unzip wood-surface-defects.zip
|
||||
|
||||
# Run the dataset preparation script
|
||||
python split_coco_dataset.py
|
||||
python reorganize_dataset.py
|
||||
# Create multi-format datasets
|
||||
python split_coco_dataset.py # Creates dataset_yolo/
|
||||
python setup_datasets.py # Creates dataset_coco/ and updates configs
|
||||
```
|
||||
|
||||
### 3. Launch Annotation GUI
|
||||
@ -77,10 +77,38 @@ Open http://localhost:7860 in your browser to access the web-based annotation in
|
||||
- Manual annotation tools
|
||||
- Real-time result visualization
|
||||
|
||||
### 4. Train Model
|
||||
### 4. Train Models
|
||||
|
||||
Choose from three different frameworks:
|
||||
|
||||
#### RF-DETR (Highest accuracy, slower training)
|
||||
```bash
|
||||
python train_yolox.py --dataset-dir dataset_split --model yolox-nano --epochs 5 --batch-size 4
|
||||
python train_rfdetr.py \
|
||||
--dataset-dir dataset_coco \
|
||||
--output-dir runs/rfdetr_medium \
|
||||
--model medium \
|
||||
--epochs 50 \
|
||||
--batch-size 4 \
|
||||
--grad-accum-steps 4 \
|
||||
--lr 1e-4
|
||||
```
|
||||
|
||||
#### YOLOX (Balanced performance/speed)
|
||||
```bash
|
||||
python train_yolox.py \
|
||||
--dataset-dir dataset_yolo \
|
||||
--model yolox-nano \
|
||||
--epochs 50 \
|
||||
--batch-size 8
|
||||
```
|
||||
|
||||
#### YOLOv6 (Fastest, edge-optimized)
|
||||
```bash
|
||||
python train_yolov6.py \
|
||||
--dataset-dir dataset_yolo \
|
||||
--model yolov6n \
|
||||
--epochs 50 \
|
||||
--batch-size 8
|
||||
```
|
||||
|
||||
## 📁 Project Structure
|
||||
@ -88,11 +116,23 @@ python train_yolox.py --dataset-dir dataset_split --model yolox-nano --epochs 5
|
||||
```
|
||||
saw_mill_knot_detection/
|
||||
├── annotation_gui.py # Gradio web interface for annotation
|
||||
├── train_rfdetr.py # RF-DETR training script
|
||||
├── train_yolox.py # YOLOX training script
|
||||
├── split_coco_dataset.py # Dataset splitting utility
|
||||
├── reorganize_dataset.py # Dataset reorganization to YOLO format
|
||||
├── config.py # Configuration settings
|
||||
├── dataset_split/ # Training data (excluded from git)
|
||||
├── train_yolov6.py # YOLOv6 training script
|
||||
├── setup_datasets.py # Multi-format dataset setup script
|
||||
├── split_coco_dataset.py # Dataset splitting utility
|
||||
├── config.py # Configuration settings
|
||||
├── dataset_coco/ # RF-DETR dataset (COCO format)
|
||||
│ ├── train/
|
||||
│ │ ├── *.jpg # Training images
|
||||
│ │ └── _annotations.coco.json
|
||||
│ ├── valid/
|
||||
│ │ ├── *.jpg # Validation images
|
||||
│ │ └── _annotations.coco.json
|
||||
│ └── test/
|
||||
│ ├── *.jpg # Test images
|
||||
│ └── _annotations.coco.json
|
||||
├── dataset_yolo/ # YOLOX/YOLOv6/YOLOv8 dataset (YOLO format)
|
||||
│ ├── train/
|
||||
│ │ ├── images/ # Training images
|
||||
│ │ └── labels/ # YOLO format labels
|
||||
@ -104,17 +144,20 @@ saw_mill_knot_detection/
|
||||
│ │ └── labels/ # YOLO format labels
|
||||
│ └── data.yaml # YOLO dataset configuration
|
||||
├── runs/ # Training outputs (excluded from git)
|
||||
│ └── yolox_training/
|
||||
│ └── training/
|
||||
│ └── weights/
|
||||
│ ├── best.pt # Best model weights
|
||||
│ └── last.pt # Latest model weights
|
||||
├── bbox_coco_dataset.json # Original COCO annotations
|
||||
├── requirements.txt # Python dependencies
|
||||
├── .gitignore # Excludes large data files
|
||||
└── README.md # This file
|
||||
```
|
||||
|
||||
## 🤖 Framework Comparison
|
||||
|
||||
| Framework | Accuracy | Speed | Memory | Deployment | Best For |
|
||||
|-----------|----------|-------|--------|------------|----------|
|
||||
| **RF-DETR** | ⭐⭐⭐⭐⭐ | ⭐⭐ | ⭐⭐⭐ | CPU/GPU | Highest accuracy, research |
|
||||
| **YOLOX** | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐ | Edge devices | Balanced performance |
|
||||
| **YOLOv6** | ⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐ | Mobile/Edge | Fast inference, production |
|
||||
|
||||
## 🛠️ Usage Guide
|
||||
|
||||
### Annotation GUI Features
|
||||
|
||||
Reference in New Issue
Block a user