赞
踩
我们以最近大热的YOLOv8为例,回顾一下之前的安装过程:
%pip install ultralytics
import ultralytics
ultralytics.checks()
这里选择训练的数据集为:COCO128
COCO128是一个小型教程数据集,由COCOtrain2017中的前128个图像组成。
在YOLO中自带的coco128.yaml文件:
1)可选的用于自动下载的下载命令/URL,
2)指向培训图像目录的路径(或指向带有培训图像列表的*.txt文件的路径),
3)与验证图像相同,
4)类数,
5)类名列表:
# 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/
val: ../coco128/images/train2017/
# 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']
!yolo train model = yolov8n.pt data = coco128.yaml epochs = 10 imgsz = 640
训练过程为:
from n params module arguments
0 -1 1 464 ultralytics.nn.modules.conv.Conv [3, 16, 3, 2]
1 -1 1 4672 ultralytics.nn.modules.conv.Conv [16, 32, 3, 2]
2 -1 1 7360 ultralytics.nn.modules.block.C2f [32, 32, 1, True]
3 -1 1 18560 ultralytics.nn.modules.conv.Conv [32, 64, 3, 2]
4 -1 2 49664 ultralytics.nn.modules.block.C2f [64, 64, 2, Tr
ue]
5 -1 1 73984 ultralytics.nn.modules.conv.Conv [64, 128, 3, 2]
6 -1 2 197632 ultralytics.nn.modules.block.C2f [128, 128, 2, True]
7 -1 1 295424 ultralytics.nn.modules.conv.Conv [128, 256, 3, 2]
8 -1 1 460288 ultralytics.nn.modules.block.C2f [256, 256, 1, True]
9 -1 1 164608 ultralytics.nn.modules.block.SPPF [256, 256, 5]
10 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest']
11 [-1, 6] 1 0 ultralytics.nn.modules.conv.Concat [1]
12 -1 1 148224 ultralytics.nn.modules.block.C2f [384, 128, 1]
13 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest']
14 [-1, 4] 1 0 ultralytics.nn.modules.conv.Concat [1]
15 -1 1 37248 ultralytics.nn.modules.block.C2f [192, 64, 1]
16 -1 1 36992 ultralytics.nn.modules.conv.Conv [64, 64, 3, 2]
17 [-1, 12] 1 0 ultralytics.nn.modules.conv.Concat [1]
18 -1 1 123648 ultralytics.nn.modules.block.C2f [192, 128, 1]
19 -1 1 147712 ultralytics.nn.modules.conv.Conv [128, 128, 3, 2]
20 [-1, 9] 1 0 ultralytics.nn.modules.conv.Concat [1]
21 -1 1 493056 ultralytics.nn.modules.block.C2f [384, 256, 1]
22 [15, 18, 21] 1 897664 ultralytics.nn.modules.head.Detect [80, [64, 128, 256]]
Model summary: 225 layers, 3157200 parameters, 3157184 gradients
Transferred 355/355 items from pretrained weights
TensorBoard: Start with 'tensorboard --logdir runs/detect/train', view at http://localhost:6006/
AMP: running Automatic Mixed Precision (AMP) checks with YOLOv8n...
AMP: checks passed ✅
train: Scanning /kaggle/working/datasets/coco128/labels/train2017.cache... 126 i
albumentations: Blur(p=0.01, blur_limit=(3, 7)), MedianBlur(p=0.01, blur_limit=(3, 7)), ToGray(p=0.01), CLAHE(p=0.01, clip_limit=(1, 4.0), tile_grid_size=(8, 8))
val: Scanning /kaggle/working/datasets/coco128/labels/train2017.cache... 126 ima
Plotting labels to runs/detect/train/labels.jpg...
optimizer: AdamW(lr=0.000119, momentum=0.9) with parameter groups 57 weight(decay=0.0), 64 weight(decay=0.0005), 63 bias(decay=0.0)
Image sizes 640 train, 640 val
Using 2 dataloader workers
Logging results to runs/detect/train
Starting training for 10 epochs...
Closing dataloader mosaic
albumentations: Blur(p=0.01, blur_limit=(3, 7)), MedianBlur(p=0.01, blur_limit=(3, 7)), ToGray(p=0.01), CLAHE(p=0.01, clip_limit=(1, 4.0), tile_grid_size=(8, 8))
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
1/10 2.61G 1.153 1.398 1.192 81 640: 1
Class Images Instances Box(P R mAP50 m
all 128 929 0.688 0.506 0.61 0.446
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
2/10 2.56G 1.142 1.345 1.202 121 640: 1
Class Images Instances Box(P R mAP50 m
all 128 929 0.678 0.525 0.63 0.456
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
3/10 2.57G 1.147 1.25 1.175 108 640: 1
Class Images Instances Box(P R mAP50 m
all 128 929 0.656 0.548 0.64 0.466
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
4/10 2.57G 1.149 1.287 1.177 116 640: 1
Class Images Instances Box(P R mAP50 m
all 128 929 0.684 0.568 0.654 0.482
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
5/10 2.57G 1.169 1.233 1.207 68 640: 1
Class Images Instances Box(P R mAP50 m
all 128 929 0.664 0.586 0.668 0.491
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
6/10 2.57G 1.139 1.231 1.177 95 640: 1
Class Images Instances Box(P R mAP50 m
all 128 929 0.66 0.613 0.677 0.5
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
7/10 2.57G 1.134 1.211 1.181 115 640: 1
Class Images Instances Box(P R mAP50 m
all 128 929 0.649 0.631 0.683 0.504
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
8/10 2.57G 1.114 1.194 1.178 71 640: 1
Class Images Instances Box(P R mAP50 m
all 128 929 0.664 0.634 0.69 0.513
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
9/10 2.57G 1.117 1.127 1.148 142 640: 1
Class Images Instances Box(P R mAP50 m
all 128 929 0.624 0.671 0.697 0.52
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
10/10 2.57G 1.085 1.133 1.172 104 640: 1
Class Images Instances Box(P R mAP50 m
all 128 929 0.631 0.676 0.704 0.522
10 epochs completed in 0.018 hours.
Optimizer stripped from runs/detect/train/weights/last.pt, 6.5MB
Optimizer stripped from runs/detect/train/weights/best.pt, 6.5MB
Validating runs/detect/train/weights/best.pt...
Ultralytics YOLOv8.0.128 声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/149642
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。