目标检测 YOLOv5使用的数据集格式

flyfish

通过训练命令查看数据集格式

python train.py --data coco128.yaml --cfg yolov5s.yaml --weights '' --batch-size 64 

执行过程

WARNING: Dataset not found, nonexistent paths: ['/pytorch1.7/coco128/images/train2017']
Downloading https://github.com/ultralytics/yolov5/releases/download/v1.0/coco128.zip ...
100%|█████████████████████████████████████████████████████| 21.1M/21.1M [00:06<00:00, 3.32MB/s]
Scaled weight_decay = 0.0005
Optimizer groups: 54 .bias, 54 conv.weight, 51 other
Dataset autodownload success

train: Scanning '../coco128/labels/train2017' images and labels... 128 found, 0 missing, 2 empty, 0 corrupted: 100%|| 128/128 [00:00<00:00, 2351.24it/s]
train: New cache created: ../coco128/labels/train2017.cache
val: Scanning '../coco128/labels/train2017.cache' images and labels... 128 found, 0 missing, 2 empty, 0 corrupted: 100%|| 128/128 [00:00<00:00, 1338830.
Plotting labels... 

目录查看
coco128与yolov5同一级目录

coco128
├── images
│   └── train2017
├── labels
│   ├── train2017
│   └── train2017.cache
├── LICENSE
└── README.txt

images中的train2017存储是图像,例如000000000009.jpg
labels中的train2017存储是标注文本,例如000000000009.txt

标注内容类似

45 0.479492 0.688771 0.955609 0.5955
45 0.736516 0.247188 0.498875 0.476417
50 0.637063 0.732938 0.494125 0.510583
45 0.339438 0.418896 0.678875 0.7815
49 0.646836 0.132552 0.118047 0.096937
49 0.773148 0.129802 0.090734 0.097229
49 0.668297 0.226906 0.131281 0.146896
49 0.642859 0.079219 0.148063 0.148062

如果是我们自己的数据集也是按照这种格式,少写代码。

读取数据是按照coco128.yaml内容

# download command/URL (optional)
download: https://github.com/ultralytics/yolov5/releases/download/v1.0/coco128.zip

# train and val data as 1) directory: path/images/, 2) file: path/images.txt, or 3) list: [path1/images/, path2/images/]
train: ../coco128/images/train2017/  # 128 images
val: ../coco128/images/train2017/  # 128 images

# number of classes
nc: 80

# class names
names: [ 'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light',
         'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow',
         'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee',
         'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard',
         'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple',
         'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch',
         'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone',
         'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear',
         'hair drier', 'toothbrush' ]
Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐