📸

最新のYOLOv8 が公開されたので試してみる

2023/01/11に公開1

最新のYOLOv8がUltralyticsより公開されました。まだ論文がarxivに公開されていないらしく情報が少ないですが、とりあえず試してみることにします。
https://github.com/ultralytics/ultralytics
ドキュメントをパッと見てまず思ったのがYOLOv8がPythonのパッケージとして配布されていることですかね。https://docs.ultralytics.com によると,YOLOv8では以前のYOLOを切り替えることができるみたいです。これは拡張性とかかなり期待できそうです!
早速bus.jpgでテスト。

$ pip install ultralytics
$ yolo task=detect mode=predict model=yolov8n.pt source="https://ultralytics.com/images/bus.jpg"


認識されました。YOLOv5ではstop signの検出はされなかった記憶があるので性能アップしてるのかな?

detection

COCO val2017による事前学習済みモデルのmAPだけを比較すると検出の精度は軒並み上がってはいるようです。
https://github.com/ultralytics/yolov5

YOLOv5

YOLOv8

yaml

https://roboflow.com/ のfootball-player-detection のデータセットを使って学習と推論を確かめてみました。付属されたyamlの内容なこのようになっています。クラス数は4で、ボール、ゴールキーパー、プレイヤー、レフリーとなっています。

data.yaml
names:
- ball
- goalkeeper
- player
- referee
nc: 4
roboflow:
  license: CC BY 4.0
  project: football-players-detection-3zvbc
  url: https://universe.roboflow.com/roboflow-jvuqo/football-players-detection-3zvbc/dataset/4
  version: 4
  workspace: roboflow-jvuqo
test: ../test/images
train: football-players-detection-4/train/images
val: football-players-detection-4/valid/images

train

100エポックで学習させました。モデルは一番小さいやつです。

from ultralytics import YOLO
model = YOLO("yolov8n.pt")  
model.train(data="./football-players-detection-4/data.yaml", batch=4)  # train the model

学習のlogはこちら
yolo/engine/trainer: task=detect, mode=train, model=yolov8n.yaml, data=./football-players-detection-4/data.yaml, epochs=100, patience=50, batch=4, imgsz=640, save=True, cache=False, device=None, workers=4, project=None, name=None, exist_ok=False, pretrained=False, optimizer=SGD, verbose=False, seed=0, deterministic=True, single_cls=False, image_weights=False, rect=False, cos_lr=False, close_mosaic=10, resume=False, overlap_mask=True, mask_ratio=4, dropout=False, val=True, save_json=False, save_hybrid=False, conf=0.001, iou=0.7, max_det=300, half=True, dnn=False, plots=True, source=ultralytics/assets/, show=False, save_txt=False, save_conf=False, save_crop=False, hide_labels=False, hide_conf=False, vid_stride=1, line_thickness=3, visualize=False, augment=False, agnostic_nms=False, retina_masks=False, format=torchscript, keras=False, optimize=False, int8=False, dynamic=False, simplify=False, opset=17, workspace=4, nms=False, lr0=0.01, lrf=0.01, momentum=0.937, weight_decay=0.001, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=7.5, cls=0.5, dfl=1.5, fl_gamma=0.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, hydra={'output_subdir': None, 'run': {'dir': '.'}}, v5loader=True, save_dir=runs/detect/train13
Ultralytics YOLOv8.0.3 🚀 Python-3.10.6 torch-1.13.1+cu117 CUDA:0 (NVIDIA GeForce RTX 3060, 12288MiB)
Downloading https://ultralytics.com/assets/Arial.ttf to /root/.config/Ultralytics/Arial.ttf...
100%|█████████████████████████████████████████████████████████████████████| 755k/755k [00:01<00:00, 651kB/s]
Overriding model.yaml nc=80 with nc=4

                   from  n    params  module                                       arguments                     
  0                  -1  1       464  ultralytics.nn.modules.Conv                  [3, 16, 3, 2]                 
  1                  -1  1      4672  ultralytics.nn.modules.Conv                  [16, 32, 3, 2]                
  2                  -1  1      7360  ultralytics.nn.modules.C2f                   [32, 32, 1, True]             
  3                  -1  1     18560  ultralytics.nn.modules.Conv                  [32, 64, 3, 2]                
  4                  -1  2     49664  ultralytics.nn.modules.C2f                   [64, 64, 2, True]             
  5                  -1  1     73984  ultralytics.nn.modules.Conv                  [64, 128, 3, 2]               
  6                  -1  2    197632  ultralytics.nn.modules.C2f                   [128, 128, 2, True]           
  7                  -1  1    295424  ultralytics.nn.modules.Conv                  [128, 256, 3, 2]              
  8                  -1  1    460288  ultralytics.nn.modules.C2f                   [256, 256, 1, True]           
  9                  -1  1    164608  ultralytics.nn.modules.SPPF                  [256, 256, 5]                 
 10                  -1  1         0  torch.nn.modules.upsampling.Upsample         [None, 2, 'nearest']          
 11             [-1, 6]  1         0  ultralytics.nn.modules.Concat                [1]                           
 12                  -1  1    148224  ultralytics.nn.modules.C2f                   [384, 128, 1]                 
 13                  -1  1         0  torch.nn.modules.upsampling.Upsample         [None, 2, 'nearest']          
 14             [-1, 4]  1         0  ultralytics.nn.modules.Concat                [1]                           
 15                  -1  1     37248  ultralytics.nn.modules.C2f                   [192, 64, 1]                  
 16                  -1  1     36992  ultralytics.nn.modules.Conv                  [64, 64, 3, 2]                
 17            [-1, 12]  1         0  ultralytics.nn.modules.Concat                [1]                           
 18                  -1  1    123648  ultralytics.nn.modules.C2f                   [192, 128, 1]                 
 19                  -1  1    147712  ultralytics.nn.modules.Conv                  [128, 128, 3, 2]              
 20             [-1, 9]  1         0  ultralytics.nn.modules.Concat                [1]                           
 21                  -1  1    493056  ultralytics.nn.modules.C2f                   [384, 256, 1]                 
 22        [15, 18, 21]  1    752092  ultralytics.nn.modules.Detect                [4, [64, 128, 256]]           
Model summary: 225 layers, 3011628 parameters, 3011612 gradients, 8.2 GFLOPs

Transferred 319/355 items from pretrained weights
optimizer: SGD(lr=0.01) with parameter groups 57 weight(decay=0.0), 64 weight(decay=0.001), 63 bias
train: Scanning /work/football-players-detection-4/train/labels.cache... 204 images, 0 backgrounds, 0 corrup
val: Scanning /work/football-players-detection-4/valid/labels.cache... 38 images, 0 backgrounds, 0 corrupt: 
Image sizes 640 train, 640 val
Using 4 dataloader workers
Logging results to runs/detect/train13
Starting training for 100 epochs...

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
      1/100      1.47G      2.009      3.621     0.9438        165        640: 100%|██████████| 51/51 [00:11
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905     0.0338      0.144      0.121     0.0373

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
      2/100      1.73G      2.336      2.039     0.9439        162        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905       0.88      0.127      0.108      0.034

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
      3/100      1.73G      2.742      2.028      1.004        178        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.877      0.109      0.106     0.0309

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
      4/100      1.73G      2.605      1.859      1.019        192        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905        0.9      0.176      0.166      0.055

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
      5/100      1.73G      2.611      1.756     0.9955        205        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.893      0.144      0.143      0.047

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
      6/100      1.99G      2.384      1.643     0.9691        134        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.644      0.181      0.154     0.0492

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
      7/100      1.99G      2.376      1.568     0.9644        165        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.679      0.196      0.182     0.0577

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
      8/100      1.99G        2.3      1.529      0.953        259        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.915      0.176      0.175     0.0616

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
      9/100      1.99G       2.12      1.494     0.9399        205        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.674      0.209       0.18     0.0781

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     10/100      1.99G      2.163      1.433     0.9156        140        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.888      0.189      0.158     0.0566

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     11/100      1.99G      2.047      1.386      0.911        206        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.945      0.198      0.217     0.0912

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     12/100      1.99G      1.966      1.318     0.9019        201        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.813      0.224      0.237      0.111

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     13/100      1.99G      1.883      1.272     0.8939        120        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905       0.76      0.254      0.259      0.128

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     14/100      1.99G      1.866      1.281     0.8882         83        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.742      0.256      0.242      0.106

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     15/100      1.99G       1.85      1.255      0.897        116        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.892       0.26      0.291      0.134

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     16/100      1.99G       1.84      1.185     0.8925        171        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.885      0.265      0.303      0.155

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     17/100      1.99G      1.855      1.187     0.8838        168        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.862      0.262      0.309      0.158

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     18/100      1.99G      1.823       1.15     0.8752        193        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.837      0.263      0.307      0.156

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     19/100      1.99G      1.674      1.105     0.8691        175        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.828      0.263      0.311      0.169

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     20/100      1.99G      1.749      1.106     0.8696        107        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905       0.84      0.281      0.333      0.164

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     21/100      1.99G      1.716      1.105     0.8694        205        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.519      0.315      0.345      0.181

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     22/100      1.99G      1.702      1.087     0.8648        108        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.889       0.29      0.357      0.175

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     23/100      1.99G      1.655      1.052     0.8674        195        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.918      0.287      0.363      0.195

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     24/100      1.99G       1.67      1.074     0.8647        209        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.908       0.28      0.375      0.205

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     25/100      1.99G      1.628      1.013     0.8636        211        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.911      0.285       0.37      0.202

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     26/100      1.99G      1.618      1.004     0.8611        141        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.813       0.33      0.368      0.187

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     27/100      1.99G      1.659      1.001     0.8645        120        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.832      0.323      0.374      0.198

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     28/100      1.99G       1.59     0.9911     0.8556        176        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.802      0.345      0.397      0.213

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     29/100      1.99G      1.524     0.9619     0.8515        131        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.663       0.41      0.399       0.21

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     30/100      1.99G      1.562     0.9773     0.8536        303        640: 100%|██████████| 51/51 [00:05
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.676      0.409      0.407      0.219

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     31/100      1.99G      1.505     0.9305     0.8442        178        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.652      0.403      0.423      0.223

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     32/100      1.99G      1.568     0.9467     0.8507         78        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.681      0.421      0.417      0.229

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     33/100      1.99G      1.478     0.9109     0.8463        192        640: 100%|██████████| 51/51 [00:05
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905       0.72      0.442      0.456       0.26

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     34/100      1.99G      1.477     0.8861     0.8472        160        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.734      0.451      0.477      0.251

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     35/100      1.99G       1.46     0.8981     0.8489        239        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.734      0.444      0.508      0.288

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     36/100      1.99G      1.478     0.8897     0.8439        218        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.782      0.462      0.527      0.305

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     37/100      1.99G      1.397     0.8607     0.8461        135        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.785      0.513      0.539      0.301

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     38/100      1.99G       1.45     0.8713     0.8445        210        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.799      0.519      0.556      0.341

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     39/100      1.99G      1.484     0.8736     0.8436        238        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.772      0.496      0.559      0.302

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     40/100      1.99G      1.434     0.8443     0.8446        176        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.787      0.534      0.568      0.336

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     41/100      1.99G      1.365     0.8316     0.8407        147        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.833      0.501      0.561      0.323

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     42/100      1.99G      1.399     0.8436     0.8373        209        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.825      0.517      0.565       0.31

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     43/100      1.99G      1.381     0.8311     0.8404        159        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.849      0.502      0.572      0.316

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     44/100      1.99G      1.359     0.8052     0.8392        115        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.841      0.527      0.586      0.356

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     45/100      1.99G      1.409     0.8311     0.8351        230        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.897      0.507      0.593      0.335

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     46/100      1.99G       1.39     0.8033     0.8406        127        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.881      0.521      0.596      0.352

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     47/100      1.99G      1.397     0.8045     0.8387        147        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.792      0.559      0.587      0.342

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     48/100      1.99G      1.308     0.7802     0.8309         97        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.853      0.555      0.609      0.367

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     49/100      1.99G      1.351     0.7775     0.8326        130        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.884      0.556      0.611      0.345

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     50/100      1.99G      1.371     0.7948     0.8323        135        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.909      0.557       0.62      0.371

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     51/100      1.99G      1.324     0.7599     0.8291        114        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.888      0.575      0.617      0.362

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     52/100      1.99G      1.333     0.7634     0.8313        176        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.859      0.576      0.614      0.357

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     53/100      1.99G      1.316     0.7678     0.8298         89        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.864      0.558      0.616      0.377

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     54/100      1.99G      1.304     0.7515      0.829        205        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.836      0.561      0.612      0.365

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     55/100      1.99G      1.291     0.7561     0.8314        199        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.849      0.588      0.617      0.385

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     56/100      1.99G       1.28      0.745     0.8277        145        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.796      0.598      0.609      0.381

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     57/100      1.99G      1.265     0.7361     0.8292        159        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.816       0.59      0.616      0.391

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     58/100      1.99G      1.316     0.7579     0.8236        184        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.856      0.568      0.614      0.379

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     59/100      1.99G      1.307     0.7426     0.8248        201        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.829      0.589      0.613      0.373

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     60/100      1.99G      1.263     0.7287     0.8249        196        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.804      0.613      0.611      0.377

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     61/100      1.99G      1.261     0.7306     0.8294        153        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.836      0.573      0.617      0.385

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     62/100      1.99G      1.242     0.7202     0.8309        141        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.848      0.583      0.614      0.379

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     63/100      1.99G      1.229     0.7055     0.8281        247        640: 100%|██████████| 51/51 [00:07
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.854      0.542      0.606      0.366

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     64/100      1.99G      1.226     0.7115     0.8258        212        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.853      0.597      0.622      0.399

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     65/100      1.99G      1.219     0.7067     0.8207        132        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.842      0.593      0.619      0.395

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     66/100      1.99G      1.229     0.7119     0.8277        118        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.843       0.58      0.625      0.392

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     67/100      1.99G      1.222     0.7114      0.827        131        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.845      0.589      0.629      0.398

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     68/100      1.99G      1.237     0.7146     0.8227         79        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905       0.84      0.564      0.617      0.388

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     69/100      1.99G      1.221     0.6929     0.8193        118        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.873      0.566      0.635      0.409

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     70/100      1.99G      1.178     0.6823     0.8187        155        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.892      0.586      0.634      0.396

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     71/100      1.99G      1.221     0.7006     0.8204        178        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.863      0.594      0.627      0.402

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     72/100      1.99G      1.179     0.6768     0.8146        170        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.866       0.57      0.629      0.395

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     73/100      1.99G      1.193     0.6817     0.8214        109        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.861      0.585      0.628      0.404

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     74/100      1.99G      1.167     0.6858     0.8179        168        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.861      0.597       0.63      0.399

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     75/100      1.99G      1.186     0.6846     0.8165        157        640: 100%|██████████| 51/51 [00:05
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.872      0.599      0.635      0.398

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     76/100      1.99G      1.167     0.6659     0.8174        142        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.866      0.614      0.633        0.4

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     77/100      1.99G      1.154     0.6747     0.8187        171        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.856      0.612      0.629      0.391

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     78/100      1.99G      1.117     0.6599     0.8153         90        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.862      0.605      0.628      0.397

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     79/100      1.99G      1.174      0.677     0.8133        145        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.854      0.606      0.633      0.407

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     80/100      1.99G      1.161     0.6688     0.8162        201        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.841      0.611      0.631      0.407

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     81/100      1.99G      1.142      0.658     0.8184        201        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.833      0.617      0.631      0.407

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     82/100      1.99G      1.143     0.6509     0.8116        150        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905       0.84      0.628      0.626      0.405

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     83/100      1.99G      1.138     0.6508     0.8134        185        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.855      0.632      0.636      0.414

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     84/100      1.99G      1.159     0.6615     0.8112        249        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905       0.86      0.618      0.647       0.42

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     85/100      1.99G      1.125     0.6503     0.8129        152        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.864      0.611      0.646      0.417

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     86/100      1.99G      1.112     0.6412     0.8154        170        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.856      0.609      0.639      0.415

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     87/100      1.99G      1.149      0.647     0.8126        205        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.855      0.614      0.635      0.415

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     88/100      1.99G      1.093     0.6269      0.811        177        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.856      0.609      0.636      0.416

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     89/100      1.99G      1.087     0.6333     0.8119        169        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.848       0.62      0.638      0.413

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     90/100      1.99G       1.12     0.6398     0.8129        169        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905       0.88      0.591      0.649       0.42
Closing dataloader mosaic

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     91/100      1.99G      1.064     0.6786     0.8115         90        640: 100%|██████████| 51/51 [00:06
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.844      0.591      0.647      0.407

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     92/100      1.99G      1.035     0.6426     0.8113         90        640: 100%|██████████| 51/51 [00:05
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.854      0.583      0.642      0.411

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     93/100      1.99G      1.061     0.6618      0.805         95        640: 100%|██████████| 51/51 [00:05
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.849      0.589      0.639      0.409

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     94/100      1.99G      1.062     0.6508     0.8099         91        640: 100%|██████████| 51/51 [00:05
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.843      0.606      0.646      0.415

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     95/100      1.99G       1.05     0.6432     0.8106         91        640: 100%|██████████| 51/51 [00:05
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.835      0.616      0.654      0.417

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     96/100      1.99G      1.059     0.6453     0.8104         93        640: 100%|██████████| 51/51 [00:05
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.848      0.622      0.655      0.421

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     97/100      1.99G      1.033     0.6385     0.8024         91        640: 100%|██████████| 51/51 [00:05
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.833      0.633       0.65      0.421

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     98/100      1.99G      1.017     0.6259     0.8074         98        640: 100%|██████████| 51/51 [00:05
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905       0.83      0.627      0.651      0.426

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
     99/100      1.99G      1.015      0.623     0.8082         89        640: 100%|██████████| 51/51 [00:05
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.834      0.623      0.651      0.428

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
    100/100      1.99G      1.031     0.6333     0.8088         92        640: 100%|██████████| 51/51 [00:05
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.839      0.626       0.65      0.422

100 epochs completed in 0.260 hours.
Optimizer stripped from runs/detect/train13/weights/last.pt, 6.3MB
Optimizer stripped from runs/detect/train13/weights/best.pt, 6.3MB

Validating runs/detect/train13/weights/best.pt...
Ultralytics YOLOv8.0.3 🚀 Python-3.10.6 torch-1.13.1+cu117 CUDA:0 (NVIDIA GeForce RTX 3060, 12288MiB)
Fusing layers... 
Model summary: 168 layers, 3006428 parameters, 0 gradients, 8.1 GFLOPs
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95):  60%|██████    | 3WARNING ⚠️ NMS time limit 0.900s exceeded
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 5
                   all         38        905      0.832      0.596      0.624      0.407
                  ball         38         35          1          0          0          0
            goalkeeper         38         27      0.812      0.802      0.877      0.574
                player         38        754      0.871      0.895      0.922      0.634
               referee         38         89      0.646      0.685      0.696      0.421
Speed: 1.6ms pre-process, 56.7ms inference, 0.0ms loss, 53.7ms post-process per image
Saving runs/detect/train13/predictions.json...
Results saved to runs/detect/train13

テスト用の画像

テスト前の画像を一枚だけ載せます。ドルトムントの試合みたいですね!

検出結果

player だけでなく referee, goalkeeper も検出してくれてました。良い感じではないでしょうか。

!yolo task=detect mode=predict model=best.pt source="./football-players-detection-4/test/images"


ただ、別の画像の検出ではボールまでは捉えてくれませんでした。選手よりだいぶ小さいので難しいのですかね?

感想

面白かったです。次はサッカーのリアルタイム動画像でどう検出されるのか試すことにします。

Discussion

あすま自動化研究所あすま自動化研究所

記事のとうりにやってみて、できました。
ありがとうございます。
データをダウンロードするところのインストラクションもあると初心者にはやさしいです。