This project provides a complete pipeline to convert annotation data in JSON format into the YOLO format for object detection tasks. It automatically processes training, validation, and test datasets, creates train.txt
and valid.txt
image lists, and generates a custom_dataset.yaml
configuration file for YOLO training.
2D_Bounding_Box/
├── training/
│ ├── images/
│ └── labels/ # JSON label files
├── validation/
│ ├── images/
│ └── labels/
├── test/
│ ├── images/
│ └── labels/
- Uses
glob
to collect training and validation image file paths - Saves them as
train.txt
andvalid.txt
for YOLO training
- Extracts
Label
andCoordinate
info from JSON files - Converts each annotation to YOLO format:
YOLO Format: <class_id> <x_center> <y_center> <width> <height>
- Saves converted annotations to
.txt
files
- Generates
custom_dataset.yaml
with class names and paths to image lists
nc: 9
names: ["car", "truck", "bus", "special_vehicle", "motorcycle", "bicycle", "pedestrian", "traffic_sign", "traffic_light"]
train: path_to_train.txt
val: path_to_valid.txt
- Horizontal and vertical flips are applied for data augmentation using Albumentations
- Python 3.8+
- PyTorch
- Albumentations
- TorchVision
- PyYAML
pip install torch torchvision albumentations pyyaml
Class ID | Class Name |
---|---|
0 | car |
1 | truck |
2 | bus |
3 | special vehicle |
4 | motorcycle |
5 | bicycle |
6 | pedestrian |
7 | traffic_sign |
8 | traffic_light |
File | Description |
---|---|
train.txt , valid.txt |
Lists of image file paths |
custom_dataset.yaml |
YOLO configuration file |
.txt (YOLO labels) |
Annotation files in YOLO format |
- Add bounding box visualization tool
- Add label validation utilities (e.g., invalid box checker)
- Automate training script generation for YOLOv5/YOLOv8