Ccmmutty logo
Commutty IT
0 pv3 min read

YOLOv5で転移学習してみる

https://cdn.magicode.io/media/notebox/21edc16a-71d9-4787-8405-bc76e0f49b63.jpeg

YOLOv5で転移学習

以前とりあえずYOLOv5を使ってみるということでノートパソコンの内臓のカメラで自分の顔を検出させてみました。 https://jp.magicode.io/mnbi/articles/c89195ef85984442a544ca79d5206872
今回は学習済でない物体を検出させるため、画像を用意して、学習させてみようと思います。
(ラベリングはやりません。。。)
ちなみにyolov5の学習済モデルで検出できるのは'person', 'bicycle', 'car', 等々80クラスのようです。 https://github.com/ultralytics/yolov5/blob/master/data/coco128.yaml

なにをやるか

roboflowのPublic Datasetsで良きデータがないか探しました。 長引くコロナ禍、あまり着けない国もあるようですが、日本ではまだまだみんな着けてるマスクの着用検出向けのデータセットもあります。
が、
ヘルメットの着用検知をやります。
Hard Hat Workers Dataset

やってみる

googlecolabでnotebookを作る

貧弱なGPUしか持ち合わせていないのでgooglecolabのパワーを借ります。 無料枠でもnVIDIA TESLAっていう強いGPUが使えるそうです。

googleDriveをマウントする

colabの無料枠ではディスクが定期的(最大12時間?)でリセットされてしまいますが、 googleDriveをマウントしておけば、消えてほしくないファイルはDriveに保存できます。

roboflowのデータセットをダウンロードしてDriveに保存

colabでyolov5の準備

yolov5のリポジトリをcloneして、ディレクトリ移動します。
python
!git clone https://github.com/ultralytics/yolov5

Cloning into 'yolov5'... remote: Enumerating objects: 12281, done. remote: Total 12281 (delta 0), reused 0 (delta 0), pack-reused 12281 Receiving objects: 100% (12281/12281), 12.08 MiB | 31.40 MiB/s, done. Resolving deltas: 100% (8476/8476), done.
python
cd yolov5

/content/yolov5
必要なライブラリを一括でインストールします。
実行結果は文字化けしてますね・・・
python
!pip install -qr requirements.txt

[?25l  |▌ | 10 kB 33.3 MB/s eta 0:00:01  |█ | 20 kB 9.1 MB/s eta 0:00:01  |█▋ | 30 kB 8.4 MB/s eta 0:00:01  |██▏ | 40 kB 7.9 MB/s eta 0:00:01  |██▊ | 51 kB 4.4 MB/s eta 0:00:01  |███▎ | 61 kB 5.2 MB/s eta 0:00:01  |███▉ | 71 kB 5.3 MB/s eta 0:00:01  |████▍ | 81 kB 4.1 MB/s eta 0:00:01  |█████ | 92 kB 4.5 MB/s eta 0:00:01  |█████▌ | 102 kB 5.0 MB/s eta 0:00:01  |██████ | 112 kB 5.0 MB/s eta 0:00:01  |██████▋ | 122 kB 5.0 MB/s eta 0:00:01  |███████▏ | 133 kB 5.0 MB/s eta 0:00:01  |███████▊ | 143 kB 5.0 MB/s eta 0:00:01  |████████▎ | 153 kB 5.0 MB/s eta 0:00:01  |████████▉ | 163 kB 5.0 MB/s eta 0:00:01  |█████████▍ | 174 kB 5.0 MB/s eta 0:00:01  |██████████ | 184 kB 5.0 MB/s eta 0:00:01  |██████████▍ | 194 kB 5.0 MB/s eta 0:00:01  |███████████ | 204 kB 5.0 MB/s eta 0:00:01  |███████████▌ | 215 kB 5.0 MB/s eta 0:00:01  |████████████ | 225 kB 5.0 MB/s eta 0:00:01  |████████████▋ | 235 kB 5.0 MB/s eta 0:00:01  |█████████████▏ | 245 kB 5.0 MB/s eta 0:00:01  |█████████████▊ | 256 kB 5.0 MB/s eta 0:00:01  |██████████████▎ | 266 kB 5.0 MB/s eta 0:00:01  |██████████████▉ | 276 kB 5.0 MB/s eta 0:00:01  |███████████████▍ | 286 kB 5.0 MB/s eta 0:00:01  |████████████████ | 296 kB 5.0 MB/s eta 0:00:01  |████████████████▌ | 307 kB 5.0 MB/s eta 0:00:01  |█████████████████ | 317 kB 5.0 MB/s eta 0:00:01  |█████████████████▋ | 327 kB 5.0 MB/s eta 0:00:01  |██████████████████▏ | 337 kB 5.0 MB/s eta 0:00:01  |██████████████████▊ | 348 kB 5.0 MB/s eta 0:00:01  |███████████████████▎ | 358 kB 5.0 MB/s eta 0:00:01  |███████████████████▉ | 368 kB 5.0 MB/s eta 0:00:01  |████████████████████▍ | 378 kB 5.0 MB/s eta 0:00:01  |████████████████████▉ | 389 kB 5.0 MB/s eta 0:00:01  |█████████████████████▍ | 399 kB 5.0 MB/s eta 0:00:01  |██████████████████████ | 409 kB 5.0 MB/s eta 0:00:01  |██████████████████████▌ | 419 kB 5.0 MB/s eta 0:00:01  |███████████████████████ | 430 kB 5.0 MB/s eta 0:00:01  |███████████████████████▋ | 440 kB 5.0 MB/s eta 0:00:01  |████████████████████████▏ | 450 kB 5.0 MB/s eta 0:00:01  |████████████████████████▊ | 460 kB 5.0 MB/s eta 0:00:01  |█████████████████████████▎ | 471 kB 5.0 MB/s eta 0:00:01  |█████████████████████████▉ | 481 kB 5.0 MB/s eta 0:00:01  |██████████████████████████▍ | 491 kB 5.0 MB/s eta 0:00:01  |███████████████████████████ | 501 kB 5.0 MB/s eta 0:00:01  |███████████████████████████▌ | 512 kB 5.0 MB/s eta 0:00:01  |████████████████████████████ | 522 kB 5.0 MB/s eta 0:00:01  |████████████████████████████▋ | 532 kB 5.0 MB/s eta 0:00:01  |█████████████████████████████▏ | 542 kB 5.0 MB/s eta 0:00:01  |█████████████████████████████▊ | 552 kB 5.0 MB/s eta 0:00:01  |██████████████████████████████▎ | 563 kB 5.0 MB/s eta 0:00:01  |██████████████████████████████▊ | 573 kB 5.0 MB/s eta 0:00:01  |███████████████████████████████▎| 583 kB 5.0 MB/s eta 0:00:01  |███████████████████████████████▉| 593 kB 5.0 MB/s eta 0:00:01  |████████████████████████████████| 596 kB 5.0 MB/s [?25h
学習を実行します。
yolov5で用意されているtrain.pyを使用します。
--dataでDriveに保存したデータセットフォルダ内のyamlファイルを指定
--batch-size,--epochはなんでもいいと思います(これを変えた場合の効果わからんので)。
--freeze 10 は重要です。yolov5sというモデルは最初の10層が特徴量を取り出す層になっていて、10を設定することで特徴量を取り出す層を再利用できるようです。 --name /content/drive/MyDrive/HardHatData --nameは結果を保存するディレクトリ指定です。
結果を確認する前にディスクがリセットされるとやり直しになってしまうのでマウントしたDriveに保存しておきます。
python
# --weights /content/yolov5/runs/train/exp3/weights/best.pt
!python train.py --data /content/drive/MyDrive/HardHatData/data.yaml --cfg yolov5s.yaml  --batch-size 8 --epochs 50 --freeze 10 --name /content/drive/MyDrive/HardHatData

train: weights=yolov5s.pt, cfg=yolov5s.yaml, data=/content/drive/MyDrive/HardHatData/data.yaml, hyp=data/hyps/hyp.scratch-low.yaml, epochs=50, batch_size=8, imgsz=640, rect=False, resume=False, nosave=False, noval=False, noautoanchor=False, noplots=False, evolve=None, bucket=, cache=None, image_weights=False, device=, multi_scale=False, single_cls=False, optimizer=SGD, sync_bn=False, workers=8, project=runs/train, name=/content/drive/MyDrive/HardHatData, exist_ok=False, quad=False, cos_lr=False, label_smoothing=0.0, patience=100, freeze=[10], save_period=-1, local_rank=-1, entity=None, upload_dataset=False, bbox_interval=-1, artifact_alias=latest github: up to date with https://github.com/ultralytics/yolov5 ✅ YOLOv5 🚀 v6.1-261-g19f33cb Python-3.7.13 torch-1.11.0+cu113 CUDA:0 (Tesla T4, 15110MiB) hyperparameters: 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=0.05, cls=0.5, cls_pw=1.0, obj=1.0, obj_pw=1.0, iou_t=0.2, anchor_t=4.0, fl_gamma=0.0, 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 Weights & Biases: run 'pip install wandb' to automatically track and visualize YOLOv5 🚀 runs (RECOMMENDED) TensorBoard: Start with 'tensorboard --logdir /content/drive/MyDrive', view at http://localhost:6006/ Downloading https://ultralytics.com/assets/Arial.ttf to /root/.config/Ultralytics/Arial.ttf... 100% 755k/755k [00:00<00:00, 18.0MB/s] Downloading https://github.com/ultralytics/yolov5/releases/download/v6.1/yolov5s.pt to yolov5s.pt... 100% 14.1M/14.1M [00:00<00:00, 136MB/s] Overriding model.yaml nc=80 with nc=3 from n params module arguments 0 -1 1 3520 models.common.Conv [3, 32, 6, 2, 2] 1 -1 1 18560 models.common.Conv [32, 64, 3, 2] 2 -1 1 18816 models.common.C3 [64, 64, 1] 3 -1 1 73984 models.common.Conv [64, 128, 3, 2] 4 -1 2 115712 models.common.C3 [128, 128, 2] 5 -1 1 295424 models.common.Conv [128, 256, 3, 2] 6 -1 3 625152 models.common.C3 [256, 256, 3] 7 -1 1 1180672 models.common.Conv [256, 512, 3, 2] 8 -1 1 1182720 models.common.C3 [512, 512, 1] 9 -1 1 656896 models.common.SPPF [512, 512, 5] 10 -1 1 131584 models.common.Conv [512, 256, 1, 1] 11 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] 12 [-1, 6] 1 0 models.common.Concat [1] 13 -1 1 361984 models.common.C3 [512, 256, 1, False] 14 -1 1 33024 models.common.Conv [256, 128, 1, 1] 15 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] 16 [-1, 4] 1 0 models.common.Concat [1] 17 -1 1 90880 models.common.C3 [256, 128, 1, False] 18 -1 1 147712 models.common.Conv [128, 128, 3, 2] 19 [-1, 14] 1 0 models.common.Concat [1] 20 -1 1 296448 models.common.C3 [256, 256, 1, False] 21 -1 1 590336 models.common.Conv [256, 256, 3, 2] 22 [-1, 10] 1 0 models.common.Concat [1] 23 -1 1 1182720 models.common.C3 [512, 512, 1, False] 24 [17, 20, 23] 1 21576 models.yolo.Detect [3, [[10, 13, 16, 30, 33, 23], [30, 61, 62, 45, 59, 119], [116, 90, 156, 198, 373, 326]], [128, 256, 512]] YOLOv5s summary: 270 layers, 7027720 parameters, 7027720 gradients Transferred 342/349 items from yolov5s.pt AMP: checks passed ✅ freezing model.0.conv.weight freezing model.0.bn.weight freezing model.0.bn.bias freezing model.1.conv.weight freezing model.1.bn.weight freezing model.1.bn.bias freezing model.2.cv1.conv.weight freezing model.2.cv1.bn.weight freezing model.2.cv1.bn.bias freezing model.2.cv2.conv.weight freezing model.2.cv2.bn.weight freezing model.2.cv2.bn.bias freezing model.2.cv3.conv.weight freezing model.2.cv3.bn.weight freezing model.2.cv3.bn.bias freezing model.2.m.0.cv1.conv.weight freezing model.2.m.0.cv1.bn.weight freezing model.2.m.0.cv1.bn.bias freezing model.2.m.0.cv2.conv.weight freezing model.2.m.0.cv2.bn.weight freezing model.2.m.0.cv2.bn.bias freezing model.3.conv.weight freezing model.3.bn.weight freezing model.3.bn.bias freezing model.4.cv1.conv.weight freezing model.4.cv1.bn.weight freezing model.4.cv1.bn.bias freezing model.4.cv2.conv.weight freezing model.4.cv2.bn.weight freezing model.4.cv2.bn.bias freezing model.4.cv3.conv.weight freezing model.4.cv3.bn.weight freezing model.4.cv3.bn.bias freezing model.4.m.0.cv1.conv.weight freezing model.4.m.0.cv1.bn.weight freezing model.4.m.0.cv1.bn.bias freezing model.4.m.0.cv2.conv.weight freezing model.4.m.0.cv2.bn.weight freezing model.4.m.0.cv2.bn.bias freezing model.4.m.1.cv1.conv.weight freezing model.4.m.1.cv1.bn.weight freezing model.4.m.1.cv1.bn.bias freezing model.4.m.1.cv2.conv.weight freezing model.4.m.1.cv2.bn.weight freezing model.4.m.1.cv2.bn.bias freezing model.5.conv.weight freezing model.5.bn.weight freezing model.5.bn.bias freezing model.6.cv1.conv.weight freezing model.6.cv1.bn.weight freezing model.6.cv1.bn.bias freezing model.6.cv2.conv.weight freezing model.6.cv2.bn.weight freezing model.6.cv2.bn.bias freezing model.6.cv3.conv.weight freezing model.6.cv3.bn.weight freezing model.6.cv3.bn.bias freezing model.6.m.0.cv1.conv.weight freezing model.6.m.0.cv1.bn.weight freezing model.6.m.0.cv1.bn.bias freezing model.6.m.0.cv2.conv.weight freezing model.6.m.0.cv2.bn.weight freezing model.6.m.0.cv2.bn.bias freezing model.6.m.1.cv1.conv.weight freezing model.6.m.1.cv1.bn.weight freezing model.6.m.1.cv1.bn.bias freezing model.6.m.1.cv2.conv.weight freezing model.6.m.1.cv2.bn.weight freezing model.6.m.1.cv2.bn.bias freezing model.6.m.2.cv1.conv.weight freezing model.6.m.2.cv1.bn.weight freezing model.6.m.2.cv1.bn.bias freezing model.6.m.2.cv2.conv.weight freezing model.6.m.2.cv2.bn.weight freezing model.6.m.2.cv2.bn.bias freezing model.7.conv.weight freezing model.7.bn.weight freezing model.7.bn.bias freezing model.8.cv1.conv.weight freezing model.8.cv1.bn.weight freezing model.8.cv1.bn.bias freezing model.8.cv2.conv.weight freezing model.8.cv2.bn.weight freezing model.8.cv2.bn.bias freezing model.8.cv3.conv.weight freezing model.8.cv3.bn.weight freezing model.8.cv3.bn.bias freezing model.8.m.0.cv1.conv.weight freezing model.8.m.0.cv1.bn.weight freezing model.8.m.0.cv1.bn.bias freezing model.8.m.0.cv2.conv.weight freezing model.8.m.0.cv2.bn.weight freezing model.8.m.0.cv2.bn.bias freezing model.9.cv1.conv.weight freezing model.9.cv1.bn.weight freezing model.9.cv1.bn.bias freezing model.9.cv2.conv.weight freezing model.9.cv2.bn.weight freezing model.9.cv2.bn.bias Scaled weight_decay = 0.0005 optimizer: SGD with parameter groups 57 weight (no decay), 60 weight, 60 bias albumentations: version 1.0.3 required by YOLOv5, but version 0.1.12 is currently installed train: Scanning '/content/drive/MyDrive/HardHatData/train/labels.cache' images and labels... 5269 found, 0 missing, 0 empty, 0 corrupt: 100% 5269/5269 [00:00<?, ?it/s] val: Scanning '/content/drive/MyDrive/HardHatData/test/labels.cache' images and labels... 1766 found, 0 missing, 0 empty, 0 corrupt: 100% 1766/1766 [00:00<?, ?it/s] Plotting labels to /content/drive/MyDrive/HardHatData2/labels.jpg... AutoAnchor: 6.07 anchors/target, 1.000 Best Possible Recall (BPR). Current anchors are a good fit to dataset ✅ Image sizes 640 train, 640 val Using 2 dataloader workers Logging results to /content/drive/MyDrive/HardHatData2 Starting training for 50 epochs... Epoch gpu_mem box obj cls labels img_size 0/49 0.719G 0.0748 0.04588 0.02218 26 640: 100% 659/659 [02:44<00:00, 4.00it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [03:21<00:00, 1.82s/it] all 1766 6808 0.707 0.491 0.413 0.172 Epoch gpu_mem box obj cls labels img_size 1/49 2.17G 0.05388 0.03493 0.008085 24 640: 100% 659/659 [02:37<00:00, 4.19it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:20<00:00, 5.51it/s] all 1766 6808 0.802 0.527 0.525 0.269 Epoch gpu_mem box obj cls labels img_size 2/49 2.17G 0.04844 0.03272 0.006217 32 640: 100% 659/659 [02:35<00:00, 4.23it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.11it/s] all 1766 6808 0.958 0.605 0.646 0.381 Epoch gpu_mem box obj cls labels img_size 3/49 2.17G 0.04142 0.03146 0.004875 22 640: 100% 659/659 [02:35<00:00, 4.23it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.15it/s] all 1766 6808 0.957 0.613 0.646 0.399 Epoch gpu_mem box obj cls labels img_size 4/49 2.17G 0.03734 0.03052 0.004159 36 640: 100% 659/659 [02:35<00:00, 4.23it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.15it/s] all 1766 6808 0.958 0.614 0.645 0.407 Epoch gpu_mem box obj cls labels img_size 5/49 2.17G 0.03475 0.0295 0.003677 26 640: 100% 659/659 [02:35<00:00, 4.24it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.07it/s] all 1766 6808 0.964 0.614 0.655 0.416 Epoch gpu_mem box obj cls labels img_size 6/49 2.17G 0.03399 0.02981 0.003388 35 640: 100% 659/659 [02:36<00:00, 4.22it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.11it/s] all 1766 6808 0.96 0.617 0.656 0.422 Epoch gpu_mem box obj cls labels img_size 7/49 2.17G 0.03309 0.02937 0.003309 54 640: 100% 659/659 [02:35<00:00, 4.24it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.13it/s] all 1766 6808 0.961 0.62 0.655 0.424 Epoch gpu_mem box obj cls labels img_size 8/49 2.17G 0.03232 0.02891 0.002998 40 640: 100% 659/659 [02:35<00:00, 4.24it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:17<00:00, 6.19it/s] all 1766 6808 0.959 0.624 0.654 0.427 Epoch gpu_mem box obj cls labels img_size 9/49 2.17G 0.03167 0.02868 0.002902 17 640: 100% 659/659 [02:35<00:00, 4.22it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.07it/s] all 1766 6808 0.958 0.625 0.657 0.433 Epoch gpu_mem box obj cls labels img_size 10/49 2.17G 0.0314 0.02848 0.002689 37 640: 100% 659/659 [02:33<00:00, 4.30it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:17<00:00, 6.19it/s] all 1766 6808 0.963 0.621 0.654 0.43 Epoch gpu_mem box obj cls labels img_size 11/49 2.17G 0.0308 0.02838 0.002687 45 640: 100% 659/659 [02:35<00:00, 4.24it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:17<00:00, 6.20it/s] all 1766 6808 0.964 0.62 0.656 0.432 Epoch gpu_mem box obj cls labels img_size 12/49 2.17G 0.03045 0.02808 0.002608 15 640: 100% 659/659 [02:34<00:00, 4.27it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.08it/s] all 1766 6808 0.959 0.626 0.656 0.434 Epoch gpu_mem box obj cls labels img_size 13/49 2.17G 0.03048 0.02839 0.002552 26 640: 100% 659/659 [02:36<00:00, 4.21it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:17<00:00, 6.20it/s] all 1766 6808 0.958 0.628 0.656 0.429 Epoch gpu_mem box obj cls labels img_size 14/49 2.17G 0.02999 0.0277 0.002376 54 640: 100% 659/659 [02:35<00:00, 4.24it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.07it/s] all 1766 6808 0.961 0.627 0.655 0.434 Epoch gpu_mem box obj cls labels img_size 15/49 2.17G 0.02956 0.02743 0.002382 40 640: 100% 659/659 [02:36<00:00, 4.22it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.12it/s] all 1766 6808 0.96 0.626 0.655 0.437 Epoch gpu_mem box obj cls labels img_size 16/49 2.17G 0.02958 0.02792 0.002423 27 640: 100% 659/659 [02:35<00:00, 4.24it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:17<00:00, 6.18it/s] all 1766 6808 0.962 0.626 0.656 0.438 Epoch gpu_mem box obj cls labels img_size 17/49 2.17G 0.02919 0.02757 0.002325 34 640: 100% 659/659 [02:33<00:00, 4.28it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:19<00:00, 5.67it/s] all 1766 6808 0.962 0.627 0.657 0.441 Epoch gpu_mem box obj cls labels img_size 18/49 2.17G 0.02922 0.02755 0.002192 24 640: 100% 659/659 [02:34<00:00, 4.25it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.15it/s] all 1766 6808 0.959 0.628 0.654 0.438 Epoch gpu_mem box obj cls labels img_size 19/49 2.17G 0.02888 0.02733 0.002031 51 640: 100% 659/659 [02:35<00:00, 4.23it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.12it/s] all 1766 6808 0.625 0.629 0.654 0.435 Epoch gpu_mem box obj cls labels img_size 20/49 2.17G 0.02886 0.02747 0.002049 26 640: 100% 659/659 [02:35<00:00, 4.24it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.16it/s] all 1766 6808 0.649 0.645 0.657 0.44 Epoch gpu_mem box obj cls labels img_size 21/49 2.17G 0.02863 0.02701 0.002118 24 640: 100% 659/659 [02:35<00:00, 4.24it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:17<00:00, 6.18it/s] all 1766 6808 0.958 0.626 0.656 0.44 Epoch gpu_mem box obj cls labels img_size 22/49 2.17G 0.02875 0.02724 0.002231 29 640: 100% 659/659 [02:35<00:00, 4.25it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.09it/s] all 1766 6808 0.627 0.629 0.654 0.44 Epoch gpu_mem box obj cls labels img_size 23/49 2.17G 0.02843 0.02681 0.001915 29 640: 100% 659/659 [02:34<00:00, 4.26it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.11it/s] all 1766 6808 0.63 0.626 0.653 0.441 Epoch gpu_mem box obj cls labels img_size 24/49 2.17G 0.02829 0.02689 0.001911 18 640: 100% 659/659 [02:35<00:00, 4.24it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:17<00:00, 6.18it/s] all 1766 6808 0.641 0.636 0.655 0.442 Epoch gpu_mem box obj cls labels img_size 25/49 2.17G 0.02799 0.02663 0.001944 45 640: 100% 659/659 [02:34<00:00, 4.25it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:19<00:00, 5.77it/s] all 1766 6808 0.636 0.634 0.654 0.441 Epoch gpu_mem box obj cls labels img_size 26/49 2.17G 0.02803 0.02667 0.001934 26 640: 100% 659/659 [02:33<00:00, 4.29it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:19<00:00, 5.62it/s] all 1766 6808 0.64 0.638 0.655 0.442 Epoch gpu_mem box obj cls labels img_size 27/49 2.17G 0.02777 0.02616 0.001781 35 640: 100% 659/659 [02:33<00:00, 4.30it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:19<00:00, 5.62it/s] all 1766 6808 0.673 0.638 0.655 0.442 Epoch gpu_mem box obj cls labels img_size 28/49 2.17G 0.0278 0.02645 0.001832 24 640: 100% 659/659 [02:33<00:00, 4.30it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.14it/s] all 1766 6808 0.637 0.639 0.654 0.441 Epoch gpu_mem box obj cls labels img_size 29/49 2.17G 0.02765 0.02619 0.001748 28 640: 100% 659/659 [02:35<00:00, 4.25it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:19<00:00, 5.68it/s] all 1766 6808 0.644 0.639 0.655 0.445 Epoch gpu_mem box obj cls labels img_size 30/49 2.17G 0.02773 0.02605 0.001691 32 640: 100% 659/659 [02:31<00:00, 4.36it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:17<00:00, 6.26it/s] all 1766 6808 0.63 0.627 0.656 0.443 Epoch gpu_mem box obj cls labels img_size 31/49 2.17G 0.0273 0.02642 0.001675 28 640: 100% 659/659 [02:33<00:00, 4.28it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.07it/s] all 1766 6808 0.65 0.627 0.656 0.444 Epoch gpu_mem box obj cls labels img_size 32/49 2.17G 0.02747 0.02646 0.001703 46 640: 100% 659/659 [02:34<00:00, 4.26it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.08it/s] all 1766 6808 0.672 0.632 0.656 0.444 Epoch gpu_mem box obj cls labels img_size 33/49 2.17G 0.02733 0.02634 0.00177 27 640: 100% 659/659 [02:35<00:00, 4.24it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:17<00:00, 6.18it/s] all 1766 6808 0.69 0.63 0.655 0.444 Epoch gpu_mem box obj cls labels img_size 34/49 2.17G 0.02748 0.0259 0.001736 26 640: 100% 659/659 [02:35<00:00, 4.24it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.15it/s] all 1766 6808 0.654 0.628 0.656 0.445 Epoch gpu_mem box obj cls labels img_size 35/49 2.17G 0.02704 0.02608 0.00165 55 640: 100% 659/659 [02:35<00:00, 4.24it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.11it/s] all 1766 6808 0.692 0.628 0.655 0.445 Epoch gpu_mem box obj cls labels img_size 36/49 2.17G 0.02707 0.02627 0.00168 27 640: 100% 659/659 [02:35<00:00, 4.23it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.13it/s] all 1766 6808 0.648 0.639 0.655 0.446 Epoch gpu_mem box obj cls labels img_size 37/49 2.17G 0.02682 0.02536 0.001517 55 640: 100% 659/659 [02:35<00:00, 4.25it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.16it/s] all 1766 6808 0.64 0.631 0.654 0.445 Epoch gpu_mem box obj cls labels img_size 38/49 2.17G 0.02683 0.02585 0.001526 28 640: 100% 659/659 [02:35<00:00, 4.25it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.10it/s] all 1766 6808 0.662 0.626 0.655 0.445 Epoch gpu_mem box obj cls labels img_size 39/49 2.17G 0.02682 0.02559 0.00152 34 640: 100% 659/659 [02:35<00:00, 4.25it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.15it/s] all 1766 6808 0.65 0.631 0.655 0.445 Epoch gpu_mem box obj cls labels img_size 40/49 2.17G 0.02664 0.0255 0.001429 34 640: 100% 659/659 [02:35<00:00, 4.24it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.16it/s] all 1766 6808 0.653 0.626 0.655 0.445 Epoch gpu_mem box obj cls labels img_size 41/49 2.17G 0.02687 0.0252 0.00159 34 640: 100% 659/659 [02:36<00:00, 4.20it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.10it/s] all 1766 6808 0.65 0.626 0.654 0.447 Epoch gpu_mem box obj cls labels img_size 42/49 2.17G 0.02663 0.02602 0.001448 42 640: 100% 659/659 [02:35<00:00, 4.23it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.12it/s] all 1766 6808 0.648 0.629 0.654 0.446 Epoch gpu_mem box obj cls labels img_size 43/49 2.17G 0.02632 0.02527 0.00146 21 640: 100% 659/659 [02:35<00:00, 4.23it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.11it/s] all 1766 6808 0.642 0.636 0.654 0.445 Epoch gpu_mem box obj cls labels img_size 44/49 2.17G 0.02619 0.02515 0.001309 36 640: 100% 659/659 [02:35<00:00, 4.23it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 5.96it/s] all 1766 6808 0.644 0.637 0.654 0.447 Epoch gpu_mem box obj cls labels img_size 45/49 2.17G 0.02639 0.02565 0.00151 27 640: 100% 659/659 [02:38<00:00, 4.16it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.13it/s] all 1766 6808 0.642 0.639 0.653 0.446 Epoch gpu_mem box obj cls labels img_size 46/49 2.17G 0.0264 0.02544 0.001331 45 640: 100% 659/659 [02:36<00:00, 4.22it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.14it/s] all 1766 6808 0.654 0.629 0.653 0.446 Epoch gpu_mem box obj cls labels img_size 47/49 2.17G 0.02615 0.02518 0.001314 23 640: 100% 659/659 [02:37<00:00, 4.19it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.12it/s] all 1766 6808 0.663 0.628 0.654 0.447 Epoch gpu_mem box obj cls labels img_size 48/49 2.17G 0.02595 0.02505 0.00128 13 640: 100% 659/659 [02:35<00:00, 4.23it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.10it/s] all 1766 6808 0.644 0.63 0.654 0.447 Epoch gpu_mem box obj cls labels img_size 49/49 2.17G 0.026 0.02485 0.001365 39 640: 100% 659/659 [02:35<00:00, 4.22it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:18<00:00, 6.12it/s] all 1766 6808 0.641 0.626 0.654 0.448 50 epochs completed in 2.474 hours. Optimizer stripped from /content/drive/MyDrive/HardHatData2/weights/last.pt, 14.4MB Optimizer stripped from /content/drive/MyDrive/HardHatData2/weights/best.pt, 14.4MB Validating /content/drive/MyDrive/HardHatData2/weights/best.pt... Fusing layers... YOLOv5s summary: 213 layers, 7018216 parameters, 0 gradients Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 111/111 [00:21<00:00, 5.15it/s] all 1766 6808 0.648 0.623 0.654 0.448 head 1766 1803 0.94 0.927 0.963 0.658 helmet 1766 4863 0.962 0.935 0.98 0.676 person 1766 142 0.0407 0.00704 0.0175 0.0101 Results saved to /content/drive/MyDrive/HardHatData2
Driveに保存された結果を確認します。 ヘルメットが検出できでいそうです。 が、personは全然検出できていなくて、間違ってhelmet検出しているケースも多々ある模様。
本来なら精度向上を目指すべきなんでしょうが、 まあ転移学習自体はできたしOK! ということで以上。

Discussion

コメントにはログインが必要です。