From b87ea6ab221ef1e7f7440fe47c6f924a7fce2862 Mon Sep 17 00:00:00 2001 From: Hoonjae Lee <33407038+comlhj1114@users.noreply.github.com> Date: Thu, 16 May 2024 02:39:26 +0900 Subject: [PATCH] `ultralytics 8.2.16` DDP `pretrained` argument fix (#11787) Co-authored-by: UltralyticsAssistant Co-authored-by: Glenn Jocher Co-authored-by: Laughing-q <1185102784@qq.com> Co-authored-by: Laughing <61612323+Laughing-q@users.noreply.github.com> --- examples/tutorial.ipynb | 3 --- ultralytics/__init__.py | 2 +- ultralytics/engine/trainer.py | 10 +++++----- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/examples/tutorial.ipynb b/examples/tutorial.ipynb index 1902c7ce04..14c58d2dcc 100644 --- a/examples/tutorial.ipynb +++ b/examples/tutorial.ipynb @@ -258,9 +258,6 @@ "text": [ "Ultralytics YOLOv8.2.3 🚀 Python-3.10.12 torch-2.2.1+cu121 CUDA:0 (Tesla T4, 15102MiB)\n", "\u001b[34m\u001b[1mengine/trainer: \u001b[0mtask=detect, mode=train, model=yolov8n.pt, data=coco8.yaml, epochs=3, time=None, patience=100, batch=16, imgsz=640, save=True, save_period=-1, cache=False, device=None, workers=8, project=None, name=train, exist_ok=False, pretrained=True, optimizer=auto, verbose=True, seed=0, deterministic=True, single_cls=False, rect=False, cos_lr=False, close_mosaic=10, resume=False, amp=True, fraction=1.0, profile=False, freeze=None, multi_scale=False, overlap_mask=True, mask_ratio=4, dropout=0.0, val=True, split=val, save_json=False, save_hybrid=False, conf=None, iou=0.7, max_det=300, half=False, dnn=False, plots=True, source=None, vid_stride=1, stream_buffer=False, visualize=False, augment=False, agnostic_nms=False, classes=None, retina_masks=False, embed=None, show=False, save_frames=False, save_txt=False, save_conf=False, save_crop=False, show_labels=True, show_conf=True, show_boxes=True, line_width=None, format=torchscript, keras=False, optimize=False, int8=False, dynamic=False, simplify=False, opset=None, workspace=4, nms=False, 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=7.5, cls=0.5, dfl=1.5, pose=12.0, kobj=1.0, label_smoothing=0.0, nbs=64, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, bgr=0.0, mosaic=1.0, mixup=0.0, copy_paste=0.0, auto_augment=randaugment, erasing=0.4, crop_fraction=1.0, cfg=None, tracker=botsort.yaml, save_dir=runs/detect/train\n", - "2024-04-27 18:41:11.160690: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered\n", - "2024-04-27 18:41:11.160751: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered\n", - "2024-04-27 18:41:11.162138: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered\n", "\n", " from n params module arguments \n", " 0 -1 1 464 ultralytics.nn.modules.conv.Conv [3, 16, 3, 2] \n", diff --git a/ultralytics/__init__.py b/ultralytics/__init__.py index 5e1364da9a..38a2cc467c 100644 --- a/ultralytics/__init__.py +++ b/ultralytics/__init__.py @@ -1,6 +1,6 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license -__version__ = "8.2.15" +__version__ = "8.2.16" from ultralytics.data.explorer.explorer import Explorer from ultralytics.models import RTDETR, SAM, YOLO, YOLOWorld diff --git a/ultralytics/engine/trainer.py b/ultralytics/engine/trainer.py index 05c56dead0..83ee28175e 100644 --- a/ultralytics/engine/trainer.py +++ b/ultralytics/engine/trainer.py @@ -527,13 +527,13 @@ class BaseTrainer: if isinstance(self.model, torch.nn.Module): # if model is loaded beforehand. No setup needed return - model, weights = self.model, None + cfg, weights = self.model, None ckpt = None - if str(model).endswith(".pt"): - weights, ckpt = attempt_load_one_weight(model) + if str(self.model).endswith(".pt"): + weights, ckpt = attempt_load_one_weight(self.model) cfg = weights.yaml - else: - cfg = model + elif isinstance(self.args.pretrained, (str, Path)): + weights, _ = attempt_load_one_weight(self.args.pretrained) self.model = self.get_model(cfg=cfg, weights=weights, verbose=RANK == -1) # calls Model(cfg, weights) return ckpt