From f4e8b39fc2ac4528c8378ec077e8df4afe329f60 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sun, 11 Jun 2023 20:39:32 +0200 Subject: [PATCH] `ultralytics 8.0.116` NAS, DVC, YOLOv5u updates (#3124) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- docs/models/yolo-nas.md | 2 +- docs/models/yolov5.md | 12 +++--- docs/models/yolov8.md | 2 +- docs/modes/track.md | 2 +- .../roboflow_datasets_integration.md | 6 ++- docs/yolov5/tutorials/train_custom_data.md | 7 ++- ultralytics/__init__.py | 2 +- ultralytics/yolo/data/utils.py | 2 +- ultralytics/yolo/utils/__init__.py | 11 ++--- ultralytics/yolo/utils/benchmarks.py | 19 +++++--- ultralytics/yolo/utils/callbacks/dvc.py | 2 +- ultralytics/yolo/utils/checks.py | 43 ++++++++++--------- 12 files changed, 66 insertions(+), 44 deletions(-) diff --git a/docs/models/yolo-nas.md b/docs/models/yolo-nas.md index a39cec2..9da8175 100644 --- a/docs/models/yolo-nas.md +++ b/docs/models/yolo-nas.md @@ -3,7 +3,7 @@ comments: true description: Dive into YOLO-NAS, Deci's next-generation object detection model, offering breakthroughs in speed and accuracy. Learn how to utilize pre-trained models using the Ultralytics Python API for various tasks. --- -# Deci's YOLO-NAS +# YOLO-NAS ## Overview diff --git a/docs/models/yolov5.md b/docs/models/yolov5.md index ac0d075..e163f42 100644 --- a/docs/models/yolov5.md +++ b/docs/models/yolov5.md @@ -33,7 +33,7 @@ YOLOv5u is an enhanced version of the [YOLOv5](https://github.com/ultralytics/yo | Validation | :heavy_check_mark: | | Training | :heavy_check_mark: | -??? Performance +!!! Performance === "Detection" @@ -45,11 +45,11 @@ YOLOv5u is an enhanced version of the [YOLOv5](https://github.com/ultralytics/yo | [YOLOv5lu](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov5lu.pt) | 640 | 52.2 | 408.4 | 2.50 | 53.2 | 135.0 | | [YOLOv5xu](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov5xu.pt) | 640 | 53.2 | 763.2 | 3.81 | 97.2 | 246.4 | | | | | | | | | - | [YOLOv5n6u](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov5n6u.pt) | 1280 | 42.1 | - | - | 4.3 | 7.8 | - | [YOLOv5s6u](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov5s6u.pt) | 1280 | 48.6 | - | - | 15.3 | 24.6 | - | [YOLOv5m6u](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov5m6u.pt) | 1280 | 53.6 | - | - | 41.2 | 65.7 | - | [YOLOv5l6u](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov5l6u.pt) | 1280 | 55.7 | - | - | 86.1 | 137.4 | - | [YOLOv5x6u](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov5x6u.pt) | 1280 | 56.8 | - | - | 155.4 | 250.7 | + | [YOLOv5n6u](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov5n6u.pt) | 1280 | 42.1 | 211.0 | 1.83 | 4.3 | 7.8 | + | [YOLOv5s6u](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov5s6u.pt) | 1280 | 48.6 | 422.6 | 2.34 | 15.3 | 24.6 | + | [YOLOv5m6u](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov5m6u.pt) | 1280 | 53.6 | 810.9 | 4.36 | 41.2 | 65.7 | + | [YOLOv5l6u](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov5l6u.pt) | 1280 | 55.7 | 1470.9 | 5.47 | 86.1 | 137.4 | + | [YOLOv5x6u](https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov5x6u.pt) | 1280 | 56.8 | 2436.5 | 8.98 | 155.4 | 250.7 | ## Usage diff --git a/docs/models/yolov8.md b/docs/models/yolov8.md index e1a0a5c..6e3adb5 100644 --- a/docs/models/yolov8.md +++ b/docs/models/yolov8.md @@ -35,7 +35,7 @@ YOLOv8 is the latest iteration in the YOLO series of real-time object detectors, | Validation | :heavy_check_mark: | | Training | :heavy_check_mark: | -??? Performance +!!! Performance === "Detection" diff --git a/docs/modes/track.md b/docs/modes/track.md index 80c477f..c0d8adb 100644 --- a/docs/modes/track.md +++ b/docs/modes/track.md @@ -3,7 +3,7 @@ comments: true description: Explore YOLOv8n-based object tracking with Ultralytics' BoT-SORT and ByteTrack. Learn configuration, usage, and customization tips. --- - + Object tracking is a task that involves identifying the location and class of objects, then assigning a unique ID to that detection in video streams. diff --git a/docs/yolov5/tutorials/roboflow_datasets_integration.md b/docs/yolov5/tutorials/roboflow_datasets_integration.md index c262950..1b1f844 100644 --- a/docs/yolov5/tutorials/roboflow_datasets_integration.md +++ b/docs/yolov5/tutorials/roboflow_datasets_integration.md @@ -6,7 +6,11 @@ description: Use Roboflow to organize, label, prepare, version & host datasets f # Roboflow Datasets You can now use Roboflow to organize, label, prepare, version, and host your datasets for training YOLOv5 🚀 models. Roboflow is free to use with YOLOv5 if you make your workspace public. -UPDATED 30 September 2021. +UPDATED 7 June 2023. + +!!! warning + + Roboflow users can use Ultralytics under the [AGPL license](https://github.com/ultralytics/ultralytics/blob/main/LICENSE) or procure an [Enterprise license](https://ultralytics.com/license) directly from Ultralytics. Be aware that Roboflow does **not** provide Ultralytics licenses, and it is the responsibility of the user to ensure appropriate licensing. ## Upload diff --git a/docs/yolov5/tutorials/train_custom_data.md b/docs/yolov5/tutorials/train_custom_data.md index b018a78..4b0c87c 100644 --- a/docs/yolov5/tutorials/train_custom_data.md +++ b/docs/yolov5/tutorials/train_custom_data.md @@ -4,7 +4,7 @@ description: Train your custom dataset with YOLOv5. Learn to collect, label and --- 📚 This guide explains how to train your own **custom dataset** with [YOLOv5](https://github.com/ultralytics/yolov5) 🚀. -UPDATED 26 March 2023. +UPDATED 7 June 2023. ## Before You Start @@ -32,6 +32,10 @@ YOLOv5 models must be trained on labelled data in order to learn classes of obje
Use Roboflow to create your dataset in YOLO format +!!! warning + + Roboflow users can use Ultralytics under the [AGPL license](https://github.com/ultralytics/ultralytics/blob/main/LICENSE) or procure an [Enterprise license](https://ultralytics.com/license) directly from Ultralytics. Be aware that Roboflow does **not** provide Ultralytics licenses, and it is the responsibility of the user to ensure appropriate licensing. + ### 1.1 Collect Images Your model will learn by example. Training on images similar to the ones it will see in the wild is of the utmost importance. Ideally, you will collect a wide variety of images from the same configuration (camera, angle, lighting, etc.) as you will ultimately deploy your project. @@ -200,6 +204,7 @@ Results file `results.csv` is updated after each epoch, and then plotted as `res ```python from utils.plots import plot_results + plot_results('path/to/results.csv') # plot 'results.csv' as 'results.png' ``` diff --git a/ultralytics/__init__.py b/ultralytics/__init__.py index cd12c76..95febf1 100644 --- a/ultralytics/__init__.py +++ b/ultralytics/__init__.py @@ -1,6 +1,6 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license -__version__ = '8.0.115' +__version__ = '8.0.116' from ultralytics.hub import start from ultralytics.vit.rtdetr import RTDETR diff --git a/ultralytics/yolo/data/utils.py b/ultralytics/yolo/data/utils.py index d2a0095..a3338fe 100644 --- a/ultralytics/yolo/data/utils.py +++ b/ultralytics/yolo/data/utils.py @@ -138,7 +138,7 @@ def polygon2mask(imgsz, polygons, color=1, downsample_ratio=1): """ Args: imgsz (tuple): The image size. - polygons (np.ndarray): [N, M], N is the number of polygons, M is the number of points(Be divided by 2). + polygons (list[np.ndarray]): [N, M], N is the number of polygons, M is the number of points(Be divided by 2). color (int): color downsample_ratio (int): downsample ratio """ diff --git a/ultralytics/yolo/utils/__init__.py b/ultralytics/yolo/utils/__init__.py index aa08953..b77c0c6 100644 --- a/ultralytics/yolo/utils/__init__.py +++ b/ultralytics/yolo/utils/__init__.py @@ -224,6 +224,11 @@ def set_logging(name=LOGGING_NAME, verbose=True): 'propagate': False}}}) +def emojis(string=''): + """Return platform-dependent emoji-safe version of string.""" + return string.encode().decode('ascii', 'ignore') if WINDOWS else string + + class EmojiFilter(logging.Filter): """ A custom logging filter class for removing emojis in log messages. @@ -533,6 +538,7 @@ def get_user_config_dir(sub_dir='Ultralytics'): # GCP and AWS lambda fix, only /tmp is writeable if not is_dir_writeable(str(path.parent)): path = Path('/tmp') / sub_dir + LOGGER.warning(f"WARNING ⚠️ user config directory is not writeable, defaulting to '{path}'.") # Create the subdirectory if it does not exist path.mkdir(parents=True, exist_ok=True) @@ -544,11 +550,6 @@ USER_CONFIG_DIR = Path(os.getenv('YOLO_CONFIG_DIR', get_user_config_dir())) # U SETTINGS_YAML = USER_CONFIG_DIR / 'settings.yaml' -def emojis(string=''): - """Return platform-dependent emoji-safe version of string.""" - return string.encode().decode('ascii', 'ignore') if WINDOWS else string - - def colorstr(*input): """Colors a string https://en.wikipedia.org/wiki/ANSI_escape_code, i.e. colorstr('blue', 'hello world').""" *args, string = input if len(input) > 1 else ('blue', 'bold', input[0]) # color arguments, string diff --git a/ultralytics/yolo/utils/benchmarks.py b/ultralytics/yolo/utils/benchmarks.py index 19010bc..080271e 100644 --- a/ultralytics/yolo/utils/benchmarks.py +++ b/ultralytics/yolo/utils/benchmarks.py @@ -90,7 +90,7 @@ def benchmark(model=Path(SETTINGS['weights_dir']) / 'yolov8n.pt', filename = model.ckpt_path or model.cfg export = model # PyTorch format else: - filename = model.export(imgsz=imgsz, format=format, half=half, int8=int8, device=device) # all others + filename = model.export(imgsz=imgsz, format=format, half=half, int8=int8, device=device, verbose=False) export = YOLO(filename, task=model.task) assert suffix in str(filename), 'export failed' emoji = '❎' # indicates export succeeded @@ -196,8 +196,17 @@ class ProfileModels: model.fuse() # to report correct params and GFLOPs in model.info() model_info = model.info() if self.trt and self.device.type != 'cpu' and not engine_file.is_file(): - engine_file = model.export(format='engine', half=True, imgsz=self.imgsz, device=self.device) - onnx_file = model.export(format='onnx', half=True, imgsz=self.imgsz, simplify=True, device=self.device) + engine_file = model.export(format='engine', + half=True, + imgsz=self.imgsz, + device=self.device, + verbose=False) + onnx_file = model.export(format='onnx', + half=True, + imgsz=self.imgsz, + simplify=True, + device=self.device, + verbose=False) elif file.suffix == '.onnx': model_info = self.get_onnx_model_info(file) onnx_file = file @@ -254,7 +263,7 @@ class ProfileModels: for _ in range(3): start_time = time.time() for _ in range(self.num_warmup_runs): - model(input_data, verbose=False) + model(input_data, imgsz=self.imgsz, verbose=False) elapsed = time.time() - start_time # Compute number of runs as higher of min_time or num_timed_runs @@ -263,7 +272,7 @@ class ProfileModels: # Timed runs run_times = [] for _ in tqdm(range(num_runs), desc=engine_file): - results = model(input_data, verbose=False) + results = model(input_data, imgsz=self.imgsz, verbose=False) run_times.append(results[0].speed['inference']) # Convert to milliseconds run_times = self.iterative_sigma_clipping(np.array(run_times), sigma=2, max_iters=3) # sigma clipping diff --git a/ultralytics/yolo/utils/callbacks/dvc.py b/ultralytics/yolo/utils/callbacks/dvc.py index af5af16..63ec368 100644 --- a/ultralytics/yolo/utils/callbacks/dvc.py +++ b/ultralytics/yolo/utils/callbacks/dvc.py @@ -42,7 +42,7 @@ def _log_images(image_path, prefix=''): def _log_plots(plots, prefix=''): for name, params in plots.items(): timestamp = params['timestamp'] - if _processed_plots.get(name, None) != timestamp: + if _processed_plots.get(name) != timestamp: _log_images(name, prefix) _processed_plots[name] = timestamp diff --git a/ultralytics/yolo/utils/checks.py b/ultralytics/yolo/utils/checks.py index 03b5048..8d862a5 100644 --- a/ultralytics/yolo/utils/checks.py +++ b/ultralytics/yolo/utils/checks.py @@ -19,9 +19,9 @@ import requests import torch from matplotlib import font_manager -from ultralytics.yolo.utils import (AUTOINSTALL, LOGGER, ONLINE, ROOT, USER_CONFIG_DIR, TryExcept, clean_url, colorstr, - downloads, emojis, is_colab, is_docker, is_kaggle, is_online, is_pip_package, - url2file) +from ultralytics.yolo.utils import (AUTOINSTALL, LOGGER, ONLINE, RANK, ROOT, USER_CONFIG_DIR, TryExcept, clean_url, + colorstr, downloads, emojis, is_colab, is_docker, is_kaggle, is_online, + is_pip_package, url2file) def is_ascii(s) -> bool: @@ -164,23 +164,26 @@ def check_font(font='Arial.ttf'): Returns: file (Path): Resolved font file path. """ - name = Path(font).name - - # Check USER_CONFIG_DIR - file = USER_CONFIG_DIR / name - if file.exists(): - return file - - # Check system fonts - matches = [s for s in font_manager.findSystemFonts() if font in s] - if any(matches): - return matches[0] - - # Download to USER_CONFIG_DIR if missing - url = f'https://ultralytics.com/assets/{name}' - if downloads.is_url(url): - downloads.safe_download(url=url, file=file) - return file + from ultralytics.yolo.utils.torch_utils import torch_distributed_zero_first + + with torch_distributed_zero_first(RANK): + name = Path(font).name + + # Check USER_CONFIG_DIR + file = USER_CONFIG_DIR / name + if file.exists(): + return file + + # Check system fonts + matches = [s for s in font_manager.findSystemFonts() if font in s] + if any(matches): + return matches[0] + + # Download to USER_CONFIG_DIR if missing + url = f'https://ultralytics.com/assets/{name}' + if downloads.is_url(url): + downloads.safe_download(url=url, file=file) + return file def check_python(minimum: str = '3.7.0') -> bool: