added tk gui
This commit is contained in:
89
README.md
89
README.md
@ -1,30 +1,23 @@
|
||||
# Saw Mill Knot Detection (YOLOX/YOLO)
|
||||
# Saw Mill Knot Detection
|
||||
|
||||
This repository contains a complete wood defect detection system using YOLOX/YOLO models, trained to detect 10 different types of wood surface defects. The system includes a web-based annotation GUI, automated training pipeline, and is optimized for deployment on OAK-D cameras.
|
||||
This repository contains a complete wood defect detection system with a web-based annotation GUI and separate training/deployment scripts. Supports multiple model frameworks (RF-DETR, RT-DETR, YOLOv6, YOLOX) and is optimized for deployment on OAK-D cameras.
|
||||
|
||||
## 🎯 Project Overview
|
||||
|
||||
- **Model**: YOLOX-nano (Ultralytics YOLO framework)
|
||||
- **Dataset**: 20,276 wood surface defect images with 10 defect categories
|
||||
- **Training**: 5 epochs, mAP50: 0.612, mAP50-95: 0.357
|
||||
- **Deployment Target**: OAK-D 4 Pro camera
|
||||
- **Framework**: Ultralytics 8.3.240
|
||||
- **Models**: RF-DETR, RT-DETR, YOLOv6, YOLOX (all MIT/Apache 2.0 licensed)
|
||||
- **Dataset**: 20,276 wood surface defect images
|
||||
- **Annotation GUI**: Gradio-based web interface for manual annotation
|
||||
- **Training Scripts**: Separate Python scripts for model training
|
||||
- **Deployment**: OAK-D camera optimization with OpenVINO conversion
|
||||
- **License**: All models free for commercial use
|
||||
|
||||
## 📊 Dataset Information
|
||||
|
||||
**Source**: [Kaggle Wood Surface Defects Dataset](https://www.kaggle.com/datasets/kirs0816/wood-surface-defects)
|
||||
|
||||
**Classes** (10 total):
|
||||
- Live knot
|
||||
- Dead knot
|
||||
- Knot with crack
|
||||
- Crack
|
||||
- Resin
|
||||
- Marrow
|
||||
- Quartzity
|
||||
- Knot missing
|
||||
- Blue stain
|
||||
- Overgrown
|
||||
- Live knot, Dead knot, Knot with crack, Crack, Resin
|
||||
- Marrow, Quartzity, Knot missing, Blue stain, Overgrown
|
||||
|
||||
**Dataset Split**:
|
||||
- Train: 16,220 images
|
||||
@ -65,7 +58,8 @@ source .venv/bin/activate # or conda activate your_env
|
||||
python annotation_gui.py
|
||||
```
|
||||
|
||||
# Install dependencies
|
||||
Install dependencies:
|
||||
```bash
|
||||
pip install -U pip
|
||||
pip install ultralytics gradio rfdetr
|
||||
```
|
||||
@ -88,44 +82,45 @@ python setup_datasets.py # Creates dataset_coco/ and updates configs
|
||||
python annotation_gui.py
|
||||
```
|
||||
|
||||
Tkinter version (new):
|
||||
|
||||
```bash
|
||||
python tk_annotation_gui.py
|
||||
# or
|
||||
./run_tk_gui.sh
|
||||
```
|
||||
|
||||
Open http://localhost:7860 in your browser to access the web-based annotation interface with:
|
||||
- Image navigation with index display
|
||||
- Auto-labeling with trained YOLOX model
|
||||
- Manual annotation tools
|
||||
- Auto-labeling with trained models
|
||||
- Manual annotation tools with delete buttons
|
||||
- Real-time result visualization
|
||||
- Export to COCO format
|
||||
|
||||
### 4. Train Models
|
||||
|
||||
Choose from three different frameworks:
|
||||
Use the dedicated training script for all frameworks:
|
||||
|
||||
#### RF-DETR (Highest accuracy, slower training)
|
||||
```bash
|
||||
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
|
||||
# Prepare dataset from annotations (optional)
|
||||
python train_model.py --prepare-dataset --images-dir IMAGE --annotations annotations.json --dataset dataset_prepared
|
||||
|
||||
# Train models with different frameworks
|
||||
python train_model.py --framework rf-detr --dataset dataset_prepared --output runs/rfdetr_training --model-size medium --epochs 50
|
||||
python train_model.py --framework rtdetr --dataset dataset_prepared --output runs/rtdetr_training --model-size small --epochs 30
|
||||
python train_model.py --framework yolox --dataset dataset_prepared --output runs/yolox_training --model-size nano --epochs 50
|
||||
python train_model.py --framework yolov6 --dataset dataset_prepared --output runs/yolov6_training --model-size nano --epochs 50
|
||||
|
||||
# See TRAINING_README.md for detailed training options
|
||||
```
|
||||
|
||||
#### YOLOX (Balanced performance/speed)
|
||||
```bash
|
||||
python train_yolox.py \
|
||||
--dataset-dir dataset_yolo \
|
||||
--model yolox-nano \
|
||||
--epochs 50 \
|
||||
--batch-size 8
|
||||
```
|
||||
### 5. Convert for OAK-D Deployment
|
||||
|
||||
#### YOLOv6 (Fastest, edge-optimized)
|
||||
```bash
|
||||
python train_yolov6.py \
|
||||
--dataset-dir dataset_yolo \
|
||||
--model yolov6n \
|
||||
--epochs 50 \
|
||||
--batch-size 8
|
||||
# Convert trained model for edge deployment
|
||||
python convert_for_deployment.py --model runs/training/weights/best.pt --output oak_d_deployment --img-size 640
|
||||
|
||||
# See TRAINING_README.md for deployment instructions
|
||||
```
|
||||
|
||||
## 📁 Project Structure
|
||||
@ -133,9 +128,9 @@ python train_yolov6.py \
|
||||
```
|
||||
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
|
||||
├── train_yolov6.py # YOLOv6 training script
|
||||
├── train_model.py # Unified training script for all frameworks
|
||||
├── convert_for_deployment.py # Model conversion for OAK-D deployment
|
||||
├── TRAINING_README.md # Detailed training and deployment guide
|
||||
├── setup_datasets.py # Multi-format dataset setup script
|
||||
├── split_coco_dataset.py # Dataset splitting utility
|
||||
├── config.py # Configuration settings
|
||||
|
||||
Reference in New Issue
Block a user