From 78840988573cce2af6505b026c40cee38749680a Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Tue, 16 May 2023 01:39:52 +0200 Subject: [PATCH] `ultralytics 8.0.103` minor fixes (#2634) Co-authored-by: kssion Co-authored-by: Eli Spizzichino Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: xbkaishui --- docker/Dockerfile-jetson | 5 ----- ultralytics/__init__.py | 2 +- ultralytics/nn/modules/head.py | 2 +- ultralytics/yolo/data/augment.py | 2 +- ultralytics/yolo/data/dataset_wrappers.py | 3 +-- ultralytics/yolo/utils/__init__.py | 6 +++--- 6 files changed, 7 insertions(+), 13 deletions(-) diff --git a/docker/Dockerfile-jetson b/docker/Dockerfile-jetson index e09028b8..8b4323df 100644 --- a/docker/Dockerfile-jetson +++ b/docker/Dockerfile-jetson @@ -28,11 +28,6 @@ RUN python3 -m pip install --upgrade pip wheel RUN pip install --no-cache tqdm matplotlib pyyaml psutil thop pandas onnx "numpy==1.23" RUN pip install --no-cache -e . -# Resolve duplicate OpenCV installation issues in https://github.com/ultralytics/ultralytics/issues/2407 -RUN apt_packages=$(dpkg -l | grep opencv | awk '{print $2}') && [ -n "$apt_packages" ] && apt-get remove -y $apt_packages || true -RUN pip uninstall -y opencv-python -RUN pip install "opencv-python<4.7" - # Set environment variables ENV OMP_NUM_THREADS=1 diff --git a/ultralytics/__init__.py b/ultralytics/__init__.py index 9fbf6795..c076fa36 100644 --- a/ultralytics/__init__.py +++ b/ultralytics/__init__.py @@ -1,6 +1,6 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license -__version__ = '8.0.101' +__version__ = '8.0.103' from ultralytics.hub import start from ultralytics.vit.rtdetr import RTDETR diff --git a/ultralytics/nn/modules/head.py b/ultralytics/nn/modules/head.py index 3bd13cd7..26b2342e 100644 --- a/ultralytics/nn/modules/head.py +++ b/ultralytics/nn/modules/head.py @@ -346,7 +346,7 @@ class RTDETRDecoder(nn.Module): bs, _, _ = memory.shape # prepare input for decoder anchors, valid_mask = self._generate_anchors(spatial_shapes, dtype=memory.dtype, device=memory.device) - memory = torch.where(valid_mask, memory, torch.tensor(0.)) + memory = torch.where(valid_mask, memory, 0) output_memory = self.enc_output(memory) enc_outputs_class = self.enc_score_head(output_memory) # (bs, h*w, nc) diff --git a/ultralytics/yolo/data/augment.py b/ultralytics/yolo/data/augment.py index 36ea4c66..52fb42d8 100644 --- a/ultralytics/yolo/data/augment.py +++ b/ultralytics/yolo/data/augment.py @@ -128,7 +128,7 @@ class Mosaic(BaseMixTransform): n (int, optional): The grid size, either 4 (for 2x2) or 9 (for 3x3). """ - def __init__(self, dataset, imgsz=640, p=1.0, n=9): + def __init__(self, dataset, imgsz=640, p=1.0, n=4): """Initializes the object with a dataset, image size, probability, and border.""" assert 0 <= p <= 1.0, f'The probability should be in range [0, 1], but got {p}.' assert n in (4, 9), 'grid must be equal to 4 or 9.' diff --git a/ultralytics/yolo/data/dataset_wrappers.py b/ultralytics/yolo/data/dataset_wrappers.py index 5cb59654..72a6fb57 100644 --- a/ultralytics/yolo/data/dataset_wrappers.py +++ b/ultralytics/yolo/data/dataset_wrappers.py @@ -44,8 +44,7 @@ class MixAndRectDataset: indexes = transform.get_indexes(self.dataset) if not isinstance(indexes, collections.abc.Sequence): indexes = [indexes] - mix_labels = [deepcopy(self.dataset[index]) for index in indexes] - labels['mix_labels'] = mix_labels + labels['mix_labels'] = [deepcopy(self.dataset[index]) for index in indexes] if self.dataset.rect and isinstance(transform, LetterBox): transform.new_shape = self.dataset.batch_shapes[self.dataset.batch[index]] labels = transform(labels) diff --git a/ultralytics/yolo/utils/__init__.py b/ultralytics/yolo/utils/__init__.py index dd0fad3b..96010aa0 100644 --- a/ultralytics/yolo/utils/__init__.py +++ b/ultralytics/yolo/utils/__init__.py @@ -242,13 +242,13 @@ if WINDOWS: # emoji-safe logging LOGGER.addFilter(EmojiFilter()) -def yaml_save(file='data.yaml', data=None): +def yaml_save(file='data.yaml', data={}): """ Save YAML data to a file. Args: file (str, optional): File name. Default is 'data.yaml'. - data (dict, optional): Data to save in YAML format. Default is None. + data (dict): Data to save in YAML format. Returns: None: Data is saved to the specified file. @@ -261,7 +261,7 @@ def yaml_save(file='data.yaml', data=None): # Convert Path objects to strings for k, v in data.items(): if isinstance(v, Path): - dict[k] = str(v) + data[k] = str(v) # Dump data to file in YAML format with open(file, 'w') as f: