48 KiB
48 KiB
In [1]:
!pip install -q ultralytics[2K [90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m [32m1.2/1.2 MB[0m [31m20.6 MB/s[0m eta [36m0:00:00[0ma [36m0:00:01[0m [?25h
In [2]:
import os
BASE_PATH = "/kaggle/input/datasets/thedatasith/sku110k-annotations"
DATASET_FOLDER = None
# find SKU110K_fixed folder
for item in os.listdir(BASE_PATH):
if "SKU110K" in item:
DATASET_FOLDER = os.path.join(BASE_PATH, item)
break
print("📁 Dataset folder:", DATASET_FOLDER)
for root, dirs, files in os.walk(DATASET_FOLDER):
level = root.replace(DATASET_FOLDER, '').count(os.sep)
indent = ' ' * 2 * level
print(f"{indent}📁 {os.path.basename(root)}/")
for f in files[:5]:
print(f"{indent} 📄 {f}")
if level >= 2:
break📁 Dataset folder: /kaggle/input/datasets/thedatasith/sku110k-annotations/SKU110K_fixed
📁 SKU110K_fixed/
📁 labels/
📁 val/
📄 val_30.txt
📄 val_216.txt
📄 val_16.txt
📄 val_499.txt
📄 val_180.txt
In [3]:
import yaml
YAML_PATH = BASE_PATH + "/data_kaggle.yaml"
with open(YAML_PATH, "r") as f:
data = yaml.safe_load(f)
print("Classes:", data.get("names"))
print("Number of classes:", len(data.get("names", [])))
print("Train path:", data.get("train"))
print("Val path:", data.get("val"))Classes: ['object'] Number of classes: 1 Train path: train Val path: val
In [4]:
import yaml
YAML_PATH = BASE_PATH + "/data_kaggle.yaml"
with open(YAML_PATH, "r") as f:
data = yaml.safe_load(f)
# 🔧 FIX PATHS
data["train"] = DATASET_FOLDER + "/images/train"
data["val"] = DATASET_FOLDER + "/images/val"
# save fixed yaml
FIXED_YAML_PATH = "/kaggle/working/fixed_data.yaml"
with open(FIXED_YAML_PATH, "w") as f:
yaml.dump(data, f)
print("✅ Fixed YAML saved at:", FIXED_YAML_PATH)
print(data)✅ Fixed YAML saved at: /kaggle/working/fixed_data.yaml
{'path': '/kaggle/input/sku110k-annotations/SKU110K_fixed/images', 'train': '/kaggle/input/datasets/thedatasith/sku110k-annotations/SKU110K_fixed/images/train', 'val': '/kaggle/input/datasets/thedatasith/sku110k-annotations/SKU110K_fixed/images/val', 'test': 'test', 'nc': 1, 'names': ['object']}
In [10]:
import torch
import numpy
from ultralytics import YOLO
print(torch.cuda.get_device_name(0))
print("GPU:", torch.cuda.get_device_name(0) if torch.cuda.is_available() else "None")
print(torch.cuda.get_device_capability(0))
model = YOLO('yolov8n.pt')
model.train(
device='0',
data=FIXED_YAML_PATH,
epochs=30,
imgsz=800,
batch=-1, # Automatically finas largest batch that fits in memory.
workers=4,
optimizer="AdamW",
lr0=0.002,
patience=10,
save_period=5,
project="kaggle/working/runs",
name="exp",
save=True
)Tesla T4
GPU: Tesla T4
(7, 5)
Ultralytics 8.4.46 🚀 Python-3.12.12 torch-2.10.0+cu128 CUDA:0 (Tesla T4, 14913MiB)
[34m[1mengine/trainer: [0magnostic_nms=False, amp=True, angle=1.0, augment=False, auto_augment=randaugment, batch=-1, 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=/kaggle/working/fixed_data.yaml, degrees=0.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.0, format=torchscript, fraction=1.0, freeze=None, half=False, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, imgsz=800, int8=False, iou=0.7, keras=False, kobj=1.0, line_width=None, lr0=0.002, lrf=0.01, mask_ratio=4, max_det=300, mixup=0.0, mode=train, model=yolov8n.pt, momentum=0.937, mosaic=1.0, multi_scale=0.0, name=exp-6, nbs=64, nms=False, opset=None, optimize=False, optimizer=AdamW, overlap_mask=True, patience=10, perspective=0.0, plots=True, pose=12.0, pretrained=True, profile=False, project=kaggle/working/runs, rect=False, resume=False, retina_masks=False, rle=1.0, save=True, save_conf=False, save_crop=False, save_dir=/kaggle/working/runs/detect/kaggle/working/runs/exp-6, save_frames=False, save_json=False, save_period=5, 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=4, workspace=None
Overriding model.yaml nc=80 with nc=1
from n params module arguments
0 -1 1 464 ultralytics.nn.modules.conv.Conv [3, 16, 3, 2]
1 -1 1 4672 ultralytics.nn.modules.conv.Conv [16, 32, 3, 2]
2 -1 1 7360 ultralytics.nn.modules.block.C2f [32, 32, 1, True]
3 -1 1 18560 ultralytics.nn.modules.conv.Conv [32, 64, 3, 2]
4 -1 2 49664 ultralytics.nn.modules.block.C2f [64, 64, 2, True]
5 -1 1 73984 ultralytics.nn.modules.conv.Conv [64, 128, 3, 2]
6 -1 2 197632 ultralytics.nn.modules.block.C2f [128, 128, 2, True]
7 -1 1 295424 ultralytics.nn.modules.conv.Conv [128, 256, 3, 2]
8 -1 1 460288 ultralytics.nn.modules.block.C2f [256, 256, 1, True]
9 -1 1 164608 ultralytics.nn.modules.block.SPPF [256, 256, 5]
10 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest']
11 [-1, 6] 1 0 ultralytics.nn.modules.conv.Concat [1]
12 -1 1 148224 ultralytics.nn.modules.block.C2f [384, 128, 1]
13 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest']
14 [-1, 4] 1 0 ultralytics.nn.modules.conv.Concat [1]
15 -1 1 37248 ultralytics.nn.modules.block.C2f [192, 64, 1]
16 -1 1 36992 ultralytics.nn.modules.conv.Conv [64, 64, 3, 2]
17 [-1, 12] 1 0 ultralytics.nn.modules.conv.Concat [1]
18 -1 1 123648 ultralytics.nn.modules.block.C2f [192, 128, 1]
19 -1 1 147712 ultralytics.nn.modules.conv.Conv [128, 128, 3, 2]
20 [-1, 9] 1 0 ultralytics.nn.modules.conv.Concat [1]
21 -1 1 493056 ultralytics.nn.modules.block.C2f [384, 256, 1]
22 [15, 18, 21] 1 751507 ultralytics.nn.modules.head.Detect [1, 16, None, [64, 128, 256]]
Model summary: 130 layers, 3,011,043 parameters, 3,011,027 gradients, 8.2 GFLOPs
Transferred 319/355 items from pretrained weights
Freezing layer 'model.22.dfl.conv.weight'
[34m[1mAMP: [0mrunning Automatic Mixed Precision (AMP) checks...
[34m[1mAMP: [0mchecks passed ✅
[34m[1mtrain: [0mFast image access ✅ (ping: 0.0±0.0 ms, read: 1622.5±338.4 MB/s, size: 1055.7 KB)
[K[34m[1mtrain: [0mScanning /kaggle/input/datasets/thedatasith/sku110k-annotations/SKU110K_fixed/labels/train... 8185 images, 0 backgrounds, 0 corrupt: 100% ━━━━━━━━━━━━ 8185/8185 530.6it/s 15.4s<0.0s
[34m[1mtrain: [0m/kaggle/input/datasets/thedatasith/sku110k-annotations/SKU110K_fixed/images/train/train_1797.jpg: 3 duplicate labels removed
WARNING ⚠️ [34m[1mtrain: [0mCache directory /kaggle/input/datasets/thedatasith/sku110k-annotations/SKU110K_fixed/labels is not writable, cache not saved.
[34m[1malbumentations: [0mBlur(p=0.01, blur_limit=(3, 7)), MedianBlur(p=0.01, blur_limit=(3, 7)), ToGray(p=0.01, method='weighted_average', num_output_channels=3), CLAHE(p=0.01, clip_limit=(1.0, 4.0), tile_grid_size=(8, 8))
[34m[1mAutoBatch: [0mComputing optimal batch size for imgsz=800 at 60.0% CUDA memory utilization.
[34m[1mAutoBatch: [0mCUDA:0 (Tesla T4) 14.56G total, 14.06G reserved, 4.27G allocated, -3.77G free
Params GFLOPs GPU_mem (GB) forward (ms) backward (ms) input output
3011043 12.8 0.742 25.48 nan (1, 3, 800, 800) list
3011043 25.61 1.407 22.69 nan (2, 3, 800, 800) list
3011043 51.21 2.533 20.66 nan (4, 3, 800, 800) list
3011043 102.4 4.647 31.35 nan (8, 3, 800, 800) list
3011043 204.9 8.993 67.12 nan (16, 3, 800, 800) list
WARNING ⚠️ [34m[1mAutoBatch: [0mbatch=-4 outside safe range, using default batch-size 16.
[34m[1mAutoBatch: [0mUsing batch-size 16 for CUDA:0 27.35G/14.56G (188%) ✅
[34m[1mtrain: [0mFast image access ✅ (ping: 0.0±0.0 ms, read: 1226.3±337.2 MB/s, size: 909.7 KB)
[K[34m[1mtrain: [0mScanning /kaggle/input/datasets/thedatasith/sku110k-annotations/SKU110K_fixed/labels/train... 8185 images, 0 backgrounds, 0 corrupt: 100% ━━━━━━━━━━━━ 8185/8185 690.8it/s 11.8s<0.0s
[34m[1mtrain: [0m/kaggle/input/datasets/thedatasith/sku110k-annotations/SKU110K_fixed/images/train/train_1797.jpg: 3 duplicate labels removed
WARNING ⚠️ [34m[1mtrain: [0mCache directory /kaggle/input/datasets/thedatasith/sku110k-annotations/SKU110K_fixed/labels is not writable, cache not saved.
[34m[1malbumentations: [0mBlur(p=0.01, blur_limit=(3, 7)), MedianBlur(p=0.01, blur_limit=(3, 7)), ToGray(p=0.01, method='weighted_average', num_output_channels=3), CLAHE(p=0.01, clip_limit=(1.0, 4.0), tile_grid_size=(8, 8))
[34m[1mval: [0mFast image access ✅ (ping: 0.0±0.0 ms, read: 645.9±321.3 MB/s, size: 1108.0 KB)
[K[34m[1mval: [0mScanning /kaggle/input/datasets/thedatasith/sku110k-annotations/SKU110K_fixed/labels/val... 584 images, 0 backgrounds, 0 corrupt: 100% ━━━━━━━━━━━━ 584/584 471.5it/s 1.2s0.0s
WARNING ⚠️ [34m[1mval: [0mCache directory /kaggle/input/datasets/thedatasith/sku110k-annotations/SKU110K_fixed/labels is not writable, cache not saved.
[34m[1moptimizer:[0m AdamW(lr=0.002, momentum=0.937) with parameter groups 57 weight(decay=0.0), 64 weight(decay=0.0005), 63 bias(decay=0.0)
Plotting labels to /kaggle/working/runs/detect/kaggle/working/runs/exp-6/labels.jpg...
Image sizes 800 train, 800 val
Using 2 dataloader workers
Logging results to [1m/kaggle/working/runs/detect/kaggle/working/runs/exp-6[0m
Starting training for 50 epochs...
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 1/50 9.3G 1.622 1.023 1.113 2446 800: 100% ━━━━━━━━━━━━ 512/512 1.8it/s 4:46<0.4s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.6it/s 12.2s0.7s
all 584 90456 0.822 0.693 0.758 0.425
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 2/50 14G 1.515 0.817 1.063 2277 800: 100% ━━━━━━━━━━━━ 512/512 1.8it/s 4:42<0.4s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.6it/s 11.8s0.7s
all 584 90456 0.851 0.77 0.82 0.476
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 3/50 12.3G 1.479 0.7712 1.048 2172 800: 100% ━━━━━━━━━━━━ 512/512 1.8it/s 4:40<0.4s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.7it/s 11.1s0.6s
all 584 90456 0.853 0.757 0.81 0.475
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 4/50 9.78G 1.459 0.748 1.042 1688 800: 100% ━━━━━━━━━━━━ 512/512 1.8it/s 4:47<0.4s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.6it/s 11.6s0.7s
all 584 90456 0.849 0.775 0.827 0.484
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 5/50 9.12G 1.451 0.7335 1.036 3278 800: 100% ━━━━━━━━━━━━ 512/512 1.8it/s 4:45<0.4s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.7it/s 11.1s0.6s
all 584 90456 0.872 0.788 0.842 0.497
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 6/50 12.6G 1.433 0.7175 1.031 1835 800: 100% ━━━━━━━━━━━━ 512/512 1.8it/s 4:52<0.4s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.6it/s 11.6s0.6s
all 584 90456 0.881 0.802 0.853 0.511
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 7/50 12.5G 1.422 0.7049 1.025 1625 800: 100% ━━━━━━━━━━━━ 512/512 1.7it/s 4:58<0.4s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.6it/s 11.6s0.7s
all 584 90456 0.879 0.81 0.859 0.511
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 8/50 13.5G 1.415 0.699 1.023 2169 800: 100% ━━━━━━━━━━━━ 512/512 1.8it/s 4:52<0.4s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.5it/s 12.5s0.7s
all 584 90456 0.883 0.792 0.849 0.511
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 9/50 10.9G 1.409 0.6911 1.019 2703 800: 100% ━━━━━━━━━━━━ 512/512 1.8it/s 4:50<0.4s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.5it/s 12.5s0.7s
all 584 90456 0.89 0.816 0.865 0.525
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 10/50 10.1G 1.404 0.6845 1.018 2094 800: 100% ━━━━━━━━━━━━ 512/512 1.8it/s 4:49<0.4s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.7it/s 11.5s0.6s
all 584 90456 0.885 0.817 0.867 0.524
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 11/50 11.5G 1.394 0.6736 1.015 2164 800: 100% ━━━━━━━━━━━━ 512/512 1.8it/s 4:48<0.4s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.6it/s 11.9s0.6s
all 584 90456 0.89 0.814 0.866 0.526
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 12/50 10G 1.395 0.6753 1.016 2302 800: 100% ━━━━━━━━━━━━ 512/512 1.8it/s 4:46<0.4s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.7it/s 11.1s0.6s
all 584 90456 0.89 0.819 0.874 0.529
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 13/50 11.4G 1.389 0.6684 1.011 1912 800: 100% ━━━━━━━━━━━━ 512/512 1.8it/s 4:47<0.4s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.6it/s 12.0s0.7s
all 584 90456 0.893 0.823 0.875 0.531
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 14/50 11.5G 1.386 0.6636 1.011 1621 800: 100% ━━━━━━━━━━━━ 512/512 1.8it/s 4:45<0.3s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.7it/s 11.1s0.6s
all 584 90456 0.895 0.825 0.875 0.533
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 15/50 10.3G 1.385 0.6615 1.012 1877 800: 100% ━━━━━━━━━━━━ 512/512 1.8it/s 4:45<0.4s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.6it/s 12.0s0.7s
all 584 90456 0.895 0.826 0.878 0.534
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 16/50 10.2G 1.379 0.6564 1.009 1694 800: 100% ━━━━━━━━━━━━ 512/512 1.8it/s 4:46<0.4s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.6it/s 11.5s0.6s
all 584 90456 0.895 0.821 0.876 0.534
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 17/50 13.7G 1.372 0.6501 1.008 1779 800: 100% ━━━━━━━━━━━━ 512/512 1.8it/s 4:43<0.4s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.7it/s 11.1s0.6s
all 584 90456 0.902 0.825 0.879 0.539
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 18/50 8.65G 1.371 0.6494 1.004 1915 800: 100% ━━━━━━━━━━━━ 512/512 1.8it/s 4:41<0.4s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.6it/s 11.5s0.6s
all 584 90456 0.896 0.826 0.878 0.539
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 19/50 12.3G 1.372 0.6459 1.005 1668 800: 100% ━━━━━━━━━━━━ 512/512 1.8it/s 4:44<0.4s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.6it/s 11.6s0.7s
all 584 90456 0.898 0.826 0.879 0.541
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 20/50 12.9G 1.369 0.6451 1.006 2292 800: 100% ━━━━━━━━━━━━ 512/512 1.8it/s 4:42<0.4s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.7it/s 11.2s0.7s
all 584 90456 0.896 0.831 0.88 0.54
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 21/50 12G 1.369 0.644 1.003 1722 800: 100% ━━━━━━━━━━━━ 512/512 1.8it/s 4:41<0.3s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.6it/s 11.7s0.8s
all 584 90456 0.903 0.827 0.881 0.541
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 22/50 9.84G 1.363 0.6361 0.9997 2757 800: 100% ━━━━━━━━━━━━ 512/512 1.8it/s 4:43<0.4s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.6it/s 11.7s0.6s
all 584 90456 0.902 0.833 0.886 0.545
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 23/50 13.7G 1.362 0.6348 0.9999 2388 800: 100% ━━━━━━━━━━━━ 512/512 1.8it/s 4:41<0.4s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.6it/s 11.6s0.6s
all 584 90456 0.901 0.83 0.882 0.545
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 24/50 11.1G 1.362 0.6353 1 2284 800: 100% ━━━━━━━━━━━━ 512/512 1.8it/s 4:39<0.4s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.6it/s 11.8s0.7s
all 584 90456 0.901 0.838 0.882 0.545
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 25/50 9.52G 1.36 0.6314 0.9987 1620 800: 100% ━━━━━━━━━━━━ 512/512 1.8it/s 4:39<0.4s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.7it/s 11.1s0.7s
all 584 90456 0.903 0.837 0.882 0.546
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 26/50 11.4G 1.356 0.6293 0.9977 2145 800: 100% ━━━━━━━━━━━━ 512/512 1.8it/s 4:45<0.4s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.6it/s 11.9s0.6s
all 584 90456 0.902 0.835 0.884 0.547
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 27/50 11.8G 1.353 0.6294 0.9982 2334 800: 100% ━━━━━━━━━━━━ 512/512 1.8it/s 4:40<0.4s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.7it/s 11.5s0.6s
all 584 90456 0.902 0.838 0.89 0.55
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 28/50 14.3G 1.35 0.6254 0.9954 2831 800: 100% ━━━━━━━━━━━━ 512/512 1.8it/s 4:42<0.4s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.6it/s 12.0s0.7s
all 584 90456 0.902 0.839 0.89 0.548
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 29/50 11.6G 1.348 0.6233 0.9973 2048 800: 100% ━━━━━━━━━━━━ 512/512 1.8it/s 4:43<0.4s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.7it/s 11.5s0.6s
all 584 90456 0.903 0.839 0.889 0.55
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 30/50 13G 1.347 0.6208 0.9952 1730 800: 100% ━━━━━━━━━━━━ 512/512 1.8it/s 4:46<0.4s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.7it/s 11.5s0.7s
all 584 90456 0.904 0.839 0.892 0.551
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 31/50 13.9G 1.345 0.6187 0.9946 1832 800: 100% ━━━━━━━━━━━━ 512/512 1.8it/s 4:46<0.3s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.7it/s 11.2s0.7s
all 584 90456 0.909 0.836 0.891 0.551
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 32/50 12.3G 1.35 0.6191 0.9955 2375 800: 100% ━━━━━━━━━━━━ 512/512 1.8it/s 4:40<0.4s
[K Class Images Instances Box(P R mAP50 mAP50-95): 100% ━━━━━━━━━━━━ 19/19 1.7it/s 11.3s0.6s
all 584 90456 0.904 0.842 0.892 0.553
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
[K 33/50 8.47G 1.313 0.6057 0.9904 3858 800: 3% ──────────── 17/512 1.8it/s 8.8s<4:29
Exception in thread Thread-37 (_pin_memory_loop): Traceback (most recent call last): File "/usr/lib/python3.12/threading.py", line 1075, in _bootstrap_inner
[0;31m---------------------------------------------------------------------------[0m
[0;31mKeyboardInterrupt[0m Traceback (most recent call last)
[0;32m/tmp/ipykernel_57/2567830867.py[0m in [0;36m<cell line: 0>[0;34m()[0m
[1;32m 8[0m [0;34m[0m[0m
[1;32m 9[0m [0mmodel[0m [0;34m=[0m [0mYOLO[0m[0;34m([0m[0;34m'yolov8n.pt'[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m
[0;32m---> 10[0;31m model.train(
[0m[1;32m 11[0m [0mdevice[0m[0;34m=[0m[0;34m'0'[0m[0;34m,[0m[0;34m[0m[0;34m[0m[0m
[1;32m 12[0m [0mdata[0m[0;34m=[0m[0mFIXED_YAML_PATH[0m[0;34m,[0m[0;34m[0m[0;34m[0m[0m
[0;32m/usr/local/lib/python3.12/dist-packages/ultralytics/engine/model.py[0m in [0;36mtrain[0;34m(self, trainer, **kwargs)[0m
[1;32m 790[0m [0mself[0m[0;34m.[0m[0mmodel[0m [0;34m=[0m [0mself[0m[0;34m.[0m[0mtrainer[0m[0;34m.[0m[0mmodel[0m[0;34m[0m[0;34m[0m[0m
[1;32m 791[0m [0;34m[0m[0m
[0;32m--> 792[0;31m [0mself[0m[0;34m.[0m[0mtrainer[0m[0;34m.[0m[0mtrain[0m[0;34m([0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m
[0m[1;32m 793[0m [0;31m# Update model and cfg after training[0m[0;34m[0m[0;34m[0m[0m
[1;32m 794[0m [0;32mif[0m [0mRANK[0m [0;32min[0m [0;34m{[0m[0;34m-[0m[0;36m1[0m[0;34m,[0m [0;36m0[0m[0;34m}[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m
[0;32m/usr/local/lib/python3.12/dist-packages/ultralytics/engine/trainer.py[0m in [0;36mtrain[0;34m(self)[0m
[1;32m 244[0m [0;34m[0m[0m
[1;32m 245[0m [0;32melse[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m
[0;32m--> 246[0;31m [0mself[0m[0;34m.[0m[0m_do_train[0m[0;34m([0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m
[0m[1;32m 247[0m [0;34m[0m[0m
[1;32m 248[0m [0;32mdef[0m [0m_setup_scheduler[0m[0;34m([0m[0mself[0m[0;34m)[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m
[0;32m/usr/local/lib/python3.12/dist-packages/ultralytics/engine/trainer.py[0m in [0;36m_do_train[0;34m(self)[0m
[1;32m 437[0m [0mloss[0m[0;34m,[0m [0mself[0m[0;34m.[0m[0mloss_items[0m [0;34m=[0m [0munwrap_model[0m[0;34m([0m[0mself[0m[0;34m.[0m[0mmodel[0m[0;34m)[0m[0;34m.[0m[0mloss[0m[0;34m([0m[0mbatch[0m[0;34m,[0m [0mpreds[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m
[1;32m 438[0m [0;32melse[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m
[0;32m--> 439[0;31m [0mloss[0m[0;34m,[0m [0mself[0m[0;34m.[0m[0mloss_items[0m [0;34m=[0m [0mself[0m[0;34m.[0m[0mmodel[0m[0;34m([0m[0mbatch[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m
[0m[1;32m 440[0m [0mself[0m[0;34m.[0m[0mloss[0m [0;34m=[0m [0mloss[0m[0;34m.[0m[0msum[0m[0;34m([0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m
[1;32m 441[0m [0;32mif[0m [0mRANK[0m [0;34m!=[0m [0;34m-[0m[0;36m1[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m
[0;32m/usr/local/lib/python3.12/dist-packages/torch/nn/modules/module.py[0m in [0;36m_wrapped_call_impl[0;34m(self, *args, **kwargs)[0m
[1;32m 1774[0m [0;32mreturn[0m [0mself[0m[0;34m.[0m[0m_compiled_call_impl[0m[0;34m([0m[0;34m*[0m[0margs[0m[0;34m,[0m [0;34m**[0m[0mkwargs[0m[0;34m)[0m [0;31m# type: ignore[misc][0m[0;34m[0m[0;34m[0m[0m
[1;32m 1775[0m [0;32melse[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m
[0;32m-> 1776[0;31m [0;32mreturn[0m [0mself[0m[0;34m.[0m[0m_call_impl[0m[0;34m([0m[0;34m*[0m[0margs[0m[0;34m,[0m [0;34m**[0m[0mkwargs[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m
[0m[1;32m 1777[0m [0;34m[0m[0m
[1;32m 1778[0m [0;31m# torchrec tests the code consistency with the following code[0m[0;34m[0m[0;34m[0m[0m
[0;32m/usr/local/lib/python3.12/dist-packages/torch/nn/modules/module.py[0m in [0;36m_call_impl[0;34m(self, *args, **kwargs)[0m
[1;32m 1785[0m [0;32mor[0m [0m_global_backward_pre_hooks[0m [0;32mor[0m [0m_global_backward_hooks[0m[0;34m[0m[0;34m[0m[0m
[1;32m 1786[0m or _global_forward_hooks or _global_forward_pre_hooks):
[0;32m-> 1787[0;31m [0;32mreturn[0m [0mforward_call[0m[0;34m([0m[0;34m*[0m[0margs[0m[0;34m,[0m [0;34m**[0m[0mkwargs[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m
[0m[1;32m 1788[0m [0;34m[0m[0m
[1;32m 1789[0m [0mresult[0m [0;34m=[0m [0;32mNone[0m[0;34m[0m[0;34m[0m[0m
[0;32m/usr/local/lib/python3.12/dist-packages/ultralytics/nn/tasks.py[0m in [0;36mforward[0;34m(self, x, *args, **kwargs)[0m
[1;32m 139[0m """
[1;32m 140[0m [0;32mif[0m [0misinstance[0m[0;34m([0m[0mx[0m[0;34m,[0m [0mdict[0m[0;34m)[0m[0;34m:[0m [0;31m# for cases of training and validating while training.[0m[0;34m[0m[0;34m[0m[0m
[0;32m--> 141[0;31m [0;32mreturn[0m [0mself[0m[0;34m.[0m[0mloss[0m[0;34m([0m[0mx[0m[0;34m,[0m [0;34m*[0m[0margs[0m[0;34m,[0m [0;34m**[0m[0mkwargs[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m
[0m[1;32m 142[0m [0;32mreturn[0m [0mself[0m[0;34m.[0m[0mpredict[0m[0;34m([0m[0mx[0m[0;34m,[0m [0;34m*[0m[0margs[0m[0;34m,[0m [0;34m**[0m[0mkwargs[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m
[1;32m 143[0m [0;34m[0m[0m
[0;32m/usr/local/lib/python3.12/dist-packages/ultralytics/nn/tasks.py[0m in [0;36mloss[0;34m(self, batch, preds)[0m
[1;32m 333[0m [0;32mif[0m [0mpreds[0m [0;32mis[0m [0;32mNone[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m
[1;32m 334[0m [0mpreds[0m [0;34m=[0m [0mself[0m[0;34m.[0m[0mforward[0m[0;34m([0m[0mbatch[0m[0;34m[[0m[0;34m"img"[0m[0;34m][0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m
[0;32m--> 335[0;31m [0;32mreturn[0m [0mself[0m[0;34m.[0m[0mcriterion[0m[0;34m([0m[0mpreds[0m[0;34m,[0m [0mbatch[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m
[0m[1;32m 336[0m [0;34m[0m[0m
[1;32m 337[0m [0;32mdef[0m [0minit_criterion[0m[0;34m([0m[0mself[0m[0;34m)[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m
[0;32m/usr/local/lib/python3.12/dist-packages/ultralytics/utils/loss.py[0m in [0;36m__call__[0;34m(self, preds, batch)[0m
[1;32m 469[0m ) -> tuple[torch.Tensor, torch.Tensor]:
[1;32m 470[0m [0;34m"""Calculate the sum of the loss for box, cls and dfl multiplied by batch size."""[0m[0;34m[0m[0;34m[0m[0m
[0;32m--> 471[0;31m [0;32mreturn[0m [0mself[0m[0;34m.[0m[0mloss[0m[0;34m([0m[0mself[0m[0;34m.[0m[0mparse_output[0m[0;34m([0m[0mpreds[0m[0;34m)[0m[0;34m,[0m [0mbatch[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m
[0m[1;32m 472[0m [0;34m[0m[0m
[1;32m 473[0m [0;32mdef[0m [0mloss[0m[0;34m([0m[0mself[0m[0;34m,[0m [0mpreds[0m[0;34m:[0m [0mdict[0m[0;34m[[0m[0mstr[0m[0;34m,[0m [0mtorch[0m[0;34m.[0m[0mTensor[0m[0;34m][0m[0;34m,[0m [0mbatch[0m[0;34m:[0m [0mdict[0m[0;34m[[0m[0mstr[0m[0;34m,[0m [0mtorch[0m[0;34m.[0m[0mTensor[0m[0;34m][0m[0;34m)[0m [0;34m->[0m [0mtuple[0m[0;34m[[0m[0mtorch[0m[0;34m.[0m[0mTensor[0m[0;34m,[0m [0mtorch[0m[0;34m.[0m[0mTensor[0m[0;34m][0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m
[0;32m/usr/local/lib/python3.12/dist-packages/ultralytics/utils/loss.py[0m in [0;36mloss[0;34m(self, preds, batch)[0m
[1;32m 474[0m [0;34m"""Calculate detection loss using assigned targets."""[0m[0;34m[0m[0;34m[0m[0m
[1;32m 475[0m [0mbatch_size[0m [0;34m=[0m [0mpreds[0m[0;34m[[0m[0;34m"boxes"[0m[0;34m][0m[0;34m.[0m[0mshape[0m[0;34m[[0m[0;36m0[0m[0;34m][0m[0;34m[0m[0;34m[0m[0m
[0;32m--> 476[0;31m [0mloss[0m[0;34m,[0m [0mloss_detach[0m [0;34m=[0m [0mself[0m[0;34m.[0m[0mget_assigned_targets_and_loss[0m[0;34m([0m[0mpreds[0m[0;34m,[0m [0mbatch[0m[0;34m)[0m[0;34m[[0m[0;36m1[0m[0;34m:[0m[0;34m][0m[0;34m[0m[0;34m[0m[0m
[0m[1;32m 477[0m [0;32mreturn[0m [0mloss[0m [0;34m*[0m [0mbatch_size[0m[0;34m,[0m [0mloss_detach[0m[0;34m[0m[0;34m[0m[0m
[1;32m 478[0m [0;34m[0m[0m
[0;32m/usr/local/lib/python3.12/dist-packages/ultralytics/utils/loss.py[0m in [0;36mget_assigned_targets_and_loss[0;34m(self, preds, batch)[0m
[1;32m 426[0m )
[1;32m 427[0m [0;34m[0m[0m
[0;32m--> 428[0;31m [0mtarget_scores_sum[0m [0;34m=[0m [0mmax[0m[0;34m([0m[0mtarget_scores[0m[0;34m.[0m[0msum[0m[0;34m([0m[0;34m)[0m[0;34m,[0m [0;36m1[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m
[0m[1;32m 429[0m [0;34m[0m[0m
[1;32m 430[0m [0;31m# Cls loss with optional class weighting[0m[0;34m[0m[0;34m[0m[0m
[0;31mKeyboardInterrupt[0m: self.run()
File "/usr/lib/python3.12/threading.py", line 1012, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.12/dist-packages/torch/utils/data/_utils/pin_memory.py", line 52, in _pin_memory_loop
do_one_step()
File "/usr/local/lib/python3.12/dist-packages/torch/utils/data/_utils/pin_memory.py", line 28, in do_one_step
r = in_queue.get(timeout=MP_STATUS_CHECK_INTERVAL)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/multiprocessing/queues.py", line 122, in get
return _ForkingPickler.loads(res)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/dist-packages/torch/multiprocessing/reductions.py", line 540, in rebuild_storage_fd
fd = df.detach()
^^^^^^^^^^^
File "/usr/lib/python3.12/multiprocessing/resource_sharer.py", line 57, in detach
with _resource_sharer.get_connection(self._id) as conn:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/multiprocessing/resource_sharer.py", line 86, in get_connection
c = Client(address, authkey=process.current_process().authkey)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/multiprocessing/connection.py", line 519, in Client
c = SocketClient(address)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/multiprocessing/connection.py", line 647, in SocketClient
s.connect(address)
FileNotFoundError: [Errno 2] No such file or directory
In [11]:
import shutil
folder_path = '/kaggle/working/runs/detect/kaggle/working/runs/exp-6'
zip_path = '/kaggle/working/exp-6.zip'
shutil.make_archive('/kaggle/working/exp-6', 'zip', folder_path)
print("Weights saved to !", zip_path)
from IPython.display import FileLink
FileLink(zip_path)Out [11]:
Weights saved to ! /kaggle/working/exp-6.zip
In [ ]:
import ultralytics
model = YOLO("/kaggle/input/weights/last.pt")
model.train(resume=True)