This commit is contained in:
Lukáš Trkan
2026-04-23 21:45:55 +02:00
parent 46492f2e23
commit 0a8cf3518e
9 changed files with 155 additions and 630 deletions

3
.gitignore vendored
View File

@@ -3,4 +3,5 @@ data/
*.zip
tiles/
tiles_annotated/
tiles_lanov/
tiles_lanov/
dataset_lanov.zip

View File

@@ -76,368 +76,10 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Trénink na: cuda\n",
"Ultralytics 8.4.40 🚀 Python-3.11.10 torch-2.4.1+cu124 CUDA:0 (NVIDIA GeForce RTX 4090, 24210MiB)\n",
"\u001b[34m\u001b[1mengine/trainer: \u001b[0magnostic_nms=False, amp=True, angle=1.0, augment=False, auto_augment=randaugment, batch=16, bgr=0.0, box=7.5, cache=False, cfg=None, classes=None, close_mosaic=10, cls=0.5, cls_pw=0.0, compile=False, conf=None, copy_paste=0.0, copy_paste_mode=flip, cos_lr=False, cutmix=0.0, data=data/yolo_visdrone/dataset.yaml, degrees=15.0, deterministic=True, device=0, dfl=1.5, dnn=False, dropout=0.0, dynamic=False, embed=None, end2end=None, epochs=50, erasing=0.4, exist_ok=False, fliplr=0.5, flipud=0.5, format=torchscript, fraction=1.0, freeze=None, half=False, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, imgsz=640, int8=False, iou=0.7, keras=False, kobj=1.0, line_width=None, lr0=0.01, lrf=0.01, mask_ratio=4, max_det=300, mixup=0.0, mode=train, model=yolov8s.pt, momentum=0.937, mosaic=1.0, multi_scale=0.0, name=visdrone_vehicles, nbs=64, nms=False, opset=None, optimize=False, optimizer=auto, overlap_mask=True, patience=10, perspective=0.0, plots=True, pose=12.0, pretrained=True, profile=False, project=runs/train, rect=False, resume=False, retina_masks=False, rle=1.0, save=True, save_conf=False, save_crop=False, save_dir=/workspace/runs/detect/runs/train/visdrone_vehicles, save_frames=False, save_json=False, save_period=10, save_txt=False, scale=0.5, seed=0, shear=0.0, show=False, show_boxes=True, show_conf=True, show_labels=True, simplify=True, single_cls=False, source=None, split=val, stream_buffer=False, task=detect, time=None, tracker=botsort.yaml, translate=0.1, val=True, verbose=True, vid_stride=1, visualize=False, warmup_bias_lr=0.1, warmup_epochs=3.0, warmup_momentum=0.8, weight_decay=0.0005, workers=8, workspace=None\n",
"Downloading https://ultralytics.com/assets/Arial.ttf to '/root/.config/Ultralytics/Arial.ttf': 100% ━━━━━━━━━━━━ 755.1KB 61.9MB/s 0.0s\n",
"Overriding model.yaml nc=80 with nc=4\n",
"\n",
" from n params module arguments \n",
" 0 -1 1 928 ultralytics.nn.modules.conv.Conv [3, 32, 3, 2] \n",
" 1 -1 1 18560 ultralytics.nn.modules.conv.Conv [32, 64, 3, 2] \n",
" 2 -1 1 29056 ultralytics.nn.modules.block.C2f [64, 64, 1, True] \n",
" 3 -1 1 73984 ultralytics.nn.modules.conv.Conv [64, 128, 3, 2] \n",
" 4 -1 2 197632 ultralytics.nn.modules.block.C2f [128, 128, 2, True] \n",
" 5 -1 1 295424 ultralytics.nn.modules.conv.Conv [128, 256, 3, 2] \n",
" 6 -1 2 788480 ultralytics.nn.modules.block.C2f [256, 256, 2, True] \n",
" 7 -1 1 1180672 ultralytics.nn.modules.conv.Conv [256, 512, 3, 2] \n",
" 8 -1 1 1838080 ultralytics.nn.modules.block.C2f [512, 512, 1, True] \n",
" 9 -1 1 656896 ultralytics.nn.modules.block.SPPF [512, 512, 5] \n",
" 10 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] \n",
" 11 [-1, 6] 1 0 ultralytics.nn.modules.conv.Concat [1] \n",
" 12 -1 1 591360 ultralytics.nn.modules.block.C2f [768, 256, 1] \n",
" 13 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] \n",
" 14 [-1, 4] 1 0 ultralytics.nn.modules.conv.Concat [1] \n",
" 15 -1 1 148224 ultralytics.nn.modules.block.C2f [384, 128, 1] \n",
" 16 -1 1 147712 ultralytics.nn.modules.conv.Conv [128, 128, 3, 2] \n",
" 17 [-1, 12] 1 0 ultralytics.nn.modules.conv.Concat [1] \n",
" 18 -1 1 493056 ultralytics.nn.modules.block.C2f [384, 256, 1] \n",
" 19 -1 1 590336 ultralytics.nn.modules.conv.Conv [256, 256, 3, 2] \n",
" 20 [-1, 9] 1 0 ultralytics.nn.modules.conv.Concat [1] \n",
" 21 -1 1 1969152 ultralytics.nn.modules.block.C2f [768, 512, 1] \n",
" 22 [15, 18, 21] 1 2117596 ultralytics.nn.modules.head.Detect [4, 16, None, [128, 256, 512]]\n",
"Model summary: 130 layers, 11,137,148 parameters, 11,137,132 gradients, 28.7 GFLOPs\n",
"\n",
"Transferred 349/355 items from pretrained weights\n",
"Freezing layer 'model.22.dfl.conv.weight'\n",
"\u001b[34m\u001b[1mAMP: \u001b[0mrunning Automatic Mixed Precision (AMP) checks...\n",
"Downloading https://github.com/ultralytics/assets/releases/download/v8.4.0/yolo26n.pt to 'yolo26n.pt': 100% ━━━━━━━━━━━━ 5.3MB 46.4MB/s 0.1s\n",
"\u001b[34m\u001b[1mAMP: \u001b[0mchecks passed ✅\n",
"\u001b[34m\u001b[1mtrain: \u001b[0mFast image access ✅ (ping: 0.6±0.2 ms, read: 48.3±24.4 MB/s, size: 260.7 KB)\n",
"\u001b[34m\u001b[1mtrain: \u001b[0mScanning /workspace/data/yolo_visdrone/train/labels... 6471 images, 279 backgrounds, 0 corrupt: 100% ━━━━━━━━━━━━ 6471/6471 514.6it/s 12.6s\n",
"\u001b[34m\u001b[1mtrain: \u001b[0m/workspace/data/yolo_visdrone/train/images/0000140_00118_d_0000002.jpg: 1 duplicate labels removed\n",
"\u001b[34m\u001b[1mtrain: \u001b[0mNew cache created: /workspace/data/yolo_visdrone/train/labels.cache\n",
"\u001b[34m\u001b[1mval: \u001b[0mFast image access ✅ (ping: 0.4±0.4 ms, read: 48.4±15.9 MB/s, size: 142.1 KB)\n",
"\u001b[34m\u001b[1mval: \u001b[0mScanning /workspace/data/yolo_visdrone/val/labels... 548 images, 29 backgrounds, 0 corrupt: 100% ━━━━━━━━━━━━ 548/548 365.1it/s 1.5s\n",
"\u001b[34m\u001b[1mval: \u001b[0mNew cache created: /workspace/data/yolo_visdrone/val/labels.cache\n",
"\u001b[34m\u001b[1moptimizer:\u001b[0m 'optimizer=auto' found, ignoring 'lr0=0.01' and 'momentum=0.937' and determining best 'optimizer', 'lr0' and 'momentum' automatically... \n",
"\u001b[34m\u001b[1moptimizer:\u001b[0m AdamW(lr=0.00125, momentum=0.9) with parameter groups 57 weight(decay=0.0), 64 weight(decay=0.0005), 63 bias(decay=0.0)\n",
"Plotting labels to /workspace/runs/detect/runs/train/visdrone_vehicles/labels.jpg... \n",
"Image sizes 640 train, 640 val\n",
"Using 8 dataloader workers\n",
"Logging results to \u001b[1m/workspace/runs/detect/runs/train/visdrone_vehicles\u001b[0m\n",
"Starting training for 50 epochs...\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 1/50 6.74G 1.681 1.528 1.078 120 640: 100% ━━━━━━━━━━━━ 405/405 11.2it/s 36.0s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 4.4it/s 4.1s\n",
" all 548 17040 0.364 0.302 0.271 0.148\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 2/50 7.48G 1.561 1.225 1.018 411 640: 100% ━━━━━━━━━━━━ 405/405 13.3it/s 30.3s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 5.3it/s 3.4s\n",
" all 548 17040 0.479 0.293 0.301 0.178\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 3/50 7.5G 1.538 1.186 1.007 316 640: 100% ━━━━━━━━━━━━ 405/405 13.5it/s 30.1s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 4.7it/s 3.8s\n",
" all 548 17040 0.384 0.342 0.304 0.167\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 4/50 7.5G 1.503 1.155 0.998 229 640: 100% ━━━━━━━━━━━━ 405/405 13.1it/s 31.0s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 5.0it/s 3.6s\n",
" all 548 17040 0.487 0.33 0.329 0.206\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 5/50 7.5G 1.465 1.105 0.9862 296 640: 100% ━━━━━━━━━━━━ 405/405 13.5it/s 30.1s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 5.4it/s 3.3s\n",
" all 548 17040 0.489 0.348 0.345 0.198\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 6/50 7.5G 1.453 1.075 0.9789 307 640: 100% ━━━━━━━━━━━━ 405/405 13.6it/s 29.9s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 4.9it/s 3.7s\n",
" all 548 17040 0.55 0.362 0.385 0.21\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 7/50 7.5G 1.433 1.058 0.9745 352 640: 100% ━━━━━━━━━━━━ 405/405 12.6it/s 32.2s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 5.3it/s 3.4s\n",
" all 548 17040 0.526 0.367 0.385 0.238\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 8/50 7.5G 1.411 1.033 0.9689 130 640: 100% ━━━━━━━━━━━━ 405/405 12.7it/s 31.9s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 6.9it/s 2.6s\n",
" all 548 17040 0.544 0.38 0.396 0.251\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 9/50 7.5G 1.391 1.016 0.9621 362 640: 100% ━━━━━━━━━━━━ 405/405 12.2it/s 33.1s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 6.9it/s 2.6s\n",
" all 548 17040 0.533 0.391 0.408 0.257\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 10/50 7.5G 1.37 1 0.9538 251 640: 100% ━━━━━━━━━━━━ 405/405 12.1it/s 33.5s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 7.2it/s 2.5s\n",
" all 548 17040 0.56 0.366 0.383 0.239\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 11/50 7.5G 1.359 0.9788 0.9528 315 640: 100% ━━━━━━━━━━━━ 405/405 13.0it/s 31.1s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 5.9it/s 3.0s\n",
" all 548 17040 0.528 0.393 0.408 0.248\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 12/50 8.27G 1.349 0.9773 0.9515 194 640: 100% ━━━━━━━━━━━━ 405/405 12.7it/s 32.0s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 7.8it/s 2.3s\n",
" all 548 17040 0.569 0.408 0.424 0.266\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 13/50 8.27G 1.338 0.9568 0.9487 302 640: 100% ━━━━━━━━━━━━ 405/405 12.9it/s 31.4s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 6.4it/s 2.8s\n",
" all 548 17040 0.586 0.403 0.43 0.272\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 14/50 8.27G 1.329 0.9541 0.9422 212 640: 100% ━━━━━━━━━━━━ 405/405 12.1it/s 33.4s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 6.1it/s 3.0s\n",
" all 548 17040 0.583 0.421 0.452 0.282\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 15/50 8.27G 1.327 0.9459 0.9386 312 640: 100% ━━━━━━━━━━━━ 405/405 13.0it/s 31.2s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 6.9it/s 2.6s\n",
" all 548 17040 0.592 0.424 0.453 0.289\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 16/50 8.27G 1.316 0.9352 0.9406 391 640: 100% ━━━━━━━━━━━━ 405/405 13.0it/s 31.0s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 6.4it/s 2.8s\n",
" all 548 17040 0.577 0.417 0.442 0.276\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 17/50 8.27G 1.302 0.9241 0.9354 289 640: 100% ━━━━━━━━━━━━ 405/405 13.0it/s 31.2s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 6.8it/s 2.7s\n",
" all 548 17040 0.615 0.41 0.455 0.286\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 18/50 8.27G 1.296 0.9194 0.9328 343 640: 100% ━━━━━━━━━━━━ 405/405 12.1it/s 33.4s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 6.3it/s 2.8s\n",
" all 548 17040 0.613 0.395 0.436 0.28\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 19/50 8.27G 1.285 0.9064 0.9314 176 640: 100% ━━━━━━━━━━━━ 405/405 12.5it/s 32.3s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 5.9it/s 3.1s\n",
" all 548 17040 0.596 0.427 0.454 0.287\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 20/50 8.27G 1.272 0.8993 0.9273 419 640: 100% ━━━━━━━━━━━━ 405/405 12.5it/s 32.4s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 6.8it/s 2.6s\n",
" all 548 17040 0.603 0.414 0.452 0.294\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 21/50 8.27G 1.266 0.8915 0.9256 368 640: 100% ━━━━━━━━━━━━ 405/405 12.4it/s 32.7s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 6.2it/s 2.9s\n",
" all 548 17040 0.635 0.433 0.479 0.303\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 22/50 8.27G 1.252 0.8861 0.9235 399 640: 100% ━━━━━━━━━━━━ 405/405 12.3it/s 32.8s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 7.2it/s 2.5s\n",
" all 548 17040 0.639 0.433 0.472 0.299\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 23/50 8.27G 1.249 0.8802 0.9229 323 640: 100% ━━━━━━━━━━━━ 405/405 12.7it/s 31.9s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 7.1it/s 2.5s\n",
" all 548 17040 0.616 0.427 0.467 0.305\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 24/50 8.27G 1.232 0.8676 0.9185 515 640: 100% ━━━━━━━━━━━━ 405/405 14.1it/s 28.7s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 6.3it/s 2.9s\n",
" all 548 17040 0.64 0.42 0.471 0.308\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 25/50 8.27G 1.23 0.8628 0.917 293 640: 100% ━━━━━━━━━━━━ 405/405 13.8it/s 29.4s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 6.9it/s 2.6s\n",
" all 548 17040 0.592 0.45 0.478 0.31\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 26/50 9.3G 1.231 0.8637 0.9194 339 640: 100% ━━━━━━━━━━━━ 405/405 12.1it/s 33.6s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 6.7it/s 2.7s\n",
" all 548 17040 0.635 0.418 0.467 0.305\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 27/50 9.3G 1.217 0.8563 0.9122 342 640: 100% ━━━━━━━━━━━━ 405/405 12.9it/s 31.4s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 6.5it/s 2.8s\n",
" all 548 17040 0.643 0.436 0.484 0.314\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 28/50 9.3G 1.213 0.8475 0.9091 387 640: 100% ━━━━━━━━━━━━ 405/405 13.5it/s 30.1s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 6.2it/s 2.9s\n",
" all 548 17040 0.622 0.449 0.486 0.31\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 29/50 9.3G 1.21 0.8415 0.9099 393 640: 100% ━━━━━━━━━━━━ 405/405 13.5it/s 30.1s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 6.3it/s 2.8s\n",
" all 548 17040 0.604 0.452 0.488 0.32\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 30/50 9.3G 1.203 0.8385 0.9082 296 640: 100% ━━━━━━━━━━━━ 405/405 13.9it/s 29.2s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 6.8it/s 2.6s\n",
" all 548 17040 0.604 0.452 0.487 0.311\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 31/50 9.3G 1.186 0.8276 0.9057 187 640: 100% ━━━━━━━━━━━━ 405/405 12.9it/s 31.5s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 7.6it/s 2.4s\n",
" all 548 17040 0.607 0.46 0.495 0.322\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 32/50 9.3G 1.194 0.8245 0.9052 312 640: 100% ━━━━━━━━━━━━ 405/405 12.7it/s 32.0s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 6.9it/s 2.6s\n",
" all 548 17040 0.652 0.451 0.502 0.327\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 33/50 9.3G 1.185 0.8258 0.9068 385 640: 100% ━━━━━━━━━━━━ 405/405 13.3it/s 30.4s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 6.5it/s 2.8s\n",
" all 548 17040 0.603 0.474 0.499 0.322\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 34/50 9.3G 1.181 0.8198 0.9028 300 640: 100% ━━━━━━━━━━━━ 405/405 13.2it/s 30.6s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 7.1it/s 2.5s\n",
" all 548 17040 0.651 0.451 0.5 0.326\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 35/50 9.3G 1.175 0.8094 0.9012 312 640: 100% ━━━━━━━━━━━━ 405/405 13.1it/s 30.9s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 8.8it/s 2.0s\n",
" all 548 17040 0.622 0.455 0.494 0.326\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 36/50 9.3G 1.167 0.8011 0.9009 399 640: 100% ━━━━━━━━━━━━ 405/405 14.2it/s 28.6s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 7.5it/s 2.4s\n",
" all 548 17040 0.634 0.452 0.499 0.33\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 37/50 9.3G 1.161 0.7976 0.9003 318 640: 100% ━━━━━━━━━━━━ 405/405 13.5it/s 29.9s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 6.4it/s 2.8s\n",
" all 548 17040 0.625 0.475 0.509 0.335\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 38/50 9.3G 1.164 0.7973 0.8987 280 640: 100% ━━━━━━━━━━━━ 405/405 13.5it/s 30.1s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 7.7it/s 2.3s\n",
" all 548 17040 0.625 0.482 0.517 0.34\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 39/50 9.3G 1.155 0.7871 0.8957 475 640: 100% ━━━━━━━━━━━━ 405/405 13.9it/s 29.1s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 9.0it/s 2.0s\n",
" all 548 17040 0.64 0.466 0.512 0.334\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 40/50 9.3G 1.151 0.7872 0.8961 274 640: 100% ━━━━━━━━━━━━ 405/405 14.1it/s 28.6s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 9.6it/s 1.9s\n",
" all 548 17040 0.644 0.471 0.51 0.334\n",
"Closing dataloader mosaic\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 41/50 9.3G 1.115 0.7576 0.8965 134 640: 100% ━━━━━━━━━━━━ 405/405 13.3it/s 30.5s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 7.6it/s 2.4s\n",
" all 548 17040 0.645 0.466 0.505 0.33\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 42/50 9.3G 1.105 0.7458 0.895 193 640: 100% ━━━━━━━━━━━━ 405/405 13.4it/s 30.1s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 8.4it/s 2.1s\n",
" all 548 17040 0.659 0.451 0.51 0.334\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 43/50 9.3G 1.099 0.7388 0.8945 119 640: 100% ━━━━━━━━━━━━ 405/405 15.1it/s 26.8s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 9.1it/s 2.0s\n",
" all 548 17040 0.589 0.486 0.505 0.335\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 44/50 9.3G 1.091 0.7312 0.8914 272 640: 100% ━━━━━━━━━━━━ 405/405 15.0it/s 27.0s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 8.9it/s 2.0s\n",
" all 548 17040 0.619 0.476 0.504 0.335\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 45/50 9.3G 1.086 0.7252 0.8911 180 640: 100% ━━━━━━━━━━━━ 405/405 14.5it/s 27.9s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 8.7it/s 2.1s\n",
" all 548 17040 0.638 0.468 0.506 0.338\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 46/50 9.3G 1.084 0.7237 0.8881 140 640: 100% ━━━━━━━━━━━━ 405/405 14.9it/s 27.2s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 8.4it/s 2.1s\n",
" all 548 17040 0.669 0.453 0.51 0.336\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 47/50 9.3G 1.078 0.7178 0.8877 187 640: 100% ━━━━━━━━━━━━ 405/405 14.2it/s 28.6s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 8.0it/s 2.3s\n",
" all 548 17040 0.663 0.458 0.512 0.339\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 48/50 9.3G 1.072 0.7115 0.8862 265 640: 100% ━━━━━━━━━━━━ 405/405 13.4it/s 30.2s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 7.9it/s 2.3s\n",
" all 548 17040 0.646 0.465 0.512 0.341\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 49/50 9.3G 1.073 0.7076 0.8848 238 640: 100% ━━━━━━━━━━━━ 405/405 13.8it/s 29.3s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 8.4it/s 2.1s\n",
" all 548 17040 0.632 0.468 0.515 0.343\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 50/50 9.3G 1.062 0.7007 0.8852 221 640: 100% ━━━━━━━━━━━━ 405/405 14.6it/s 27.7s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 9.5it/s 1.9s\n",
" all 548 17040 0.649 0.463 0.514 0.343\n",
"\n",
"50 epochs completed in 0.477 hours.\n",
"Optimizer stripped from /workspace/runs/detect/runs/train/visdrone_vehicles/weights/last.pt, 22.5MB\n",
"Optimizer stripped from /workspace/runs/detect/runs/train/visdrone_vehicles/weights/best.pt, 22.5MB\n",
"\n",
"Validating /workspace/runs/detect/runs/train/visdrone_vehicles/weights/best.pt...\n",
"Ultralytics 8.4.40 🚀 Python-3.11.10 torch-2.4.1+cu124 CUDA:0 (NVIDIA GeForce RTX 4090, 24210MiB)\n",
"Model summary (fused): 73 layers, 11,127,132 parameters, 0 gradients, 28.4 GFLOPs\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 18/18 6.3it/s 2.9s\n",
" all 548 17040 0.648 0.463 0.514 0.343\n",
" car 515 14064 0.752 0.751 0.772 0.51\n",
" van 421 1975 0.6 0.368 0.425 0.285\n",
" truck 266 750 0.579 0.3 0.342 0.223\n",
" bus 131 251 0.661 0.435 0.515 0.353\n",
"Speed: 0.1ms preprocess, 0.4ms inference, 0.0ms loss, 2.4ms postprocess per image\n",
"Results saved to \u001b[1m/workspace/runs/detect/runs/train/visdrone_vehicles\u001b[0m\n"
]
}
],
"source": [
"import torch\n",
"\n",
"# Detekce dostupného zařízení\n",
"if torch.cuda.is_available():\n",
" DEVICE = \"cuda\"\n",
"elif torch.backends.mps.is_available():\n",
" DEVICE = \"mps\"\n",
"else:\n",
" DEVICE = \"cpu\"\n",
"\n",
"print(f\"Trénink na: {DEVICE}\")\n",
"\n",
"results = model.train(\n",
" data=str(YAML),\n",
" epochs=50,\n",
" imgsz=640,\n",
" batch=16,\n",
" device=DEVICE,\n",
" name=\"visdrone_vehicles\",\n",
" project=\"runs/train\",\n",
" patience=10, # early stopping\n",
" save=True,\n",
" save_period=10,\n",
" val=True,\n",
" plots=True,\n",
" # Augmentace pro letecké snímky\n",
" degrees=15.0, # rotace\n",
" flipud=0.5, # vertikální flip\n",
" fliplr=0.5,\n",
" mosaic=1.0,\n",
" scale=0.5,\n",
")"
]
"outputs": [],
"source": "import torch\nfrom pathlib import Path\n\n# Detekce dostupného zařízení\nif torch.cuda.is_available():\n DEVICE = \"cuda\"\nelif torch.backends.mps.is_available():\n DEVICE = \"mps\"\nelse:\n DEVICE = \"cpu\"\n\nprint(f\"Trénink na: {DEVICE}\")\n\nresults = model.train(\n data=str(YAML),\n epochs=50,\n imgsz=640,\n batch=16,\n device=DEVICE,\n name=\"visdrone_vehicles\",\n project=str(Path(\"runs/train\").resolve()),\n patience=10, # early stopping\n save=True,\n save_period=10,\n val=True,\n plots=True,\n # Augmentace pro letecké snímky\n degrees=15.0, # rotace\n flipud=0.5, # vertikální flip\n fliplr=0.5,\n mosaic=1.0,\n scale=0.5,\n)"
},
{
"cell_type": "code",
@@ -475,241 +117,17 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Ultralytics 8.4.40 🚀 Python-3.11.10 torch-2.4.1+cu124 CUDA:0 (NVIDIA GeForce RTX 4090, 24210MiB)\n",
"Model summary (fused): 73 layers, 11,127,132 parameters, 0 gradients, 28.4 GFLOPs\n",
"\u001b[34m\u001b[1mval: \u001b[0mFast image access ✅ (ping: 0.3±0.2 ms, read: 97.7±33.9 MB/s, size: 126.7 KB)\n",
"\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 35/35 11.2it/s 3.1s\n",
" all 548 17040 0.651 0.465 0.515 0.344\n",
" car 515 14064 0.753 0.751 0.774 0.511\n",
" van 421 1975 0.604 0.369 0.426 0.286\n",
" truck 266 750 0.578 0.3 0.342 0.224\n",
" bus 131 251 0.667 0.44 0.518 0.354\n",
"Speed: 0.6ms preprocess, 1.3ms inference, 0.0ms loss, 0.6ms postprocess per image\n",
"Results saved to \u001b[1m/workspace/runs/detect/val\u001b[0m\n",
"\n",
"mAP50: 0.5151\n",
"mAP50-95: 0.3438\n",
" AP50[car]: 0.7742\n",
" AP50[van]: 0.4262\n",
" AP50[truck]: 0.3418\n",
" AP50[bus]: 0.5181\n"
]
}
],
"source": [
"# Validace nejlepšího modelu\n",
"best_weights = Path(\"runs/detect/runs/train/visdrone_vehicles/weights/best.pt\")\n",
"assert best_weights.exists(), \"Trénink ještě neproběhl nebo selhal\"\n",
"\n",
"model_best = YOLO(str(best_weights))\n",
"val_results = model_best.val(data=str(YAML), imgsz=640, split=\"val\")\n",
"\n",
"print(f\"\\nmAP50: {val_results.box.map50:.4f}\")\n",
"print(f\"mAP50-95: {val_results.box.map:.4f}\")\n",
"for i, cls in enumerate([\"car\", \"van\", \"truck\", \"bus\"]):\n",
" ap = val_results.box.ap50[i] if i < len(val_results.box.ap50) else float('nan')\n",
" print(f\" AP50[{cls}]: {ap:.4f}\")"
]
"outputs": [],
"source": "# Validace nejlepšího modelu\nbest_weights = Path(\"runs/train/visdrone_vehicles/weights/best.pt\")\nassert best_weights.exists(), \"Trénink ještě neproběhl nebo selhal\"\n\nmodel_best = YOLO(str(best_weights))\nval_results = model_best.val(data=str(YAML), imgsz=640, split=\"val\")\n\nprint(f\"\\nmAP50: {val_results.box.map50:.4f}\")\nprint(f\"mAP50-95: {val_results.box.map:.4f}\")\nfor i, cls in enumerate([\"car\", \"van\", \"truck\", \"bus\"]):\n ap = val_results.box.ap50[i] if i < len(val_results.box.ap50) else float('nan')\n print(f\" AP50[{cls}]: {ap:.4f}\")"
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Fine-tuning na: lanov/dataset.yaml\n",
"Ultralytics 8.4.40 🚀 Python-3.11.10 torch-2.4.1+cu124 CUDA:0 (NVIDIA GeForce RTX 4090, 24210MiB)\n",
"\u001b[34m\u001b[1mengine/trainer: \u001b[0magnostic_nms=False, amp=True, angle=1.0, augment=False, auto_augment=randaugment, batch=32, bgr=0.0, box=7.5, cache=False, cfg=None, classes=None, close_mosaic=10, cls=0.5, cls_pw=0.0, compile=False, conf=None, copy_paste=0.0, copy_paste_mode=flip, cos_lr=False, cutmix=0.0, data=lanov/dataset.yaml, degrees=10.0, deterministic=True, device=0, dfl=1.5, dnn=False, dropout=0.0, dynamic=False, embed=None, end2end=None, epochs=30, erasing=0.4, exist_ok=False, fliplr=0.5, flipud=0.5, format=torchscript, fraction=1.0, freeze=None, half=False, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, imgsz=256, int8=False, iou=0.7, keras=False, kobj=1.0, line_width=None, lr0=0.001, lrf=0.01, mask_ratio=4, max_det=300, mixup=0.0, mode=train, model=runs/detect/runs/train/visdrone_vehicles/weights/best.pt, momentum=0.937, mosaic=0.5, multi_scale=0.0, name=lanov_finetune-2, nbs=64, nms=False, opset=None, optimize=False, optimizer=auto, overlap_mask=True, patience=10, perspective=0.0, plots=True, pose=12.0, pretrained=True, profile=False, project=runs/detect/runs/train, rect=False, resume=False, retina_masks=False, rle=1.0, save=True, save_conf=False, save_crop=False, save_dir=/workspace/runs/detect/runs/detect/runs/train/lanov_finetune-2, save_frames=False, save_json=False, save_period=-1, save_txt=False, scale=0.5, seed=0, shear=0.0, show=False, show_boxes=True, show_conf=True, show_labels=True, simplify=True, single_cls=False, source=None, split=val, stream_buffer=False, task=detect, time=None, tracker=botsort.yaml, translate=0.1, val=True, verbose=True, vid_stride=1, visualize=False, warmup_bias_lr=0.1, warmup_epochs=3.0, warmup_momentum=0.8, weight_decay=0.0005, workers=8, workspace=None\n",
"\n",
" from n params module arguments \n",
" 0 -1 1 928 ultralytics.nn.modules.conv.Conv [3, 32, 3, 2] \n",
" 1 -1 1 18560 ultralytics.nn.modules.conv.Conv [32, 64, 3, 2] \n",
" 2 -1 1 29056 ultralytics.nn.modules.block.C2f [64, 64, 1, True] \n",
" 3 -1 1 73984 ultralytics.nn.modules.conv.Conv [64, 128, 3, 2] \n",
" 4 -1 2 197632 ultralytics.nn.modules.block.C2f [128, 128, 2, True] \n",
" 5 -1 1 295424 ultralytics.nn.modules.conv.Conv [128, 256, 3, 2] \n",
" 6 -1 2 788480 ultralytics.nn.modules.block.C2f [256, 256, 2, True] \n",
" 7 -1 1 1180672 ultralytics.nn.modules.conv.Conv [256, 512, 3, 2] \n",
" 8 -1 1 1838080 ultralytics.nn.modules.block.C2f [512, 512, 1, True] \n",
" 9 -1 1 656896 ultralytics.nn.modules.block.SPPF [512, 512, 5] \n",
" 10 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] \n",
" 11 [-1, 6] 1 0 ultralytics.nn.modules.conv.Concat [1] \n",
" 12 -1 1 591360 ultralytics.nn.modules.block.C2f [768, 256, 1] \n",
" 13 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] \n",
" 14 [-1, 4] 1 0 ultralytics.nn.modules.conv.Concat [1] \n",
" 15 -1 1 148224 ultralytics.nn.modules.block.C2f [384, 128, 1] \n",
" 16 -1 1 147712 ultralytics.nn.modules.conv.Conv [128, 128, 3, 2] \n",
" 17 [-1, 12] 1 0 ultralytics.nn.modules.conv.Concat [1] \n",
" 18 -1 1 493056 ultralytics.nn.modules.block.C2f [384, 256, 1] \n",
" 19 -1 1 590336 ultralytics.nn.modules.conv.Conv [256, 256, 3, 2] \n",
" 20 [-1, 9] 1 0 ultralytics.nn.modules.conv.Concat [1] \n",
" 21 -1 1 1969152 ultralytics.nn.modules.block.C2f [768, 512, 1] \n",
" 22 [15, 18, 21] 1 2117596 ultralytics.nn.modules.head.Detect [4, 16, None, [128, 256, 512]]\n",
"Model summary: 130 layers, 11,137,148 parameters, 11,137,132 gradients, 28.7 GFLOPs\n",
"\n",
"Transferred 355/355 items from pretrained weights\n",
"Freezing layer 'model.22.dfl.conv.weight'\n",
"\u001b[34m\u001b[1mAMP: \u001b[0mrunning Automatic Mixed Precision (AMP) checks...\n",
"\u001b[34m\u001b[1mAMP: \u001b[0mchecks passed ✅\n",
"\u001b[34m\u001b[1mtrain: \u001b[0mFast image access ✅ (ping: 0.3±0.1 ms, read: 7.1±1.5 MB/s, size: 19.3 KB)\n",
"\u001b[34m\u001b[1mtrain: \u001b[0mScanning /workspace/lanov/train/labels... 253 images, 50 backgrounds, 0 corrupt: 100% ━━━━━━━━━━━━ 253/253 750.0it/s 0.3s\n",
"\u001b[34m\u001b[1mtrain: \u001b[0mNew cache created: /workspace/lanov/train/labels.cache\n",
"\u001b[34m\u001b[1mval: \u001b[0mFast image access ✅ (ping: 0.2±0.0 ms, read: 4.8±2.1 MB/s, size: 14.6 KB)\n",
"\u001b[34m\u001b[1mval: \u001b[0mScanning /workspace/lanov/val/labels... 100 images, 50 backgrounds, 0 corrupt: 100% ━━━━━━━━━━━━ 100/100 470.1it/s 0.2s\n",
"\u001b[34m\u001b[1mval: \u001b[0mNew cache created: /workspace/lanov/val/labels.cache\n",
"\u001b[34m\u001b[1moptimizer:\u001b[0m 'optimizer=auto' found, ignoring 'lr0=0.001' and 'momentum=0.937' and determining best 'optimizer', 'lr0' and 'momentum' automatically... \n",
"\u001b[34m\u001b[1moptimizer:\u001b[0m AdamW(lr=0.00125, momentum=0.9) with parameter groups 57 weight(decay=0.0), 64 weight(decay=0.0005), 63 bias(decay=0.0)\n",
"Plotting labels to /workspace/runs/detect/runs/detect/runs/train/lanov_finetune-2/labels.jpg... \n",
"Image sizes 256 train, 256 val\n",
"Using 8 dataloader workers\n",
"Logging results to \u001b[1m/workspace/runs/detect/runs/detect/runs/train/lanov_finetune-2\u001b[0m\n",
"Starting training for 30 epochs...\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 1/30 1.46G 3.22 3.365 1.341 78 256: 100% ━━━━━━━━━━━━ 8/8 3.5it/s 2.3s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 2/2 6.8it/s 0.3s\n",
" all 100 271 0.248 0.142 0.114 0.035\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 2/30 1.5G 3.126 2.779 1.245 111 256: 100% ━━━━━━━━━━━━ 8/8 13.7it/s 0.6s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 2/2 14.2it/s 0.1s\n",
" all 100 271 0.17 0.261 0.165 0.054\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 3/30 1.5G 2.761 1.844 1.18 106 256: 100% ━━━━━━━━━━━━ 8/8 11.9it/s 0.7s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 2/2 11.8it/s 0.2s\n",
" all 100 271 0.47 0.289 0.187 0.0661\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 4/30 1.5G 2.577 1.633 1.037 167 256: 100% ━━━━━━━━━━━━ 8/8 11.6it/s 0.7s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 2/2 12.4it/s 0.2s\n",
" all 100 271 0.515 0.275 0.224 0.106\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 5/30 1.5G 2.505 1.658 1.056 60 256: 100% ━━━━━━━━━━━━ 8/8 11.8it/s 0.7s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 2/2 11.8it/s 0.2s\n",
" all 100 271 0.445 0.207 0.196 0.0749\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 6/30 1.5G 2.526 1.676 1.044 64 256: 100% ━━━━━━━━━━━━ 8/8 10.2it/s 0.8s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 2/2 11.9it/s 0.2s\n",
" all 100 271 0.822 0.146 0.128 0.0355\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 7/30 1.54G 2.4 1.562 0.999 97 256: 100% ━━━━━━━━━━━━ 8/8 11.9it/s 0.7s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 2/2 13.9it/s 0.1s\n",
" all 100 271 0.513 0.286 0.231 0.0919\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 8/30 1.54G 2.42 1.508 1.004 55 256: 100% ━━━━━━━━━━━━ 8/8 15.1it/s 0.5s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 2/2 13.2it/s 0.2s\n",
" all 100 271 0.53 0.303 0.206 0.0736\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 9/30 1.54G 2.415 1.494 1.013 82 256: 100% ━━━━━━━━━━━━ 8/8 10.8it/s 0.7s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 2/2 12.7it/s 0.2s\n",
" all 100 271 0.84 0.183 0.153 0.0401\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 10/30 1.54G 2.395 1.488 0.9924 73 256: 100% ━━━━━━━━━━━━ 8/8 12.5it/s 0.6s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 2/2 12.8it/s 0.2s\n",
" all 100 271 0.856 0.188 0.24 0.0599\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 11/30 1.54G 2.344 1.469 1.002 66 256: 100% ━━━━━━━━━━━━ 8/8 12.8it/s 0.6s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 2/2 12.6it/s 0.2s\n",
" all 100 271 0.235 0.297 0.234 0.0919\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 12/30 1.54G 2.487 1.468 0.9987 83 256: 100% ━━━━━━━━━━━━ 8/8 12.4it/s 0.6s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 2/2 15.0it/s 0.1s\n",
" all 100 271 0.52 0.176 0.179 0.0476\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 13/30 1.54G 2.391 1.43 1.03 137 256: 100% ━━━━━━━━━━━━ 8/8 6.2it/s 1.3s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 2/2 4.9it/s 0.4s\n",
" all 100 271 0.194 0.374 0.203 0.0596\n",
"\n",
" Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size\n",
" 14/30 1.54G 2.343 1.411 1.012 102 256: 100% ━━━━━━━━━━━━ 8/8 6.1it/s 1.3s\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 2/2 10.9it/s 0.2s\n",
" all 100 271 0.531 0.183 0.195 0.0581\n",
"\u001b[34m\u001b[1mEarlyStopping: \u001b[0mTraining stopped early as no improvement observed in last 10 epochs. Best results observed at epoch 4, best model saved as best.pt.\n",
"To update EarlyStopping(patience=10) pass a new patience value, i.e. `patience=300` or use `patience=0` to disable EarlyStopping.\n",
"\n",
"14 epochs completed in 0.008 hours.\n",
"Optimizer stripped from /workspace/runs/detect/runs/detect/runs/train/lanov_finetune-2/weights/last.pt, 22.5MB\n",
"Optimizer stripped from /workspace/runs/detect/runs/detect/runs/train/lanov_finetune-2/weights/best.pt, 22.5MB\n",
"\n",
"Validating /workspace/runs/detect/runs/detect/runs/train/lanov_finetune-2/weights/best.pt...\n",
"Ultralytics 8.4.40 🚀 Python-3.11.10 torch-2.4.1+cu124 CUDA:0 (NVIDIA GeForce RTX 4090, 24210MiB)\n",
"Model summary (fused): 73 layers, 11,127,132 parameters, 0 gradients, 28.4 GFLOPs\n",
" Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 2/2 12.2it/s 0.2s\n",
" all 100 271 0.514 0.275 0.224 0.106\n",
" car 48 262 0.233 0.576 0.376 0.0984\n",
" van 5 5 1 0 0.0162 0.00943\n",
" truck 4 4 0.308 0.25 0.279 0.211\n",
"Speed: 0.0ms preprocess, 0.1ms inference, 0.0ms loss, 0.4ms postprocess per image\n",
"Results saved to \u001b[1m/workspace/runs/detect/runs/detect/runs/train/lanov_finetune-2\u001b[0m\n",
"Lánov fine-tuning hotov. Nejlepší váhy: /workspace/runs/detect/runs/detect/runs/train/lanov_finetune-2/weights/best.pt\n"
]
}
],
"source": [
"import zipfile\n",
"from pathlib import Path\n",
"\n",
"LANOV_ZIP = Path('dataset_lanov.zip')\n",
"LANOV_YAML = Path('lanov/dataset.yaml')\n",
"\n",
"# Rozbal zip pokud yaml ještě není\n",
"if LANOV_ZIP.exists() and not LANOV_YAML.exists():\n",
" print('Rozbaluji dataset_lanov.zip ...')\n",
" with zipfile.ZipFile(LANOV_ZIP) as zf:\n",
" zf.extractall('.')\n",
" print('Hotovo.')\n",
"\n",
"if not LANOV_YAML.exists():\n",
" print('Lánov dataset nenalezen — fine-tuning přeskočen.')\n",
" print('Spusť prepare_dataset.py nebo nahraj dataset_lanov.zip.')\n",
"else:\n",
" print(f'Fine-tuning na: {LANOV_YAML}')\n",
"\n",
" lanov_model = YOLO(str(best_weights)) # navazuje na VisDrone trénink\n",
"\n",
" lanov_results = lanov_model.train(\n",
" data=str(LANOV_YAML),\n",
" epochs=30,\n",
" imgsz=256,\n",
" batch=32,\n",
" device=DEVICE,\n",
" name='lanov_finetune',\n",
" project='runs/detect/runs/train',\n",
" patience=10,\n",
" save=True,\n",
" val=True,\n",
" plots=True,\n",
" degrees=10.0,\n",
" flipud=0.5,\n",
" fliplr=0.5,\n",
" mosaic=0.5,\n",
" lr0=0.001, # nižší LR pro fine-tuning\n",
" )\n",
"\n",
" best_weights = Path(lanov_results.save_dir) / 'weights' / 'best.pt'\n",
" print(f'Lánov fine-tuning hotov. Nejlepší váhy: {best_weights}')\n"
]
"outputs": [],
"source": "import zipfile\nimport shutil\nfrom pathlib import Path\n\nLANOV_ZIP = Path('dataset_lanov.zip')\nLANOV_YAML = Path('lanov/dataset.yaml')\n\n# Rozbal zip pokud yaml ještě není\nif LANOV_ZIP.exists() and not LANOV_YAML.exists():\n print('Rozbaluji dataset_lanov.zip ...')\n with zipfile.ZipFile(LANOV_ZIP) as zf:\n zf.extractall('.')\n print('Hotovo.')\n\nif not LANOV_YAML.exists():\n print('Lánov dataset nenalezen — fine-tuning přeskočen.')\n print('Spusť prepare_dataset.py nebo nahraj dataset_lanov.zip.')\nelse:\n print(f'Fine-tuning na: {LANOV_YAML}')\n\n # Záloha modelu před fine-tuningem\n backup = best_weights.parent / 'best_before_finetune.pt'\n shutil.copy(best_weights, backup)\n print(f'Záloha uložena: {backup}')\n\n lanov_model = YOLO(str(best_weights)) # navazuje na VisDrone trénink\n\n lanov_results = lanov_model.train(\n data=str(LANOV_YAML),\n epochs=30,\n imgsz=256,\n batch=32,\n device=DEVICE,\n name='lanov_finetune',\n project=str(Path(\"runs/train\").resolve()),\n patience=10,\n save=True,\n val=True,\n plots=True,\n degrees=10.0,\n flipud=0.5,\n fliplr=0.5,\n mosaic=0.5,\n lr0=0.001, # nižší LR pro fine-tuning\n )\n\n best_weights = Path(lanov_results.save_dir) / 'weights' / 'best.pt'\n print(f'Lánov fine-tuning hotov. Nejlepší váhy: {best_weights}')"
},
{
"cell_type": "code",
@@ -766,4 +184,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
}
}

BIN
best_before_finetune.pt Normal file

Binary file not shown.

Binary file not shown.

107
map.html
View File

@@ -4,7 +4,8 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HK Aerial — Detekce vozidel</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
<script src="https://unpkg.com/maplibre-gl@4.7.1/dist/maplibre-gl.js"></script>
<link href="https://unpkg.com/maplibre-gl@4.7.1/dist/maplibre-gl.css" rel="stylesheet" />
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
@@ -70,61 +71,93 @@
</div>
<div class="info-box">
Zoom 1419 &nbsp;|&nbsp; Dlaždice: 256×256 px, z=18
WebGL &nbsp;|&nbsp; Zoom 1419 &nbsp;|&nbsp; Dlaždice: 256×256 px, z=18
</div>
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<script>
const map = L.map('map', {
center: [50.208, 15.836],
const base = window.location.origin;
const map = new maplibregl.Map({
container: 'map',
style: {
version: 8,
glyphs: 'https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf',
sources: {
osm: {
type: 'raster',
tiles: [
'https://a.tile.openstreetmap.org/{z}/{x}/{y}.png',
'https://b.tile.openstreetmap.org/{z}/{x}/{y}.png',
'https://c.tile.openstreetmap.org/{z}/{x}/{y}.png'
],
tileSize: 256,
attribution: '© OpenStreetMap contributors',
maxzoom: 19
},
tiles: {
type: 'raster',
tiles: [`${base}/tiles/{z}/{x}/{y}.jpg`],
tileSize: 256,
minzoom: 13,
maxzoom: 18,
attribution: 'Letecké snímky HK'
},
annotated: {
type: 'raster',
tiles: [`${base}/tiles_annotated/{z}/{x}/{y}.jpg`],
tileSize: 256,
minzoom: 13,
maxzoom: 18,
attribution: 'Anotované snímky HK'
}
},
layers: [
{
id: 'osm-layer',
type: 'raster',
source: 'osm',
layout: { visibility: 'none' }
},
{
id: 'tiles-layer',
type: 'raster',
source: 'tiles',
layout: { visibility: 'none' }
},
{
id: 'annotated-layer',
type: 'raster',
source: 'annotated',
layout: { visibility: 'visible' }
}
]
},
center: [15.836, 50.208],
zoom: 16,
minZoom: 13,
maxZoom: 19
});
// Base layers
const osm = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors',
maxZoom: 19
});
map.addControl(new maplibregl.NavigationControl(), 'bottom-right');
map.addControl(new maplibregl.ScaleControl({ unit: 'metric' }), 'bottom-right');
// Custom tile layers — tiles named as "{z}_{x}_{y}.jpg"
const tilesLayer = L.tileLayer('tiles/18_{x}_{y}.jpg', {
minNativeZoom: 18,
maxNativeZoom: 18,
minZoom: 13,
maxZoom: 19,
tileSize: 256,
errorTileUrl: 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
attribution: 'Letecké snímky HK'
});
const layerIds = {
osm: 'osm-layer',
tiles: 'tiles-layer',
annotated: 'annotated-layer'
};
const annotatedLayer = L.tileLayer('tiles_annotated/18_{x}_{y}.jpg', {
minNativeZoom: 18,
maxNativeZoom: 18,
minZoom: 13,
maxZoom: 19,
tileSize: 256,
errorTileUrl: 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
attribution: 'Anotované snímky HK'
});
// Start with annotated layer
annotatedLayer.addTo(map);
const layers = { osm, tiles: tilesLayer, annotated: annotatedLayer };
let current = 'annotated';
function setLayer(name) {
if (name === current) return;
map.removeLayer(layers[current]);
map.addLayer(layers[name]);
map.setLayoutProperty(layerIds[current], 'visibility', 'none');
map.setLayoutProperty(layerIds[name], 'visibility', 'visible');
current = name;
document.querySelectorAll('.layer-toggle button').forEach(b => b.classList.remove('active'));
document.getElementById('btn-' + name).classList.add('active');
}
// Keyboard shortcut: 1/2/3 to switch layers
document.addEventListener('keydown', e => {
if (e.key === '1') setLayer('osm');
if (e.key === '2') setLayer('tiles');

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 MiB

73
serve.py Executable file
View File

@@ -0,0 +1,73 @@
#!/usr/bin/env python3
"""Local tile server for HK aerial map. Translates /tiles/{z}/{x}/{y}.jpg -> tiles/18_{x}_{y}.jpg"""
import http.server
import socketserver
import os
import re
import webbrowser
import threading
from pathlib import Path
PORT = 8080
SCRIPT_DIR = Path(__file__).parent
TRANSPARENT_GIF = (
b'GIF89a\x01\x00\x01\x00\x80\x00\x00\xff\xff\xff\x00\x00\x00'
b'!\xf9\x04\x00\x00\x00\x00\x00,\x00\x00\x00\x00\x01\x00\x01'
b'\x00\x00\x02\x02D\x01\x00;'
)
TILE_PATTERN = re.compile(
r'^/(tiles(?:_annotated)?)/(\d+)/(\d+)/(\d+)\.(jpg|png|gif)$'
)
class Handler(http.server.SimpleHTTPRequestHandler):
def do_GET(self):
path = self.path.split('?')[0]
m = TILE_PATTERN.match(path)
if m:
layer, z, x, y, ext = m.groups()
# Tiles are stored as 18_x_y.jpg regardless of requested zoom
flat = SCRIPT_DIR / layer / f'18_{x}_{y}.jpg'
if flat.exists():
data = flat.read_bytes()
self.send_response(200)
self.send_header('Content-Type', 'image/jpeg')
self.send_header('Content-Length', len(data))
self.send_header('Cache-Control', 'public, max-age=3600')
self.end_headers()
self.wfile.write(data)
else:
self.send_response(200)
self.send_header('Content-Type', 'image/gif')
self.send_header('Content-Length', len(TRANSPARENT_GIF))
self.end_headers()
self.wfile.write(TRANSPARENT_GIF)
return
super().do_GET()
def log_message(self, fmt, *args):
# Only log non-tile requests so output stays readable
if not TILE_PATTERN.match(self.path.split('?')[0]):
print(f' {self.address_string()} {fmt % args}')
def main():
os.chdir(SCRIPT_DIR)
with socketserver.TCPServer(('', PORT), Handler) as httpd:
httpd.allow_reuse_address = True
url = f'http://localhost:{PORT}/map.html'
print(f'HK Aerial Map → {url}')
print('Press Ctrl+C to stop.\n')
threading.Timer(0.4, webbrowser.open, args=(url,)).start()
try:
httpd.serve_forever()
except KeyboardInterrupt:
print('\nServer stopped.')
if __name__ == '__main__':
main()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB