最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Why does YOLO download a nano v11 model (yolov11n) when given the extra larger v12 weights (yolov12x)? - Stack Overflow

programmeradmin1浏览0评论

I run the following YOLO code with extra large v12 weights, yet it seems to download the yolov11n model for some reason and uses that. I'm trying to understand this behavior, as I don't see it in the documentation.

from ultralytics import YOLO
import torch

torch.cuda.empty_cache()

model = YOLO("/content/yolo12x.pt") # also tried yolo12l.pt

mydata = '/content/yolo_model_definition.yaml'

results = model.train(
    amp=True,
    batch=256,
    cache='disk',
    cos_lr=True,
    data=mydata,
    deterministic=False,
    dropout=0.1,
    epochs=100,
    exist_ok=True,
    fraction=1.0,
    freeze=[0, 1, 2, 3, 4],
    imgsz=224,
    lr0=0.001,
    lrf=0.0001,
    mask_ratio=4,
    multi_scale=True,
    nbs=512,
    optimizer='auto',
    patience=15,
    plots=True,
    pretrained=True,
    project='aihardware',
    name='fine_tune_run',
    rect=False,
    resume=False,
    seed=42,
    val=True,
    verbose=True,
    weight_decay=0.0005,
    warmup_bias_lr=0.1,
    warmup_epochs=3.0,
    warmup_momentum=0.8,
    close_mosaic=10,
    cls=1.0,
    pose=0,
    overlap_mask=True
)

print(results)

Here's some of the output:

Freezing layer 'model.4.m.1.m.1.cv1.bn.weight'
Freezing layer 'model.4.m.1.m.1.cv1.bn.bias'
Freezing layer 'model.4.m.1.m.1.cv2.conv.weight'
Freezing layer 'model.4.m.1.m.1.cv2.bn.weight'
Freezing layer 'model.4.m.1.m.1.cv2.bn.bias'
Freezing layer 'model.21.dfl.conv.weight'
AMP: running Automatic Mixed Precision (AMP) checks...
Downloading .3.0/yolo11n.pt to 'yolo11n.pt'...
100%|██████████| 5.35M/5.35M [00:00<00:00, 396MB/s]
AMP: checks passed ✅
train: Scanning /content/new/labels.cache... 739 images, 84 backgrounds, 0 corrupt: 100%|██████████| 739/739 [00:00<?, ?it/s]
train: Caching images (0.1GB Disk): 100%|██████████| 739/739 [00:00<00:00, 59497.67it/s]
albumentations: Blur(p=0.01, blur_limit=(3, 7)), MedianBlur(p=0.01, blur_limit=(3, 7)), ToGray(p=0.01, num_output_channels=3, method='weighted_average'), CLAHE(p=0.01, clip_limit=(1.0, 4.0), tile_grid_size=(8, 8))
val: Scanning /content/val/labels... 141 images, 16 backgrounds, 0 corrupt: 100%|██████████| 141/141 [00:00<00:00, 998.33it/s]val: New cache created: /content/val/labels.cache

val: Caching images (0.0GB Disk): 100%|██████████| 141/141 [00:00<00:00, 5131.07it/s]
Plotting labels to aihardware/fine_tune_run/labels.jpg... 
optimizer: 'optimizer=auto' found, ignoring 'lr0=0.001' and 'momentum=0.937' and determining best 'optimizer', 'lr0' and 'momentum' automatically... 
optimizer: AdamW(lr=0.000833, momentum=0.9) with parameter groups 205 weight(decay=0.0), 214 weight(decay=0.0005), 211 bias(decay=0.0)
TensorBoard: model graph visualization added ✅
Image sizes 224 train, 224 val
Using 8 dataloader workers
Logging results to aihardware/fine_tune_run
Starting training for 100 epochs...

Of course, the part of that I'm concerned about is:

Downloading /
v8.3.0/yolo11n.pt to 'yolo11n.pt'...
100%|██████████| 5.35M/5.35M [00:00<00:00, 396MB/s]

I have also tried changing pretrained from True to a string path to the weights (not that it should need it, since the weights were specified in the creation of the model object). The problem does not happen if I use the YOLO CLI instead of Python:

!yolo train model=/content/yolo12l.pt \
    data=/content/yolo_model_definition.yaml \
    epochs=100 \
    batch=32 \
    imgsz=224 \
    lr0=0.001 \
    lrf=0.0001 \
    weight_decay=0.0005 \
    dropout=0.1 \
    multi_scale=True \
    optimizer=auto \
    project=aihardware \
    name=fine_tune_run \
    exist_ok=True \
    cos_lr=True \
    cache=disk \
    val=True \
    plots=True \
    seed=42 \
    warmup_epochs=3.0 \
    warmup_bias_lr=0.1 \
    warmup_momentum=0.8 \
    patience=15 \
    cls=1.0 \
    mask_ratio=4 \
    close_mosaic=10 \
    overlap_mask=True \
    freeze=0,1,2,3,4 \
    device=0 \
    amp=True \
    fraction=1.0 \
    verbose=True

The code above uses the v12 weights and does not download v11. However, ultralytics seems to be the current version, 8.3.99, so I don't understand the behavior in Python.

Here are the checks:

Ultralytics 8.3.99 

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论