From a462bb65c8668ac6aeecda3167cea01446b20274 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Tue, 12 May 2026 19:24:08 +0800 Subject: [PATCH] Professionalize YOLOv5 tutorials (#24468) Signed-off-by: Glenn Jocher --- .../tutorials/architecture_description.md | 2 +- .../tutorials/clearml_logging_integration.md | 155 ++++++++---------- .../en/yolov5/tutorials/multi_gpu_training.md | 64 ++++---- .../tutorials/pytorch_hub_model_loading.md | 14 +- docs/en/yolov5/tutorials/train_custom_data.md | 11 +- 5 files changed, 115 insertions(+), 131 deletions(-) diff --git a/docs/en/yolov5/tutorials/architecture_description.md b/docs/en/yolov5/tutorials/architecture_description.md index ac89d4d9..b2d672f7 100644 --- a/docs/en/yolov5/tutorials/architecture_description.md +++ b/docs/en/yolov5/tutorials/architecture_description.md @@ -225,6 +225,6 @@ This way, the build targets process ensures that each ground truth object is pro ## Conclusion -In conclusion, YOLOv5 represents a significant step forward in the development of real-time object detection models. By incorporating various new features, enhancements, and training strategies, it surpasses previous versions of the YOLO family in performance and efficiency. +YOLOv5 represents a meaningful step in the evolution of real-time object detection. Its architectural choices, training strategies, and engineering refinements deliver strong performance and efficiency relative to earlier YOLO versions. The primary enhancements in YOLOv5 include the use of a dynamic architecture, an extensive range of data augmentation techniques, innovative training strategies, as well as important adjustments in computing losses and the process of building targets. All these innovations significantly improve the accuracy and efficiency of object detection while retaining a high degree of speed, which is the trademark of YOLO models. diff --git a/docs/en/yolov5/tutorials/clearml_logging_integration.md b/docs/en/yolov5/tutorials/clearml_logging_integration.md index ea73e06f..038ee522 100644 --- a/docs/en/yolov5/tutorials/clearml_logging_integration.md +++ b/docs/en/yolov5/tutorials/clearml_logging_integration.md @@ -6,57 +6,46 @@ keywords: ClearML, YOLOv5, machine learning, experiment tracking, data versionin # ClearML Integration -ClearML MLOps experiment tracking platformClearML MLOps experiment tracking platform +ClearML MLOps experiment tracking platform ## About ClearML -[ClearML](https://clear.ml/) is an [open-source](https://github.com/clearml/clearml) MLOps platform designed to streamline your machine learning workflow and save you time ⏱️. +[ClearML](https://clear.ml/) is an [open-source](https://github.com/clearml/clearml) MLOps platform built to streamline machine learning workflows and save engineering time. -🔨 Track every YOLOv5 training run in the experiment manager +- 🔨 Track every YOLOv5 training run in the **experiment manager**. +- 🔧 Version and access your custom [training data](https://www.ultralytics.com/glossary/training-data) with the integrated ClearML **data versioning tool**. +- 🔦 **Remotely train and monitor** YOLOv5 runs using the ClearML Agent. +- 🔬 Find the best mAP with ClearML **hyperparameter optimization**. +- 🔭 Turn your trained **YOLOv5 model into an API** with a few commands using ClearML Serving. -🔧 Version and easily access your custom [training data](https://www.ultralytics.com/glossary/training-data) with the integrated ClearML Data Versioning Tool - -🔦 Remotely train and monitor your YOLOv5 training runs using ClearML Agent - -🔬 Get the very best mAP using ClearML Hyperparameter Optimization - -🔭 Turn your newly trained YOLOv5 model into an API with just a few commands using ClearML Serving - -
-And so much more. It's up to you how many of these tools you want to use, you can stick to the experiment manager, or chain them all together into an impressive pipeline! -
-
+Use as many or as few of these tools as you need — start with the experiment manager alone, or chain everything together into a full pipeline. ![ClearML scalars dashboard showing YOLOv5 training metrics](https://cdn.jsdelivr.net/gh/ultralytics/assets@main/docs/clearml-scalars-dashboard.avif) -
-
- ## 🦾 Setting Things Up -To keep track of your experiments and/or data, ClearML needs to communicate with a server. You have 2 options to get one: +ClearML needs to communicate with a server to track your experiments and data. You have two options: -Either sign up for free to the [ClearML Hosted Service](https://clear.ml/) or you can set up your own [ClearML server](https://clear.ml/docs/latest/docs/deploying_clearml/clearml_server). Even the server is open-source, so even if you're dealing with sensitive data, you should be good to go! +- Sign up for the free [ClearML Hosted Service](https://clear.ml/), or +- Deploy your own [ClearML server](https://clear.ml/docs/latest/docs/deploying_clearml/clearml_server) — it is open-source, so it remains a viable option even for sensitive data. -- Install the `clearml` python package: +Then install the `clearml` Python package and connect the SDK to your server: - ```bash - pip install clearml - ``` +```bash +pip install clearml +``` -- Connect the ClearML SDK to the server by [creating credentials](https://app.clear.ml/settings/workspace-configuration) (go right top to Settings -> Workspace -> Create new credentials), then execute the command below and follow the instructions: +Generate credentials at [Settings → Workspace → Create new credentials](https://app.clear.ml/settings/workspace-configuration) (top right of the ClearML UI), then run: - ```bash - clearml-init - ``` +```bash +clearml-init +``` -That's it! You're done 😎 - -
+Follow the prompts. That's it — setup is complete. ## 🚀 Training YOLOv5 With ClearML -To enable ClearML experiment tracking, simply install the ClearML pip package as shown earlier (or run the command below if you skipped that step). +To enable experiment tracking, install the ClearML pip package if you haven't already: ```bash pip install clearml @@ -64,47 +53,47 @@ pip install clearml This will enable integration with the YOLOv5 training script. Every training run from now on will be captured and stored by the ClearML [experiment manager](https://docs.ultralytics.com/integrations/clearml). -If you want to change the `project_name` or `task_name`, use the `--project` and `--name` arguments of the `train.py` script, by default the project will be called `YOLOv5` and the task `Training`. PLEASE NOTE: ClearML uses `/` as a delimiter for subprojects, so be careful when using `/` in your project name! +To customize the project and task names, pass `--project` and `--name` to `train.py`. The defaults are `YOLOv5` and `Training`. ClearML uses `/` as a subproject delimiter, so avoid `/` in custom project names. ```bash python train.py --img 640 --batch 16 --epochs 3 --data coco8.yaml --weights yolov5s.pt --cache ``` -or with custom project and task name: +Or with custom names: ```bash python train.py --project my_project --name my_training --img 640 --batch 16 --epochs 3 --data coco8.yaml --weights yolov5s.pt --cache ``` -This will capture: +Each run captures: -- Source code + uncommitted changes +- Source code and uncommitted changes - Installed packages -- (Hyper)parameters -- Model files (use `--save-period n` to save a checkpoint every n epochs) +- Hyperparameters +- Model checkpoints (use `--save-period n` to save every `n` epochs) - Console output -- Scalars (mAP_0.5, mAP_0.5:0.95, precision, recall, losses, learning rates, ...) -- General info such as machine details, runtime, creation date etc. -- All produced plots such as label correlogram and [confusion matrix](https://www.ultralytics.com/glossary/confusion-matrix) +- Scalars (mAP_0.5, mAP_0.5:0.95, precision, recall, losses, learning rates) +- Machine details, runtime, and creation date +- Generated plots such as the label correlogram and [confusion matrix](https://www.ultralytics.com/glossary/confusion-matrix) - Images with bounding boxes per [epoch](https://www.ultralytics.com/glossary/epoch) -- Mosaic per epoch +- Mosaic visualizations per epoch - Validation images per epoch -That's a lot right? 🤯 Now, we can visualize all of this information in the ClearML UI to get an overview of our training progress. Add custom columns to the table view (such as e.g. mAP_0.5) so you can easily sort on the best performing model. Or select multiple experiments and directly compare them! +Everything appears in the ClearML UI so you can monitor training in one place. Add custom columns (for example, `mAP_0.5`) to sort by the best-performing model, or select multiple experiments to compare them side by side. -There's even more we can do with all of this information, like [hyperparameter optimization](https://www.ultralytics.com/glossary/hyperparameter-tuning) and remote execution, so keep reading if you want to see how that works! +Keep reading for [hyperparameter optimization](https://www.ultralytics.com/glossary/hyperparameter-tuning) and remote execution. ### 🔗 Dataset Version Management -Versioning your data separately from your code is generally a good idea and makes it easy to acquire the latest version too. This repository supports supplying a dataset version ID, and it will make sure to get the data if it's not there yet. Next to that, this workflow also saves the used dataset ID as part of the task parameters, so you will always know for sure which data was used in which experiment! +Versioning data separately from code makes it easy to pull the latest version and ensures full reproducibility. This repository accepts a dataset version ID, fetches the data automatically if it is missing, and records the ID as a task parameter so you always know which data was used in which experiment. ![ClearML dataset version management interface](https://cdn.jsdelivr.net/gh/ultralytics/assets@main/docs/clearml-dataset-interface.avif) ### Prepare Your Dataset -The YOLOv5 repository supports a number of different datasets by using YAML files containing their information. By default, datasets are downloaded to the `../datasets` folder in relation to the repository root folder. So if you downloaded the `coco128` dataset using the link in the YAML or with the scripts provided by yolov5, you get this folder structure: +The YOLOv5 repository supports many datasets via YAML configuration files. By default, datasets download to the `../datasets` folder relative to the repository root. After downloading `coco128`, the folder structure looks like: -``` +```text .. |_ yolov5 |_ datasets @@ -115,103 +104,95 @@ The YOLOv5 repository supports a number of different datasets by using YAML file |_ README.txt ``` -But this can be any dataset you wish. Feel free to use your own, as long as you keep to this folder structure. +Any dataset works, provided you preserve this structure. -Next, ⚠️**copy the corresponding YAML file to the root of the dataset folder**⚠️. This YAML file contains the information ClearML will need to properly use the dataset. You can make this yourself too, of course, just follow the structure of the example YAMLs. +Next, **copy the dataset's YAML file into the dataset root folder** — ClearML reads this file to use the dataset correctly. You can write your own YAML by following the example layout, ensuring it defines `path`, `train`, `test`, `val`, `nc`, and `names`. -Basically we need the following keys: `path`, `train`, `test`, `val`, `nc`, `names`. - -``` +```text .. |_ yolov5 |_ datasets |_ coco128 |_ images |_ labels - |_ coco128.yaml # <---- HERE! + |_ coco128.yaml # <---- HERE |_ LICENSE |_ README.txt ``` ### Upload Your Dataset -To get this dataset into ClearML as a versioned dataset, go to the dataset root folder (for example `../datasets/coco128` when working from the YOLOv5 repository) and run the following command: +To register the dataset as a versioned ClearML dataset, change into its root folder and run: ```bash cd ../datasets/coco128 clearml-data sync --project YOLOv5 --name coco128 --folder . ``` -The command `clearml-data sync` is actually a shorthand command. You could also run these commands one after the other: +`clearml-data sync` is shorthand for the following sequence, which you can also run explicitly: ```bash -# Optionally add --parent if you want to base -# this version on another dataset version, so no duplicate files are uploaded! +# Add --parent to base this version on a previous one. +# Duplicate files are not re-uploaded. clearml-data create --name coco128 --project YOLOv5 clearml-data add --files . clearml-data close ``` -### Run Training Using A ClearML Dataset +### Train On A ClearML Dataset -Now that you have a ClearML dataset, you can very simply use it to train custom YOLOv5 🚀 models! +With the dataset registered, point training at it by ID: ```bash python train.py --img 640 --batch 16 --epochs 3 --data clearml://YOUR_DATASET_ID --weights yolov5s.pt --cache ``` -
- ### 👀 Hyperparameter Optimization -Now that we have our experiments and data versioned, it's time to take a look at what we can build on top! +With experiments and data versioned, you can build on top of them. Because each tracked experiment captures the full environment — code, installed packages, and configuration — runs are **fully reproducible**. ClearML lets you clone an experiment, change its parameters, and rerun it automatically, which is the foundation of hyperparameter optimization (HPO). -Using the code information, installed packages and environment details, the experiment itself is now **completely reproducible**. In fact, ClearML allows you to clone an experiment and even change its parameters. We can then just rerun it with these new parameters automatically, this is basically what HPO does! +To run HPO locally, use the bundled script. First make sure a training task exists in the experiment manager — the script clones it and varies its hyperparameters. -To **run hyperparameter optimization locally**, we've included a pre-made script for you. Just make sure a training task has been run at least once, so it is in the ClearML experiment manager, we will essentially clone it and change its hyperparameters. - -You'll need to fill in the ID of this `template task` in the script found at `utils/loggers/clearml/hpo.py` and then just run it. You can change `task.execute_locally()` to `task.execute()` to put it in a ClearML queue and have a remote agent work on it instead. +Fill in the template task ID in `utils/loggers/clearml/hpo.py`, then run: ```bash -# To use optuna, install it first, otherwise you can change the optimizer to just be RandomSearch +# Install Optuna or change the optimizer to RandomSearch. pip install optuna python utils/loggers/clearml/hpo.py ``` +Switch `task.execute_locally()` to `task.execute()` to push the job to a ClearML queue for a remote agent to pick up. + ![ClearML HPO dashboard with YOLOv5 metrics](https://cdn.jsdelivr.net/gh/ultralytics/assets@main/docs/hpo-clearml-experiment.avif) -## 🤯 Remote Execution (advanced) +## 🤯 Remote Execution (Advanced) -Running HPO locally is really handy, but what if we want to run our experiments on a remote machine instead? Maybe you have access to a very powerful GPU machine on-site, or you have some budget to use cloud GPUs. This is where the [ClearML Agent](https://clear.ml/docs/latest/docs/clearml_agent) comes into play. Check out what the agent can do here: +Running HPO locally is convenient, but you'll often want experiments on more powerful hardware — an on-prem GPU machine or a cloud instance. That's the role of the [ClearML Agent](https://clear.ml/docs/latest/docs/clearml_agent): -- [YouTube video](https://youtu.be/MX3BrXnaULs) +- [YouTube overview](https://youtu.be/MX3BrXnaULs) - [Documentation](https://clear.ml/docs/latest/docs/clearml_agent) -In short: every experiment tracked by the experiment manager contains enough information to reproduce it on a different machine (installed packages, uncommitted changes etc.). So a ClearML agent does just that: it listens to a queue for incoming tasks and when it finds one, it recreates the environment and runs it while still reporting scalars, plots etc. to the experiment manager. +Each tracked experiment contains everything needed to reproduce it on another machine (installed packages, uncommitted changes, and configuration). A ClearML agent listens to a queue, picks up incoming tasks, recreates the environment, runs the job, and streams scalars and plots back to the experiment manager. -You can turn any machine (a cloud VM, a local GPU machine, your own laptop...) into a ClearML agent by simply running: +Turn any machine — a cloud VM, a local GPU box, or a laptop — into a ClearML agent with: ```bash clearml-agent daemon --queue QUEUES_TO_LISTEN_TO [--docker] ``` -### Cloning, Editing And Enqueuing +### Cloning, Editing, And Enqueuing -With our agent running, we can give it some work. Remember from the HPO section that we can clone a task and edit the hyperparameters? We can do that from the interface too! +With an agent running, you can assign it work directly from the UI: -🪄 Clone the experiment by right-clicking it - -🎯 Edit the hyperparameters to what you wish them to be - -⏳ Enqueue the task to any of the queues by right-clicking it +- 🪄 Right-click an experiment and clone it. +- 🎯 Edit its hyperparameters. +- ⏳ Right-click the cloned task and enqueue it to a target queue. ![Enqueue a task from the UI](https://cdn.jsdelivr.net/gh/ultralytics/assets@main/docs/enqueue-task-ui.avif) ### Executing A Task Remotely -Now you can clone a task like we explained above, or simply mark your current script by adding `task.execute_remotely()` and on execution it will be put into a queue, for the agent to start working on! - -To run the YOLOv5 training script remotely, all you have to do is add this line to the training.py script after the clearml logger has been instantiated: +You can also flag a running script for remote execution programmatically by adding `task.execute_remotely()` after the ClearML logger has been instantiated. Add the highlighted line to `train.py`: ```python # ... @@ -221,18 +202,18 @@ if RANK in {-1, 0}: loggers = Loggers(save_dir, weights, opt, hyp, LOGGER) # loggers instance if loggers.clearml: loggers.clearml.task.execute_remotely(queue="my_queue") # <------ ADD THIS LINE - # Data_dict is either None if user did not choose for ClearML dataset or is filled in by ClearML + # data_dict is None unless the user selected a ClearML dataset, in which case ClearML fills it in. data_dict = loggers.clearml.data_dict # ... ``` -When running the training script after this change, python will run the script up until that line, after which it will package the code and send it to the queue instead! +After this change, running the training script executes up to that line, packages the code, and ships it to the queue. -### Autoscaling workers +### Autoscaling Workers -ClearML comes with [autoscalers](https://clear.ml/docs/latest/docs/guides/services/aws_autoscaler) too! This tool will automatically spin up new remote machines in the cloud of your choice (AWS, GCP, Azure) and turn them into ClearML agents for you whenever there are experiments detected in the queue. Once the tasks are processed, the autoscaler will automatically shut down the remote machines, and you stop paying! +ClearML ships with [autoscalers](https://clear.ml/docs/latest/docs/guides/services/aws_autoscaler) that spin up remote machines in AWS, GCP, or Azure when a queue has pending experiments, convert them into ClearML agents, and shut them down when work is finished — so you only pay for compute that is actually running. -Check out the autoscalers getting started video below. +Watch the getting-started video below: [![Watch the video](https://cdn.jsdelivr.net/gh/ultralytics/assets@main/docs/clearml-autoscalers-video-thumbnail.avif)](https://youtu.be/j4XVMAaUt3E) diff --git a/docs/en/yolov5/tutorials/multi_gpu_training.md b/docs/en/yolov5/tutorials/multi_gpu_training.md index 87802079..fdbccdee 100644 --- a/docs/en/yolov5/tutorials/multi_gpu_training.md +++ b/docs/en/yolov5/tutorials/multi_gpu_training.md @@ -6,7 +6,7 @@ keywords: YOLOv5, multiple GPUs, machine learning, deep learning, PyTorch, data # Multi-GPU Training with YOLOv5 -This guide explains how to properly use **multiple** GPUs to train a dataset with YOLOv5 🚀 on single or multiple machine(s). +This guide explains how to train YOLOv5 with **multiple** GPUs on a single machine or across multiple machines. ## Before You Start @@ -18,13 +18,13 @@ cd yolov5 pip install -r requirements.txt # install ``` -!!! tip "ProTip!" +!!! tip "Use Docker" - **Docker Image** is recommended for all Multi-GPU trainings. See [Docker Quickstart Guide](../environments/docker_image_quickstart_tutorial.md) Docker Pulls + The **Ultralytics Docker image** is recommended for all multi-GPU training runs. See the [Docker Quickstart Guide](../environments/docker_image_quickstart_tutorial.md). Docker Pulls -!!! tip "ProTip!" +!!! tip "PyTorch >= 1.9" - `torch.distributed.run` replaces `torch.distributed.launch` in **[PyTorch](https://www.ultralytics.com/glossary/pytorch)>=1.9**. See [PyTorch distributed documentation](https://docs.pytorch.org/docs/stable/distributed.html) for details. + `torch.distributed.run` replaces `torch.distributed.launch` in **[PyTorch](https://www.ultralytics.com/glossary/pytorch) >= 1.9**. See the [PyTorch distributed documentation](https://docs.pytorch.org/docs/stable/distributed.html) for details. ## Training @@ -40,31 +40,31 @@ python train.py --batch 64 --data coco.yaml --weights yolov5s.pt --device 0 ### Multi-GPU [DataParallel](https://docs.pytorch.org/docs/stable/nn.html#torch.nn.DataParallel) Mode (⚠️ not recommended) -You can increase the `device` to use Multiple GPUs in DataParallel mode. +Pass multiple GPU IDs to `--device` to enable DataParallel mode: ```bash python train.py --batch 64 --data coco.yaml --weights yolov5s.pt --device 0,1 ``` -This method is slow and barely speeds up training compared to using just 1 GPU. +DataParallel is slow and barely speeds up training compared to using a single GPU. ### Multi-GPU [DistributedDataParallel](https://docs.pytorch.org/docs/stable/nn.html#torch.nn.parallel.DistributedDataParallel) Mode (✅ recommended) -You will have to pass `python -m torch.distributed.run --nproc_per_node`, followed by the usual arguments. +Prefix the training command with `python -m torch.distributed.run --nproc_per_node`, then pass the usual arguments: ```bash python -m torch.distributed.run --nproc_per_node 2 train.py --batch 64 --data coco.yaml --weights yolov5s.pt --device 0,1 ``` -- `--nproc_per_node` specifies how many GPUs you would like to use. In the example above, it is 2. -- `--batch` is the total batch-size. It will be divided evenly to each GPU. In the example above, it is 64/2=32 per GPU. +- `--nproc_per_node` is the number of GPUs to use. In the example above, it is `2`. +- `--batch` is the total batch size, divided evenly across each GPU. In the example above, that is `64 / 2 = 32` per GPU. -The code above will use GPUs `0... (N-1)`. You can also set `CUDA_VISIBLE_DEVICES=2,3` (or any other list) before launching the command if you prefer to control device visibility via environment variables. +The command above uses GPUs `0...(N-1)`. To control device visibility through environment variables instead, set `CUDA_VISIBLE_DEVICES=2,3` (or any other list) before launching.
Use specific GPUs (click to expand) -You can do so by simply passing `--device` followed by your specific GPUs. For example, in the code below, we will use GPUs `2,3`. +Pass `--device` followed by the specific GPU IDs. The example below uses GPUs `2,3`. ```bash python -m torch.distributed.run --nproc_per_node 2 train.py --batch 64 --data coco.yaml --cfg yolov5s.yaml --weights '' --device 2,3 @@ -75,11 +75,11 @@ python -m torch.distributed.run --nproc_per_node 2 train.py --batch 64 --data co
Use SyncBatchNorm (click to expand) -[SyncBatchNorm](https://docs.pytorch.org/docs/master/generated/torch.nn.SyncBatchNorm.html) could increase [accuracy](https://www.ultralytics.com/glossary/accuracy) for multiple GPU training, however, it will slow down training by a significant factor. It is **only** available for Multiple GPU DistributedDataParallel training. +[SyncBatchNorm](https://docs.pytorch.org/docs/master/generated/torch.nn.SyncBatchNorm.html) can increase [accuracy](https://www.ultralytics.com/glossary/accuracy) for multi-GPU training, but it slows training down significantly. It is **only** available for multi-GPU DistributedDataParallel training. -It is best used when the batch-size on **each** GPU is small (<= 8). +Best used when the batch size on **each** GPU is small (`<= 8`). -To use SyncBatchNorm, simply pass `--sync-bn` to the command like below: +To enable SyncBatchNorm, pass `--sync-bn`: ```bash python -m torch.distributed.run --nproc_per_node 2 train.py --batch 64 --data coco.yaml --cfg yolov5s.yaml --weights '' --sync-bn @@ -90,13 +90,13 @@ python -m torch.distributed.run --nproc_per_node 2 train.py --batch 64 --data co
Use Multiple machines (click to expand) -This is **only** available for Multiple GPU DistributedDataParallel training. +This is **only** available for multi-GPU DistributedDataParallel training. -Before we continue, make sure the files on all machines are the same, dataset, codebase, etc. Afterward, make sure the machines can communicate with each other. +Before continuing, ensure the dataset, codebase, and any other dependencies match across all machines, then verify that the machines can reach each other on the network. -You will have to choose a master machine (the machine that the others will talk to). Note down its address (`master_addr`) and choose a port (`master_port`). I will use `master_addr = 192.168.1.1` and `master_port = 1234` for the example below. +Choose a master machine (the one the others will connect to), note its address (`master_addr`), and pick a port (`master_port`). The example below uses `master_addr = 192.168.1.1` and `master_port = 1234`. -To use it, you can do as the following: +Then run: ```bash # On master machine 0 @@ -108,18 +108,18 @@ python -m torch.distributed.run --nproc_per_node G --nnodes N --node_rank 0 --ma python -m torch.distributed.run --nproc_per_node G --nnodes N --node_rank R --master_addr "192.168.1.1" --master_port 1234 train.py --batch 64 --data coco.yaml --cfg yolov5s.yaml --weights '' ``` -where `G` is number of GPU per machine, `N` is the number of machines, and `R` is the machine number from `0...(N-1)`. Let's say I have two machines with two GPUs each, it would be `G = 2`, `N = 2`, and `R = 1` for the above. +where `G` is the number of GPUs per machine, `N` is the number of machines, and `R` is the machine rank in `0...(N-1)`. For example, with two machines and two GPUs each, set `G = 2`, `N = 2`, and `R = 1` on the second machine. -Training will not start until **all** `N` machines are connected. Output will only be shown on the master machine! +Training does not start until **all** `N` machines are connected. Output is only shown on the master machine.
### Notes -- Windows support is untested, Linux is recommended. +- Windows support is untested; Linux is recommended. - `--batch` must be a multiple of the number of GPUs. -- GPU 0 will take slightly more memory than the other GPUs as it maintains EMA and is responsible for checkpointing etc. -- If you get `RuntimeError: Address already in use`, it could be because you are running multiple trainings at a time. To fix this, simply use a different port number by adding `--master_port` like below: +- GPU 0 uses slightly more memory than the others because it maintains the EMA and handles checkpointing. +- If you get `RuntimeError: Address already in use`, it usually means multiple training runs are using the same port. Specify a different port with `--master_port`: ```bash python -m torch.distributed.run --master_port 1234 --nproc_per_node 2 ... @@ -159,19 +159,19 @@ As shown in the results, using [DistributedDataParallel](https://docs.pytorch.or ## FAQ -If an error occurs, please read the checklist below first! (It could save your time) +Read the checklist below before opening an issue — it often saves time.
Checklist (click to expand) -- Have you properly read this post? -- Have you tried to re-clone the codebase? The code changes **daily**. -- Have you tried to search for your error? Someone may have already encountered it in this repo or in another and have the solution. -- Have you installed all the requirements listed on top (including the correct Python and PyTorch versions)? -- Have you tried in other environments listed in the "Environments" section below? -- Have you tried with another dataset like coco128 or coco2017? It will make it easier to find the root cause. +- Have you read this guide end-to-end? +- Have you re-cloned the codebase? The code changes **daily**. +- Have you searched for the error message? Someone may have already hit the same issue and shared a fix. +- Have you installed all the requirements (including the correct Python and PyTorch versions)? +- Have you tried one of the supported environments listed below? +- Have you tried a smaller dataset such as `coco128` or `coco2017` to isolate the root cause? -If you went through all the above, feel free to raise an Issue by giving as much detail as possible following the template. +If all of the above check out, open an Issue with as much detail as possible, following the template.
diff --git a/docs/en/yolov5/tutorials/pytorch_hub_model_loading.md b/docs/en/yolov5/tutorials/pytorch_hub_model_loading.md index cea0e18a..3fca4894 100644 --- a/docs/en/yolov5/tutorials/pytorch_hub_model_loading.md +++ b/docs/en/yolov5/tutorials/pytorch_hub_model_loading.md @@ -16,7 +16,9 @@ Install [requirements.txt](https://github.com/ultralytics/yolov5/blob/master/req pip install -r https://raw.githubusercontent.com/ultralytics/yolov5/master/requirements.txt ``` -💡 ProTip: Cloning [https://github.com/ultralytics/yolov5](https://github.com/ultralytics/yolov5) is **not** required 😃 +!!! tip + + Cloning [`ultralytics/yolov5`](https://github.com/ultralytics/yolov5) is **not** required — PyTorch Hub fetches the code automatically. ## Load YOLOv5 with PyTorch Hub @@ -115,7 +117,9 @@ Models can also be created directly on any `device`: model = torch.hub.load("ultralytics/yolov5", "yolov5s", device="cpu") # load on CPU ``` -💡 ProTip: Input images are automatically transferred to the correct model device before inference. +!!! tip + + Input images are automatically transferred to the correct model device before inference. ### Silence Outputs @@ -339,8 +343,10 @@ model = torch.hub.load("path/to/yolov5", "custom", path="path/to/best.pt", sourc PyTorch Hub supports inference on most YOLOv5 export formats, including custom-trained models. See [TFLite, ONNX, CoreML, TensorRT Export tutorial](./model_export.md) for details on exporting models. -💡 ProTip: **TensorRT** may be up to 2-5X faster than PyTorch on [**GPU benchmarks**](https://github.com/ultralytics/yolov5/pull/6963) -💡 ProTip: **ONNX** and **OpenVINO** may be up to 2-3X faster than PyTorch on [**CPU benchmarks**](https://github.com/ultralytics/yolov5/pull/6613) +!!! tip + + - **TensorRT** can be 2-5× faster than PyTorch on [GPU benchmarks](https://github.com/ultralytics/yolov5/pull/6963). + - **ONNX** and **OpenVINO** can be 2-3× faster than PyTorch on [CPU benchmarks](https://github.com/ultralytics/yolov5/pull/6613). ```python import torch diff --git a/docs/en/yolov5/tutorials/train_custom_data.md b/docs/en/yolov5/tutorials/train_custom_data.md index 7c6fcb90..748271cb 100644 --- a/docs/en/yolov5/tutorials/train_custom_data.md +++ b/docs/en/yolov5/tutorials/train_custom_data.md @@ -20,10 +20,7 @@ pip install -r requirements.txt # Install dependencies ## Train On Custom Data - -Ultralytics active learning loop diagram -
-
+[![Ultralytics active learning loop diagram](https://cdn.jsdelivr.net/gh/ultralytics/assets@main/docs/ultralytics-active-learning-loop.avif)](https://platform.ultralytics.com) Developing a custom [object detection](https://docs.ultralytics.com/tasks/detect) model is an iterative process: @@ -86,7 +83,7 @@ names: ### 1.2 Leverage Models for Automated Labeling -While manual labeling using tools is a common approach, the process can be time-consuming. Recent advancements in foundation models offer possibilities for automating or semi-automating the annotation process, potentially speeding up dataset creation significantly. Here are a few examples of models that can assist with generating labels: +Manual labeling is the common approach but is time-consuming. Foundation models can automate or semi-automate annotation and speed up dataset creation. Examples of models that can help generate labels: - **[Google Gemini](https://colab.research.google.com/github/ultralytics/notebooks/blob/main/notebooks/how-to-use-google-gemini-models-for-object-detection-image-captioning-and-ocr.ipynb)**: Large multimodal models like Gemini possess powerful image understanding capabilities. They can be prompted to identify and locate objects within images, generating bounding boxes or descriptions that can be converted into YOLO format labels. Explore its potential in the provided tutorial notebook. - **[SAM2 (Segment Anything Model 2)](https://docs.ultralytics.com/models/sam-2)**: Foundation models focused on segmentation, like SAM2, can identify and delineate objects with high precision. While primarily for segmentation, the resulting masks can often be converted into bounding box annotations suitable for object detection tasks. @@ -176,7 +173,7 @@ All training outputs, including weights and logs, are saved in the `runs/train/` YOLOv5 seamlessly integrates with various tools for visualizing training progress, evaluating results, and monitoring performance in real-time. -### Comet Logging and Visualization 🌟 NEW +### Comet Logging and Visualization [Comet](https://docs.ultralytics.com/integrations/comet) is fully integrated for comprehensive experiment tracking. Visualize metrics live, save hyperparameters, manage datasets and model checkpoints, and analyze model predictions using interactive [Comet Custom Panels](https://bit.ly/yolov5-colab-comet-panels). @@ -192,7 +189,7 @@ Dive deeper into the supported features in our [Comet Integration Guide](https:/ Comet UI showing YOLOv5 training metrics and visualizations -### ClearML Logging and Automation 🌟 NEW +### ClearML Logging and Automation [ClearML](https://docs.ultralytics.com/integrations/clearml) integration enables detailed experiment tracking, dataset version management, and even remote execution of training runs. Activate ClearML with these simple steps: