Yolov 8
Yolov 8
March 4, 2024
Downloading
https://github.com/ultralytics/assets/releases/download/v8.1.0/yolov8n.pt to
'yolov8n.pt'…
100% 6.23M/6.23M [00:00<00:00, 186MB/s]
Ultralytics YOLOv8.1.22 � Python-3.10.12 torch-2.1.0+cu121 CUDA:0 (Tesla T4,
15102MiB)
YOLOv8n summary (fused): 168 layers, 3151904 parameters, 0 gradients, 8.7 GFLOPs
1
[11]: # Validate YOLOv8n on COCO8 val
!yolo val model=yolov8n.pt data=coco8.yaml
Downloading https://ultralytics.com/assets/Arial.ttf to
'/root/.config/Ultralytics/Arial.ttf'…
100% 755k/755k [00:00<00:00, 46.5MB/s]
val: Scanning /content/datasets/coco8/labels/val… 4 images, 0
backgrounds, 0 corrupt: 100% 4/4 [00:00<00:00, 266.01it/s]
val: New cache created: /content/datasets/coco8/labels/val.cache
Class Images Instances Box(P R mAP50
mAP50-95): 100% 1/1 [00:01<00:00, 1.65s/it]
all 4 17 0.621 0.833 0.888
0.63
person 4 10 0.721 0.5 0.519
0.269
dog 4 1 0.37 1 0.995
0.597
horse 4 2 0.751 1 0.995
0.631
elephant 4 2 0.505 0.5 0.828
0.394
umbrella 4 1 0.564 1 0.995
0.995
potted plant 4 1 0.814 1 0.995
0.895
Speed: 0.3ms preprocess, 34.7ms inference, 0.0ms loss, 114.5ms postprocess per
image
Results saved to runs/detect/val
� Learn more at https://docs.ultralytics.com/modes/val
TRAIN
[12]: #@title Select YOLOv8 � logger {run: 'auto'}
logger = 'Comet' #@param ['Comet', 'TensorBoard']
2
if logger == 'Comet':
%pip install -q comet_ml
import comet_ml; comet_ml.init()
elif logger == 'TensorBoard':
%load_ext tensorboard
%tensorboard --logdir .
���������������������������������������� 611.7/611.7
kB 9.9 MB/s eta 0:00:00
���������������������������������������� 3.3/3.3 MB
28.9 MB/s eta 0:00:00
���������������������������������������� 54.5/54.5 kB
8.4 MB/s eta 0:00:00
���������������������������������������� 258.5/258.5
kB 34.4 MB/s eta 0:00:00
���������������������������������������� 137.9/137.9
kB 17.8 MB/s eta 0:00:00
���������������������������������������� 54.3/54.3 kB
7.8 MB/s eta 0:00:00
���������������������������������������� 514.7/514.7
kB 44.8 MB/s eta 0:00:00
Please paste your Comet API key from
https://www.comet.com/api/my/settings/
(api key may not show as you type)
Comet API key: ··········
COMET INFO: Valid Comet API Key saved in /root/.comet.config
(set COMET_CONFIG to change where it is saved).
3
show_conf=True, show_boxes=True, line_width=None, format=torchscript,
keras=False, optimize=False, int8=False, dynamic=False, simplify=False,
opset=None, workspace=4, nms=False, lr0=0.01, lrf=0.01, momentum=0.937,
weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1,
box=7.5, cls=0.5, dfl=1.5, pose=12.0, kobj=1.0, label_smoothing=0.0, nbs=64,
hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5,
shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0,
copy_paste=0.0, auto_augment=randaugment, erasing=0.4, crop_fraction=1.0,
cfg=None, tracker=botsort.yaml, save_dir=runs/detect/train
2024-03-04 10:32:08.374170: E
external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register
cuDNN factory: Attempting to register factory for plugin cuDNN when one has
already been registered
2024-03-04 10:32:08.374238: E
external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register
cuFFT factory: Attempting to register factory for plugin cuFFT when one has
already been registered
2024-03-04 10:32:08.375689: E
external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to
register cuBLAS factory: Attempting to register factory for plugin cuBLAS when
one has already been registered
4
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, 8.9 GFLOPs
5
Plotting labels to runs/detect/train/labels.jpg…
optimizer: 'optimizer=auto' found, ignoring 'lr0=0.01' and
'momentum=0.937' and determining best 'optimizer', 'lr0' and 'momentum'
automatically…
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)
TensorBoard: model graph visualization added �
Image sizes 640 train, 640 val
Using 2 dataloader workers
Logging results to runs/detect/train
Starting training for 3 epochs…
Validating runs/detect/train/weights/best.pt…
Ultralytics YOLOv8.1.22 � Python-3.10.12 torch-2.1.0+cu121 CUDA:0 (Tesla T4,
15102MiB)
Model summary (fused): 168 layers, 3151904 parameters, 0 gradients, 8.7 GFLOPs
Class Images Instances Box(P R mAP50
mAP50-95): 100%|����������| 1/1 [00:00<00:00, 21.15it/s]
all 4 17 0.906 0.533 0.756
0.515
6
person 4 10 0.942 0.3 0.521
0.233
dog 4 1 1 0 0.332
0.162
horse 4 2 1 0.9 0.995
0.698
elephant 4 2 1 0 0.695
0.206
umbrella 4 1 0.755 1 0.995
0.895
potted plant 4 1 0.739 1 0.995
0.895
Speed: 0.2ms preprocess, 4.1ms inference, 0.0ms loss, 1.2ms postprocess per
image
Results saved to runs/detect/train
COMET INFO: ----------------------------------------------------
-----------------------------------
COMET INFO: Comet.ml Experiment Summary
COMET INFO: ----------------------------------------------------
-----------------------------------
COMET INFO: Data:
COMET INFO: display_summary_level : 1
COMET INFO: url : https://www.co
met.com/abdullahramzan123/general/89370907527d4b1ebece1d7afc6b1387
COMET INFO: Metrics [count] (min, max):
COMET INFO: lr/pg0 [7] : (0.0, 8.092e-07)
COMET INFO: lr/pg1 [7] : (0.0, 8.092e-07)
COMET INFO: lr/pg2 [7] : (0.0, 8.092e-07)
COMET INFO: metrics/mAP50(B) [8] : (0.72651,
0.7555229137353489)
COMET INFO: metrics/mAP50-95(B) [8] : (0.49654,
0.5150593725342014)
COMET INFO: metrics/precision(B) [8] : (0.85847,
0.9058908565192811)
COMET INFO: metrics/recall(B) [8] : (0.52577, 0.53985)
COMET INFO: model/GFLOPs : 8.858
COMET INFO: model/parameters : 3157200
COMET INFO: model/speed_PyTorch(ms) : 110.431
COMET INFO: train/box_loss [6] : (0.92498, 1.16242)
COMET INFO: train/cls_loss [6] : (2.50709, 3.15452)
COMET INFO: train/dfl_loss [6] : (1.25399, 1.51792)
COMET INFO: val/box_loss [6] : (1.54791, 1.55984)
COMET INFO: val/cls_loss [6] : (1.5348, 1.58393)
COMET INFO: val/dfl_loss [6] : (1.32367, 1.33206)
COMET INFO: Others:
COMET INFO: eval_batch_logging_interval : 1
COMET INFO: log_confusion_matrix_on_eval : False
7
COMET INFO: log_image_predictions : True
COMET INFO: max_image_predictions : 100
COMET INFO: Parameters:
COMET INFO: agnostic_nms : False
COMET INFO: amp : True
COMET INFO: augment : False
COMET INFO: auto_augment : randaugment
COMET INFO: batch : 16
COMET INFO: box : 7.5
COMET INFO: cache : False
COMET INFO: cfg : None
COMET INFO: classes : None
COMET INFO: close_mosaic : 10
COMET INFO: cls : 0.5
COMET INFO: conf : None
COMET INFO: copy_paste : 0.0
COMET INFO: cos_lr : False
COMET INFO: crop_fraction : 1.0
COMET INFO: data :
/usr/local/lib/python3.10/dist-packages/ultralytics/cfg/datasets/coco8.yaml
COMET INFO: degrees : 0.0
COMET INFO: deterministic : True
COMET INFO: device : None
COMET INFO: dfl : 1.5
COMET INFO: dnn : False
COMET INFO: dropout : 0.0
COMET INFO: dynamic : False
COMET INFO: embed : None
COMET INFO: epochs : 3
COMET INFO: erasing : 0.4
COMET INFO: exist_ok : False
COMET INFO: fliplr : 0.5
COMET INFO: flipud : 0.0
COMET INFO: format : torchscript
COMET INFO: fraction : 1.0
COMET INFO: freeze : None
COMET INFO: half : False
COMET INFO: hsv_h : 0.015
COMET INFO: hsv_s : 0.7
COMET INFO: hsv_v : 0.4
COMET INFO: imgsz : 640
COMET INFO: int8 : False
COMET INFO: iou : 0.7
COMET INFO: keras : False
COMET INFO: kobj : 1.0
COMET INFO: label_smoothing : 0.0
COMET INFO: line_width : None
COMET INFO: lr0 : 0.01
8
COMET INFO: lrf : 0.01
COMET INFO: mask_ratio : 4
COMET INFO: max_det : 300
COMET INFO: mixup : 0.0
COMET INFO: mode : train
COMET INFO: model : yolov8n.pt
COMET INFO: momentum : 0.937
COMET INFO: mosaic : 1.0
COMET INFO: multi_scale : False
COMET INFO: name : train
COMET INFO: nbs : 64
COMET INFO: nms : False
COMET INFO: opset : None
COMET INFO: optimize : False
COMET INFO: optimizer : auto
COMET INFO: overlap_mask : True
COMET INFO: patience : 100
COMET INFO: perspective : 0.0
COMET INFO: plots : True
COMET INFO: pose : 12.0
COMET INFO: pretrained : True
COMET INFO: profile : False
COMET INFO: project : None
COMET INFO: rect : False
COMET INFO: resume : False
COMET INFO: retina_masks : False
COMET INFO: save : True
COMET INFO: save_conf : False
COMET INFO: save_crop : False
COMET INFO: save_dir : runs/detect/train
COMET INFO: save_frames : False
COMET INFO: save_hybrid : False
COMET INFO: save_json : False
COMET INFO: save_period : -1
COMET INFO: save_txt : False
COMET INFO: scale : 0.5
COMET INFO: seed : 0
COMET INFO: shear : 0.0
COMET INFO: show : False
COMET INFO: show_boxes : True
COMET INFO: show_conf : True
COMET INFO: show_labels : True
COMET INFO: simplify : False
COMET INFO: single_cls : False
COMET INFO: source : None
COMET INFO: split : val
COMET INFO: stream_buffer : False
COMET INFO: task : detect
9
COMET INFO: time : None
COMET INFO: tracker : botsort.yaml
COMET INFO: translate : 0.1
COMET INFO: val : True
COMET INFO: verbose : True
COMET INFO: vid_stride : 1
COMET INFO: visualize : False
COMET INFO: warmup_bias_lr : 0.1
COMET INFO: warmup_epochs : 3.0
COMET INFO: warmup_momentum : 0.8
COMET INFO: weight_decay : 0.0005
COMET INFO: workers : 8
COMET INFO: workspace : 4
COMET INFO: Uploads:
COMET INFO: confusion-matrix : 1
COMET INFO: environment details : 1
COMET INFO: filename : 1
COMET INFO: images : 7
COMET INFO: installed packages : 1
COMET INFO: model-element : 1 (6.24 MB)
COMET INFO: os packages : 1
COMET INFO: source_code : 2 (13.64 KB)
COMET INFO:
COMET WARNING: To get all data logged automatically, import
comet_ml before the following modules: torch.
� Learn more at https://docs.ultralytics.com/modes/train
EXPORT
[14]: !yolo export model=yolov8n.pt format=torchscript
10
Visualize: https://netron.app
� Learn more at https://docs.ultralytics.com/modes/export
PYTHON USAGE
[3]: !pip install matplotlib-venn
Collecting ultralytics
Downloading ultralytics-8.1.22-py3-none-any.whl (716 kB)
11
���������������������������������������� 717.0/717.0
kB 4.3 MB/s eta 0:00:00
Requirement already satisfied: matplotlib>=3.3.0 in
/usr/local/lib/python3.10/dist-packages (from ultralytics) (3.7.1)
Requirement already satisfied: opencv-python>=4.6.0 in
/usr/local/lib/python3.10/dist-packages (from ultralytics) (4.8.0.76)
Requirement already satisfied: pillow>=7.1.2 in /usr/local/lib/python3.10/dist-
packages (from ultralytics) (9.4.0)
Requirement already satisfied: pyyaml>=5.3.1 in /usr/local/lib/python3.10/dist-
packages (from ultralytics) (6.0.1)
Requirement already satisfied: requests>=2.23.0 in
/usr/local/lib/python3.10/dist-packages (from ultralytics) (2.31.0)
Requirement already satisfied: scipy>=1.4.1 in /usr/local/lib/python3.10/dist-
packages (from ultralytics) (1.11.4)
Requirement already satisfied: torch>=1.8.0 in /usr/local/lib/python3.10/dist-
packages (from ultralytics) (2.1.0+cu121)
Requirement already satisfied: torchvision>=0.9.0 in
/usr/local/lib/python3.10/dist-packages (from ultralytics) (0.16.0+cu121)
Requirement already satisfied: tqdm>=4.64.0 in /usr/local/lib/python3.10/dist-
packages (from ultralytics) (4.66.2)
Requirement already satisfied: psutil in /usr/local/lib/python3.10/dist-packages
(from ultralytics) (5.9.5)
Requirement already satisfied: py-cpuinfo in /usr/local/lib/python3.10/dist-
packages (from ultralytics) (9.0.0)
Collecting thop>=0.1.1 (from ultralytics)
Downloading thop-0.1.1.post2209072238-py3-none-any.whl (15 kB)
Requirement already satisfied: pandas>=1.1.4 in /usr/local/lib/python3.10/dist-
packages (from ultralytics) (1.5.3)
Requirement already satisfied: seaborn>=0.11.0 in
/usr/local/lib/python3.10/dist-packages (from ultralytics) (0.13.1)
Requirement already satisfied: contourpy>=1.0.1 in
/usr/local/lib/python3.10/dist-packages (from matplotlib>=3.3.0->ultralytics)
(1.2.0)
Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.10/dist-
packages (from matplotlib>=3.3.0->ultralytics) (0.12.1)
Requirement already satisfied: fonttools>=4.22.0 in
/usr/local/lib/python3.10/dist-packages (from matplotlib>=3.3.0->ultralytics)
(4.49.0)
Requirement already satisfied: kiwisolver>=1.0.1 in
/usr/local/lib/python3.10/dist-packages (from matplotlib>=3.3.0->ultralytics)
(1.4.5)
Requirement already satisfied: numpy>=1.20 in /usr/local/lib/python3.10/dist-
packages (from matplotlib>=3.3.0->ultralytics) (1.25.2)
Requirement already satisfied: packaging>=20.0 in
/usr/local/lib/python3.10/dist-packages (from matplotlib>=3.3.0->ultralytics)
(23.2)
Requirement already satisfied: pyparsing>=2.3.1 in
12
/usr/local/lib/python3.10/dist-packages (from matplotlib>=3.3.0->ultralytics)
(3.1.1)
Requirement already satisfied: python-dateutil>=2.7 in
/usr/local/lib/python3.10/dist-packages (from matplotlib>=3.3.0->ultralytics)
(2.8.2)
Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-
packages (from pandas>=1.1.4->ultralytics) (2023.4)
Requirement already satisfied: charset-normalizer<4,>=2 in
/usr/local/lib/python3.10/dist-packages (from requests>=2.23.0->ultralytics)
(3.3.2)
Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-
packages (from requests>=2.23.0->ultralytics) (3.6)
Requirement already satisfied: urllib3<3,>=1.21.1 in
/usr/local/lib/python3.10/dist-packages (from requests>=2.23.0->ultralytics)
(2.0.7)
Requirement already satisfied: certifi>=2017.4.17 in
/usr/local/lib/python3.10/dist-packages (from requests>=2.23.0->ultralytics)
(2024.2.2)
Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-
packages (from torch>=1.8.0->ultralytics) (3.13.1)
Requirement already satisfied: typing-extensions in
/usr/local/lib/python3.10/dist-packages (from torch>=1.8.0->ultralytics)
(4.10.0)
Requirement already satisfied: sympy in /usr/local/lib/python3.10/dist-packages
(from torch>=1.8.0->ultralytics) (1.12)
Requirement already satisfied: networkx in /usr/local/lib/python3.10/dist-
packages (from torch>=1.8.0->ultralytics) (3.2.1)
Requirement already satisfied: jinja2 in /usr/local/lib/python3.10/dist-packages
(from torch>=1.8.0->ultralytics) (3.1.3)
Requirement already satisfied: fsspec in /usr/local/lib/python3.10/dist-packages
(from torch>=1.8.0->ultralytics) (2023.6.0)
Requirement already satisfied: triton==2.1.0 in /usr/local/lib/python3.10/dist-
packages (from torch>=1.8.0->ultralytics) (2.1.0)
Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-
packages (from python-dateutil>=2.7->matplotlib>=3.3.0->ultralytics) (1.16.0)
Requirement already satisfied: MarkupSafe>=2.0 in
/usr/local/lib/python3.10/dist-packages (from jinja2->torch>=1.8.0->ultralytics)
(2.1.5)
Requirement already satisfied: mpmath>=0.19 in /usr/local/lib/python3.10/dist-
packages (from sympy->torch>=1.8.0->ultralytics) (1.3.0)
Installing collected packages: thop, ultralytics
Successfully installed thop-0.1.1.post2209072238 ultralytics-8.1.22
# Load a model
model = YOLO('yolov8n.yaml') # build a new model from scratch
13
model = YOLO('yolov8n.pt') # load a pretrained model (recommended for training)
Downloading
https://github.com/ultralytics/assets/releases/download/v8.1.0/yolov8n.pt to
'yolov8n.pt'…
100%|����������| 6.23M/6.23M [00:00<00:00, 79.8MB/s]
Ultralytics YOLOv8.1.22 � Python-3.10.12 torch-2.1.0+cu121 CUDA:0 (Tesla T4,
15102MiB)
engine/trainer: task=detect, mode=train, model=yolov8n.pt,
data=coco128.yaml, epochs=3, time=None, patience=100, batch=16, imgsz=640,
save=True, save_period=-1, cache=False, device=None, workers=8, project=None,
name=train, exist_ok=False, pretrained=True, optimizer=auto, verbose=True,
seed=0, deterministic=True, single_cls=False, rect=False, cos_lr=False,
close_mosaic=10, resume=False, amp=True, fraction=1.0, profile=False,
freeze=None, multi_scale=False, overlap_mask=True, mask_ratio=4, dropout=0.0,
val=True, split=val, save_json=False, save_hybrid=False, conf=None, iou=0.7,
max_det=300, half=False, dnn=False, plots=True, source=None, vid_stride=1,
stream_buffer=False, visualize=False, augment=False, agnostic_nms=False,
classes=None, retina_masks=False, embed=None, show=False, save_frames=False,
save_txt=False, save_conf=False, save_crop=False, show_labels=True,
show_conf=True, show_boxes=True, line_width=None, format=torchscript,
keras=False, optimize=False, int8=False, dynamic=False, simplify=False,
opset=None, workspace=4, nms=False, lr0=0.01, lrf=0.01, momentum=0.937,
weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1,
box=7.5, cls=0.5, dfl=1.5, pose=12.0, kobj=1.0, label_smoothing=0.0, nbs=64,
hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5,
shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0,
copy_paste=0.0, auto_augment=randaugment, erasing=0.4, crop_fraction=1.0,
cfg=None, tracker=botsort.yaml, save_dir=runs/detect/train
14
Downloading https://ultralytics.com/assets/Arial.ttf to
'/root/.config/Ultralytics/Arial.ttf'…
100%|����������| 755k/755k [00:00<00:00, 16.7MB/s]
15
[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, 8.9 GFLOPs
16
all 128 929 0.663 0.526 0.598
0.441
Validating runs/detect/train/weights/best.pt…
Ultralytics YOLOv8.1.22 � Python-3.10.12 torch-2.1.0+cu121 CUDA:0 (Tesla T4,
15102MiB)
Model summary (fused): 168 layers, 3151904 parameters, 0 gradients, 8.7 GFLOPs
Class Images Instances Box(P R mAP50
mAP50-95): 100%|����������| 4/4 [00:04<00:00, 1.13s/it]
all 128 929 0.675 0.547 0.632
0.467
person 128 254 0.796 0.669 0.767
0.548
bicycle 128 6 0.581 0.333 0.319
0.28
car 128 46 0.72 0.217 0.278
0.18
motorcycle 128 5 0.825 0.947 0.962
0.771
17
airplane 128 6 0.682 0.667 0.913
0.692
bus 128 7 0.634 0.714 0.719
0.609
train 128 3 0.532 0.667 0.806
0.752
truck 128 12 1 0.392 0.512
0.314
boat 128 6 0.302 0.167 0.394
0.236
traffic light 128 14 0.678 0.214 0.205
0.129
stop sign 128 2 1 0.94 0.995
0.703
bench 128 9 0.804 0.457 0.633
0.374
bird 128 16 0.918 0.704 0.923
0.585
cat 128 4 0.862 1 0.995
0.816
dog 128 9 0.72 0.86 0.85
0.614
horse 128 2 0.48 1 0.995
0.497
elephant 128 17 0.905 0.824 0.87
0.67
bear 128 1 0.651 1 0.995
0.895
zebra 128 4 0.862 1 0.995
0.965
giraffe 128 9 0.844 0.889 0.951
0.714
backpack 128 6 0.706 0.412 0.43
0.291
umbrella 128 18 0.758 0.524 0.65
0.439
handbag 128 19 0.462 0.0486 0.161
0.0868
tie 128 7 0.82 0.714 0.701
0.491
suitcase 128 4 0.58 1 0.845
0.551
frisbee 128 5 0.654 0.763 0.732
0.639
skis 128 1 0.419 1 0.995
0.409
snowboard 128 7 0.825 0.714 0.742
0.482
18
sports ball 128 6 0.722 0.445 0.531
0.291
kite 128 10 0.693 0.4 0.535
0.169
baseball bat 128 4 0.491 0.5 0.476
0.197
baseball glove 128 7 0.666 0.429 0.429
0.294
skateboard 128 5 0.778 0.6 0.599
0.426
tennis racket 128 7 0.549 0.286 0.436
0.297
bottle 128 18 0.493 0.333 0.352
0.213
wine glass 128 16 0.748 0.371 0.551
0.314
cup 128 36 0.655 0.278 0.411
0.284
fork 128 6 1 0.292 0.372
0.256
knife 128 16 0.648 0.575 0.607
0.357
spoon 128 22 0.599 0.182 0.34
0.182
bowl 128 28 0.68 0.607 0.597
0.496
banana 128 1 0 0 0.166
0.0437
sandwich 128 2 0.347 0.542 0.745
0.745
orange 128 4 1 0.435 0.995
0.666
broccoli 128 11 0.659 0.182 0.259
0.229
carrot 128 24 0.685 0.363 0.643
0.402
hot dog 128 2 0.569 1 0.828
0.796
pizza 128 5 0.676 1 0.995
0.882
donut 128 14 0.623 1 0.922
0.843
cake 128 4 0.823 1 0.995
0.834
chair 128 35 0.475 0.543 0.449
0.266
couch 128 6 0.539 0.333 0.666
0.526
19
potted plant 128 14 0.571 0.571 0.666
0.46
bed 128 3 0.849 0.667 0.913
0.721
dining table 128 13 0.503 0.538 0.513
0.413
toilet 128 2 1 0.852 0.995
0.946
tv 128 2 0.551 0.5 0.638
0.61
laptop 128 3 1 0 0.533
0.426
mouse 128 2 1 0 0
0
remote 128 8 0.854 0.5 0.573
0.494
cell phone 128 8 0 0 0.0419
0.0203
microwave 128 3 0.425 1 0.83
0.699
oven 128 5 0.352 0.4 0.354
0.279
sink 128 6 0.352 0.167 0.242
0.166
refrigerator 128 5 0.51 0.4 0.659
0.521
book 128 29 0.535 0.103 0.282
0.148
clock 128 9 0.82 0.778 0.898
0.748
vase 128 2 0.446 1 0.828
0.745
scissors 128 1 1 0 0.249
0.0544
teddy bear 128 21 1 0.368 0.629
0.423
toothbrush 128 5 1 0.482 0.828
0.528
Speed: 1.4ms preprocess, 3.3ms inference, 0.0ms loss, 3.4ms postprocess per
image
Results saved to runs/detect/train
Ultralytics YOLOv8.1.22 � Python-3.10.12 torch-2.1.0+cu121 CUDA:0 (Tesla T4,
15102MiB)
Model summary (fused): 168 layers, 3151904 parameters, 0 gradients, 8.7 GFLOPs
val: Scanning /content/datasets/coco128/labels/train2017.cache…
126 images, 2 backgrounds, 0 corrupt: 100%|����������| 128/128 [00:00<?, ?it/s]
Class Images Instances Box(P R mAP50
20
mAP50-95): 100%|����������| 8/8 [00:06<00:00, 1.26it/s]
all 128 929 0.666 0.547 0.625
0.463
person 128 254 0.804 0.677 0.775
0.554
bicycle 128 6 0.577 0.333 0.318
0.28
car 128 46 0.716 0.217 0.276
0.182
motorcycle 128 5 0.828 0.969 0.928
0.749
airplane 128 6 0.678 0.667 0.913
0.692
bus 128 7 0.589 0.714 0.719
0.601
train 128 3 0.531 0.667 0.806
0.752
truck 128 12 1 0.404 0.499
0.298
boat 128 6 0.349 0.167 0.359
0.239
traffic light 128 14 0.717 0.214 0.206
0.129
stop sign 128 2 1 0.943 0.995
0.703
bench 128 9 0.807 0.469 0.632
0.374
bird 128 16 0.919 0.706 0.925
0.579
cat 128 4 0.861 1 0.995
0.816
dog 128 9 0.721 0.864 0.854
0.616
horse 128 2 0.478 1 0.995
0.497
elephant 128 17 0.903 0.824 0.87
0.67
bear 128 1 0.65 1 0.995
0.895
zebra 128 4 0.86 1 0.995
0.953
giraffe 128 9 0.805 0.92 0.955
0.749
backpack 128 6 0.576 0.333 0.375
0.256
umbrella 128 18 0.759 0.527 0.652
0.438
21
handbag 128 19 0.47 0.0495 0.16
0.087
tie 128 7 0.818 0.714 0.701
0.491
suitcase 128 4 0.579 1 0.845
0.551
frisbee 128 5 0.657 0.77 0.732
0.639
skis 128 1 0.421 1 0.995
0.41
snowboard 128 7 0.823 0.714 0.743
0.481
sports ball 128 6 0.723 0.447 0.514
0.283
kite 128 10 0.817 0.452 0.56
0.172
baseball bat 128 4 0.389 0.25 0.347
0.179
baseball glove 128 7 0.644 0.429 0.429
0.33
skateboard 128 5 0.852 0.6 0.6
0.44
tennis racket 128 7 0.717 0.372 0.46
0.331
bottle 128 18 0.44 0.333 0.353
0.21
wine glass 128 16 0.749 0.375 0.526
0.316
cup 128 36 0.631 0.286 0.407
0.291
fork 128 6 0.602 0.167 0.273
0.217
knife 128 16 0.619 0.562 0.586
0.356
spoon 128 22 0.691 0.182 0.349
0.195
bowl 128 28 0.748 0.636 0.63
0.519
banana 128 1 0 0 0.142
0.0435
sandwich 128 2 0.407 0.722 0.497
0.497
orange 128 4 1 0.442 0.995
0.666
broccoli 128 11 0.67 0.182 0.275
0.22
carrot 128 24 0.647 0.375 0.65
0.406
22
hot dog 128 2 0.556 1 0.828
0.828
pizza 128 5 0.695 1 0.995
0.866
donut 128 14 0.623 1 0.922
0.839
cake 128 4 0.681 1 0.995
0.834
chair 128 35 0.444 0.514 0.421
0.255
couch 128 6 0.642 0.5 0.739
0.584
potted plant 128 14 0.564 0.571 0.667
0.462
bed 128 3 1 0.924 0.995
0.777
dining table 128 13 0.464 0.462 0.487
0.388
toilet 128 2 1 0.854 0.995
0.946
tv 128 2 0.549 0.5 0.638
0.61
laptop 128 3 1 0 0.469
0.377
mouse 128 2 1 0 0.0387
0.00387
remote 128 8 0.85 0.5 0.605
0.511
cell phone 128 8 0 0 0.0424
0.0205
microwave 128 3 0.32 0.667 0.789
0.691
oven 128 5 0.347 0.4 0.357
0.281
sink 128 6 0.38 0.167 0.24
0.164
refrigerator 128 5 0.525 0.4 0.672
0.488
book 128 29 0.451 0.103 0.282
0.15
clock 128 9 0.818 0.778 0.903
0.736
vase 128 2 0.443 1 0.828
0.745
scissors 128 1 1 0 0.199
0.0446
teddy bear 128 21 1 0.369 0.625
0.418
23
toothbrush 128 5 0.683 0.439 0.815
0.53
Speed: 0.3ms preprocess, 18.8ms inference, 0.0ms loss, 8.6ms postprocess per
image
Results saved to runs/detect/train2
24
Validate: yolo val task=detect model=runs/detect/train/weights/best.onnx
imgsz=640 data=/usr/local/lib/python3.10/dist-
packages/ultralytics/cfg/datasets/coco128.yaml
Visualize: https://netron.app
DETECTION
[9]: # Load YOLOv8n, train it on COCO128 for 3 epochs and predict an image with it
from ultralytics import YOLO
25
4 -1 2 49664 ultralytics.nn.modules.block.C2f
[64, 64, 2, True]
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, 8.9 GFLOPs
26
126 images, 2 backgrounds, 0 corrupt: 100%|����������| 128/128 [00:00<?, ?it/s]
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))
27
all 128 929 0.674 0.547 0.632
0.468
Validating runs/detect/train3/weights/best.pt…
Ultralytics YOLOv8.1.22 � Python-3.10.12 torch-2.1.0+cu121 CUDA:0 (Tesla T4,
15102MiB)
Model summary (fused): 168 layers, 3151904 parameters, 0 gradients, 8.7 GFLOPs
Class Images Instances Box(P R mAP50
mAP50-95): 100%|����������| 4/4 [00:04<00:00, 1.12s/it]
all 128 929 0.675 0.547 0.632
0.467
person 128 254 0.796 0.669 0.767
0.548
bicycle 128 6 0.581 0.333 0.319
0.28
car 128 46 0.72 0.217 0.278
0.18
motorcycle 128 5 0.825 0.947 0.962
0.771
airplane 128 6 0.682 0.667 0.913
0.692
bus 128 7 0.634 0.714 0.719
0.609
train 128 3 0.532 0.667 0.806
0.752
truck 128 12 1 0.392 0.512
0.314
boat 128 6 0.302 0.167 0.394
0.236
traffic light 128 14 0.678 0.214 0.205
0.129
stop sign 128 2 1 0.94 0.995
0.703
bench 128 9 0.804 0.457 0.633
0.374
bird 128 16 0.918 0.704 0.923
0.585
cat 128 4 0.862 1 0.995
0.816
dog 128 9 0.72 0.86 0.85
0.614
28
horse 128 2 0.48 1 0.995
0.497
elephant 128 17 0.905 0.824 0.87
0.67
bear 128 1 0.651 1 0.995
0.895
zebra 128 4 0.862 1 0.995
0.965
giraffe 128 9 0.844 0.889 0.951
0.714
backpack 128 6 0.706 0.412 0.43
0.291
umbrella 128 18 0.758 0.524 0.65
0.439
handbag 128 19 0.462 0.0486 0.161
0.0868
tie 128 7 0.82 0.714 0.701
0.491
suitcase 128 4 0.58 1 0.845
0.551
frisbee 128 5 0.654 0.763 0.732
0.639
skis 128 1 0.419 1 0.995
0.409
snowboard 128 7 0.825 0.714 0.742
0.482
sports ball 128 6 0.722 0.445 0.531
0.291
kite 128 10 0.693 0.4 0.535
0.169
baseball bat 128 4 0.491 0.5 0.476
0.197
baseball glove 128 7 0.666 0.429 0.429
0.294
skateboard 128 5 0.778 0.6 0.599
0.426
tennis racket 128 7 0.549 0.286 0.436
0.297
bottle 128 18 0.493 0.333 0.352
0.213
wine glass 128 16 0.748 0.371 0.551
0.314
cup 128 36 0.655 0.278 0.411
0.284
fork 128 6 1 0.292 0.372
0.256
knife 128 16 0.648 0.575 0.607
0.357
29
spoon 128 22 0.599 0.182 0.34
0.182
bowl 128 28 0.68 0.607 0.597
0.496
banana 128 1 0 0 0.166
0.0437
sandwich 128 2 0.347 0.542 0.745
0.745
orange 128 4 1 0.435 0.995
0.666
broccoli 128 11 0.659 0.182 0.259
0.229
carrot 128 24 0.685 0.363 0.643
0.402
hot dog 128 2 0.569 1 0.828
0.796
pizza 128 5 0.676 1 0.995
0.882
donut 128 14 0.623 1 0.922
0.843
cake 128 4 0.823 1 0.995
0.834
chair 128 35 0.475 0.543 0.449
0.266
couch 128 6 0.539 0.333 0.666
0.526
potted plant 128 14 0.571 0.571 0.666
0.46
bed 128 3 0.849 0.667 0.913
0.721
dining table 128 13 0.503 0.538 0.513
0.413
toilet 128 2 1 0.852 0.995
0.946
tv 128 2 0.551 0.5 0.638
0.61
laptop 128 3 1 0 0.533
0.426
mouse 128 2 1 0 0
0
remote 128 8 0.854 0.5 0.573
0.494
cell phone 128 8 0 0 0.0419
0.0203
microwave 128 3 0.425 1 0.83
0.699
oven 128 5 0.352 0.4 0.354
0.279
30
sink 128 6 0.352 0.167 0.242
0.166
refrigerator 128 5 0.51 0.4 0.659
0.521
book 128 29 0.535 0.103 0.282
0.148
clock 128 9 0.82 0.778 0.898
0.748
vase 128 2 0.446 1 0.828
0.745
scissors 128 1 1 0 0.249
0.0544
teddy bear 128 21 1 0.368 0.629
0.423
toothbrush 128 5 1 0.482 0.828
0.528
Speed: 0.2ms preprocess, 3.5ms inference, 0.0ms loss, 3.3ms postprocess per
image
Results saved to runs/detect/train3
31
orig_img: array([[[122, 148, 172],
[120, 146, 170],
[125, 153, 177],
…,
[157, 170, 184],
[158, 171, 185],
[158, 171, 185]],
…,
32
[ 96, 86, 92],
[102, 92, 98]]], dtype=uint8)
orig_shape: (1080, 810)
path: '/content/bus.jpg'
probs: None
save_dir: None
speed: {'preprocess': 2.409696578979492, 'inference': 22.44114875793457,
'postprocess': 3.2095909118652344}]
SEGMENTS
[10]: # Load YOLOv8n-seg, train it on COCO128-seg for 3 epochs and predict an image␣
↪with it
Downloading
https://github.com/ultralytics/assets/releases/download/v8.1.0/yolov8n-seg.pt to
'yolov8n-seg.pt'…
100%|����������| 6.73M/6.73M [00:00<00:00, 79.9MB/s]
Ultralytics YOLOv8.1.22 � Python-3.10.12 torch-2.1.0+cu121 CUDA:0 (Tesla T4,
15102MiB)
engine/trainer: task=segment, mode=train, model=yolov8n-seg.pt,
data=coco128-seg.yaml, epochs=3, time=None, patience=100, batch=16, imgsz=640,
save=True, save_period=-1, cache=False, device=None, workers=8, project=None,
name=train, exist_ok=False, pretrained=True, optimizer=auto, verbose=True,
seed=0, deterministic=True, single_cls=False, rect=False, cos_lr=False,
close_mosaic=10, resume=False, amp=True, fraction=1.0, profile=False,
freeze=None, multi_scale=False, overlap_mask=True, mask_ratio=4, dropout=0.0,
val=True, split=val, save_json=False, save_hybrid=False, conf=None, iou=0.7,
max_det=300, half=False, dnn=False, plots=True, source=None, vid_stride=1,
stream_buffer=False, visualize=False, augment=False, agnostic_nms=False,
classes=None, retina_masks=False, embed=None, show=False, save_frames=False,
save_txt=False, save_conf=False, save_crop=False, show_labels=True,
show_conf=True, show_boxes=True, line_width=None, format=torchscript,
keras=False, optimize=False, int8=False, dynamic=False, simplify=False,
opset=None, workspace=4, nms=False, lr0=0.01, lrf=0.01, momentum=0.937,
weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1,
box=7.5, cls=0.5, dfl=1.5, pose=12.0, kobj=1.0, label_smoothing=0.0, nbs=64,
hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5,
shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0,
copy_paste=0.0, auto_augment=randaugment, erasing=0.4, crop_fraction=1.0,
cfg=None, tracker=botsort.yaml, save_dir=runs/segment/train
33
Dataset 'coco128-seg.yaml' images not found �, missing path
'/content/datasets/coco128-seg/images/train2017'
Downloading https://ultralytics.com/assets/coco128-seg.zip to
'/content/datasets/coco128-seg.zip'…
100%|����������| 6.79M/6.79M [00:00<00:00, 87.6MB/s]
Unzipping /content/datasets/coco128-seg.zip to /content/datasets/coco128-seg…:
100%|����������| 263/263 [00:00<00:00, 3686.23file/s]
Dataset download success � (1.2s), saved to /content/datasets
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
34
[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 1150432 ultralytics.nn.modules.head.Segment
[80, 32, 64, [64, 128, 256]]
YOLOv8n-seg summary: 261 layers, 3409968 parameters, 3409952 gradients, 12.8
GFLOPs
val: Scanning
/content/datasets/coco128-seg/labels/train2017.cache… 126 images, 2
backgrounds, 0 corrupt: 100%|����������| 128/128 [00:00<?, ?it/s]
Plotting labels to runs/segment/train/labels.jpg…
optimizer: 'optimizer=auto' found, ignoring 'lr0=0.01' and
'momentum=0.937' and determining best 'optimizer', 'lr0' and 'momentum'
automatically…
optimizer: AdamW(lr=0.000119, momentum=0.9) with parameter groups
66 weight(decay=0.0), 77 weight(decay=0.0005), 76 bias(decay=0.0)
TensorBoard: model graph visualization added �
Image sizes 640 train, 640 val
Using 2 dataloader workers
Logging results to runs/segment/train
Starting training for 3 epochs…
35
Epoch GPU_mem box_loss seg_loss cls_loss dfl_loss Instances
Size
1/3 3.77G 1.093 2.596 1.577 1.176 236
640: 100%|����������| 8/8 [00:09<00:00, 1.18s/it]
Class Images Instances Box(P R mAP50
mAP50-95) Mask(P R mAP50 mAP50-95): 100%|����������| 4/4
[00:02<00:00, 1.82it/s]
all 128 929 0.688 0.467 0.573
0.414 0.52 0.528 0.536 0.349
Validating runs/segment/train/weights/best.pt…
Ultralytics YOLOv8.1.22 � Python-3.10.12 torch-2.1.0+cu121 CUDA:0 (Tesla T4,
15102MiB)
YOLOv8n-seg summary (fused): 195 layers, 3404320 parameters, 0 gradients, 12.6
GFLOPs
36
Class Images Instances Box(P R mAP50
mAP50-95) Mask(P R mAP50 mAP50-95): 100%|����������| 4/4
[00:06<00:00, 1.72s/it]
all 128 929 0.563 0.59 0.597
0.433 0.573 0.54 0.555 0.368
person 128 254 0.727 0.74 0.779
0.552 0.726 0.689 0.735 0.404
bicycle 128 6 0.518 0.167 0.44
0.28 1 0.318 0.496 0.274
car 128 46 0.491 0.239 0.241
0.147 0.522 0.214 0.228 0.104
motorcycle 128 5 0.707 1 0.962
0.748 0.757 1 0.962 0.514
airplane 128 6 0.656 0.959 0.893
0.688 0.534 0.767 0.706 0.534
bus 128 7 0.561 0.714 0.72
0.572 0.569 0.714 0.72 0.554
train 128 3 0.594 0.981 0.863
0.602 0.585 0.95 0.863 0.594
truck 128 12 0.909 0.333 0.5
0.302 0.991 0.333 0.472 0.266
boat 128 6 0.494 0.5 0.522
0.283 0.4 0.333 0.376 0.152
traffic light 128 14 0.63 0.214 0.24
0.15 0.435 0.143 0.17 0.149
stop sign 128 2 1 0.912 0.995
0.747 1 0.894 0.995 0.846
bench 128 9 0.625 0.374 0.46
0.193 0.398 0.221 0.211 0.0967
bird 128 16 0.757 0.875 0.931
0.665 0.815 0.825 0.931 0.488
cat 128 4 0.697 1 0.995
0.699 0.708 1 0.995 0.741
dog 128 9 0.645 0.81 0.87
0.679 0.637 0.778 0.826 0.55
horse 128 2 0.559 1 0.995
0.398 0.291 0.5 0.249 0.0748
elephant 128 17 0.885 0.824 0.875
0.688 0.891 0.824 0.869 0.562
bear 128 1 0.603 1 0.995
0.995 0.621 1 0.995 0.995
zebra 128 4 0.827 1 0.995
0.971 0.835 1 0.995 0.853
giraffe 128 9 0.717 0.889 0.939
0.69 0.563 0.667 0.766 0.451
backpack 128 6 0.449 0.5 0.476
0.302 0.461 0.436 0.421 0.277
37
umbrella 128 18 0.575 0.722 0.754
0.473 0.543 0.556 0.513 0.228
handbag 128 19 0.749 0.158 0.239
0.175 0.954 0.158 0.26 0.151
tie 128 7 0.706 0.571 0.627
0.46 0.727 0.571 0.627 0.402
suitcase 128 4 0.392 1 0.912
0.704 0.442 1 0.912 0.629
frisbee 128 5 0.509 0.625 0.613
0.544 0.51 0.6 0.633 0.442
skis 128 1 0.45 1 0.995
0.522 0.486 1 0.995 0.0995
snowboard 128 7 0.43 0.714 0.734
0.559 0.353 0.571 0.402 0.196
sports ball 128 6 0.718 0.435 0.417
0.245 0.417 0.25 0.262 0.204
kite 128 10 0.563 0.3 0.448
0.215 0.598 0.3 0.382 0.175
baseball bat 128 4 0 0 0.117
0.0523 0.401 0.25 0.415 0.212
baseball glove 128 7 0.573 0.429 0.429
0.245 0.622 0.429 0.446 0.3
skateboard 128 5 0.617 0.4 0.418
0.287 0.635 0.361 0.424 0.247
tennis racket 128 7 0.476 0.429 0.427
0.268 0.611 0.429 0.462 0.278
bottle 128 18 0.355 0.333 0.392
0.198 0.401 0.278 0.368 0.217
wine glass 128 16 0.637 0.688 0.728
0.363 0.482 0.438 0.458 0.253
cup 128 36 0.54 0.326 0.398
0.301 0.564 0.306 0.383 0.271
fork 128 6 0.279 0.167 0.192
0.18 0.323 0.167 0.192 0.103
knife 128 16 0.609 0.488 0.588
0.422 0.636 0.438 0.484 0.362
spoon 128 22 0.769 0.273 0.465
0.304 0.882 0.273 0.431 0.202
bowl 128 28 0.705 0.679 0.692
0.549 0.716 0.643 0.637 0.354
banana 128 1 0.14 1 0.142
0.114 0.0616 0.431 0.142 0.0853
sandwich 128 2 0.351 1 0.448
0.428 0.388 1 0.448 0.354
orange 128 4 1 0 0.557
0.358 1 0 0.557 0.346
broccoli 128 11 0.406 0.182 0.278
0.235 0.423 0.182 0.295 0.242
38
carrot 128 24 0.459 0.389 0.466
0.32 0.485 0.333 0.476 0.285
hot dog 128 2 0.464 1 0.828
0.828 0.491 1 0.828 0.762
pizza 128 5 0.464 1 0.88
0.74 0.475 1 0.853 0.732
donut 128 14 0.619 1 0.945
0.865 0.624 1 0.945 0.78
cake 128 4 0.548 1 0.945
0.833 0.57 1 0.945 0.791
chair 128 35 0.299 0.514 0.448
0.216 0.336 0.514 0.426 0.197
couch 128 6 0.601 0.758 0.681
0.543 0.438 0.523 0.567 0.278
potted plant 128 14 0.606 0.5 0.582
0.404 0.726 0.568 0.622 0.294
bed 128 3 1 0.682 0.995
0.38 1 0.426 0.995 0.499
dining table 128 13 0.408 0.538 0.457
0.361 0.128 0.136 0.128 0.0794
toilet 128 2 0.364 0.5 0.511
0.509 0.388 0.5 0.511 0.506
tv 128 2 0.34 1 0.995
0.846 0.377 1 0.995 0.896
laptop 128 3 0.711 0.333 0.436
0.411 0.771 0.333 0.417 0.23
mouse 128 2 0 0 0.0401
0.00802 0 0 0 0
remote 128 8 0.815 0.5 0.615
0.479 0.826 0.5 0.629 0.457
cell phone 128 8 0.378 0.25 0.219
0.119 0.397 0.25 0.212 0.158
microwave 128 3 0.553 1 0.83
0.728 0.639 1 0.83 0.715
oven 128 5 0.296 0.4 0.34
0.269 0.48 0.6 0.61 0.421
sink 128 6 0.272 0.167 0.156
0.121 0.288 0.167 0.159 0.115
refrigerator 128 5 0.462 0.8 0.737
0.507 0.494 0.8 0.737 0.509
book 128 29 0.341 0.214 0.325
0.152 0.294 0.138 0.229 0.0881
clock 128 9 0.73 0.778 0.802
0.652 0.794 0.778 0.802 0.664
vase 128 2 0.257 1 0.448
0.403 0.27 1 0.448 0.368
scissors 128 1 1 0 0
0 1 0 0 0
39
teddy bear 128 21 0.692 0.429 0.496
0.295 0.648 0.352 0.465 0.244
toothbrush 128 5 0.684 0.2 0.5
0.195 0.811 0.2 0.5 0.253
Speed: 0.2ms preprocess, 4.8ms inference, 0.0ms loss, 6.3ms postprocess per
image
Results saved to runs/segment/train
40
[158, 171, 185],
[159, 172, 186],
[159, 172, 186]],
…,
CLASSIFICATION
41
[11]: # Load YOLOv8n-cls, train it on mnist160 for 3 epochs and predict an image with␣
↪it
Downloading
https://github.com/ultralytics/assets/releases/download/v8.1.0/yolov8n-cls.pt to
'yolov8n-cls.pt'…
100%|����������| 5.30M/5.30M [00:00<00:00, 73.7MB/s]
Ultralytics YOLOv8.1.22 � Python-3.10.12 torch-2.1.0+cu121 CUDA:0 (Tesla T4,
15102MiB)
engine/trainer: task=classify, mode=train, model=yolov8n-cls.pt,
data=mnist160, epochs=3, time=None, patience=100, batch=16, imgsz=224,
save=True, save_period=-1, cache=False, device=None, workers=8, project=None,
name=train, exist_ok=False, pretrained=True, optimizer=auto, verbose=True,
seed=0, deterministic=True, single_cls=False, rect=False, cos_lr=False,
close_mosaic=10, resume=False, amp=True, fraction=1.0, profile=False,
freeze=None, multi_scale=False, overlap_mask=True, mask_ratio=4, dropout=0.0,
val=True, split=val, save_json=False, save_hybrid=False, conf=None, iou=0.7,
max_det=300, half=False, dnn=False, plots=True, source=None, vid_stride=1,
stream_buffer=False, visualize=False, augment=False, agnostic_nms=False,
classes=None, retina_masks=False, embed=None, show=False, save_frames=False,
save_txt=False, save_conf=False, save_crop=False, show_labels=True,
show_conf=True, show_boxes=True, line_width=None, format=torchscript,
keras=False, optimize=False, int8=False, dynamic=False, simplify=False,
opset=None, workspace=4, nms=False, lr0=0.01, lrf=0.01, momentum=0.937,
weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1,
box=7.5, cls=0.5, dfl=1.5, pose=12.0, kobj=1.0, label_smoothing=0.0, nbs=64,
hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5,
shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0,
copy_paste=0.0, auto_augment=randaugment, erasing=0.4, crop_fraction=1.0,
cfg=None, tracker=botsort.yaml, save_dir=runs/classify/train
42
train: /content/datasets/mnist160/train… found 80 images in 10
classes �
val: None…
test: /content/datasets/mnist160/test… found 80 images in 10
classes �
Overriding model.yaml nc=1000 with nc=10
43
optimizer: 'optimizer=auto' found, ignoring 'lr0=0.01' and
'momentum=0.937' and determining best 'optimizer', 'lr0' and 'momentum'
automatically…
optimizer: AdamW(lr=0.000714, momentum=0.9) with parameter groups
26 weight(decay=0.0), 27 weight(decay=0.0005), 27 bias(decay=0.0)
TensorBoard: model graph visualization added �
Image sizes 224 train, 224 val
Using 2 dataloader workers
Logging results to runs/classify/train
Starting training for 3 epochs…
Validating runs/classify/train/weights/best.pt…
44
Ultralytics YOLOv8.1.22 � Python-3.10.12 torch-2.1.0+cu121 CUDA:0 (Tesla T4,
15102MiB)
YOLOv8n-cls summary (fused): 73 layers, 1447690 parameters, 0 gradients, 3.3
GFLOPs
WARNING � Dataset 'split=val' not found, using 'split=test' instead.
train: /content/datasets/mnist160/train… found 80 images in 10
classes �
val: None…
test: /content/datasets/mnist160/test… found 80 images in 10
classes �
classes top1_acc top5_acc: 100%|����������| 3/3 [00:00<00:00,
18.74it/s]
all 0.138 0.575
Speed: 0.1ms preprocess, 0.8ms inference, 0.0ms loss, 0.0ms postprocess per
image
Results saved to runs/classify/train
Results saved to runs/classify/train
boxes: None
keypoints: None
masks: None
names: {0: '0', 1: '1', 2: '2', 3: '3', 4: '4', 5: '5', 6: '6', 7: '7', 8: '8',
9: '9'}
obb: None
orig_img: array([[[122, 148, 172],
[120, 146, 170],
[125, 153, 177],
…,
[157, 170, 184],
[158, 171, 185],
[158, 171, 185]],
45
[159, 172, 186]],
…,
POSE
[12]: # Load YOLOv8n-pose, train it on COCO8-pose for 3 epochs and predict an image␣
↪with it
46
model = YOLO('yolov8n-pose.pt') # load a pretrained YOLOv8n classification␣
↪model
Downloading
https://github.com/ultralytics/assets/releases/download/v8.1.0/yolov8n-pose.pt
to 'yolov8n-pose.pt'…
100%|����������| 6.51M/6.51M [00:00<00:00, 83.7MB/s]
Ultralytics YOLOv8.1.22 � Python-3.10.12 torch-2.1.0+cu121 CUDA:0 (Tesla T4,
15102MiB)
engine/trainer: task=pose, mode=train, model=yolov8n-pose.pt,
data=coco8-pose.yaml, epochs=3, time=None, patience=100, batch=16, imgsz=640,
save=True, save_period=-1, cache=False, device=None, workers=8, project=None,
name=train, exist_ok=False, pretrained=True, optimizer=auto, verbose=True,
seed=0, deterministic=True, single_cls=False, rect=False, cos_lr=False,
close_mosaic=10, resume=False, amp=True, fraction=1.0, profile=False,
freeze=None, multi_scale=False, overlap_mask=True, mask_ratio=4, dropout=0.0,
val=True, split=val, save_json=False, save_hybrid=False, conf=None, iou=0.7,
max_det=300, half=False, dnn=False, plots=True, source=None, vid_stride=1,
stream_buffer=False, visualize=False, augment=False, agnostic_nms=False,
classes=None, retina_masks=False, embed=None, show=False, save_frames=False,
save_txt=False, save_conf=False, save_crop=False, show_labels=True,
show_conf=True, show_boxes=True, line_width=None, format=torchscript,
keras=False, optimize=False, int8=False, dynamic=False, simplify=False,
opset=None, workspace=4, nms=False, lr0=0.01, lrf=0.01, momentum=0.937,
weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1,
box=7.5, cls=0.5, dfl=1.5, pose=12.0, kobj=1.0, label_smoothing=0.0, nbs=64,
hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5,
shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0,
copy_paste=0.0, auto_augment=randaugment, erasing=0.4, crop_fraction=1.0,
cfg=None, tracker=botsort.yaml, save_dir=runs/pose/train
47
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, True]
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 1035934 ultralytics.nn.modules.head.Pose
[1, [17, 3], [64, 128, 256]]
48
YOLOv8n-pose summary: 250 layers, 3295470 parameters, 3295454 gradients, 9.3
GFLOPs
49
all 4 14 0.919 0.929 0.907
0.685 1 0.619 0.652 0.366
Validating runs/pose/train/weights/best.pt…
Ultralytics YOLOv8.1.22 � Python-3.10.12 torch-2.1.0+cu121 CUDA:0 (Tesla T4,
15102MiB)
YOLOv8n-pose summary (fused): 187 layers, 3289964 parameters, 0 gradients, 9.2
GFLOPs
Class Images Instances Box(P R mAP50
mAP50-95) Pose(P R mAP50 mAP50-95): 100%|����������| 1/1
[00:00<00:00, 15.99it/s]
all 4 14 0.919 0.929 0.907
0.687 1 0.625 0.652 0.366
Speed: 0.3ms preprocess, 7.3ms inference, 0.0ms loss, 1.2ms postprocess per
image
50
Results saved to runs/pose/train
…,
51
[[157, 157, 163],
[180, 180, 186],
[185, 186, 190],
…,
[107, 97, 103],
[102, 92, 98],
[108, 98, 104]],
[ ]:
52