Skip to content

Commit 734b699

Browse files
glenn-jocherClay Januhowski
authored andcommitted
Improve classification comments (ultralytics#8997)
1 parent b6f8a2d commit 734b699

File tree

5 files changed

+16
-13
lines changed

5 files changed

+16
-13
lines changed

.github/README_cn.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ We trained YOLOv5-cls classification models on ImageNet for 90 epochs using a 4x
269269
<details>
270270
<summary>Table Notes (click to expand)</summary>
271271

272-
- All checkpoints are trained to 90 epochs with SGD optimizer with lr0=0.001 at image size 224 and all default settings. Runs logged to https://wandb.ai/glenn-jocher/YOLOv5-Classifier-v6-2.
272+
- All checkpoints are trained to 90 epochs with SGD optimizer with `lr0=0.001` and `weight_decay=5e-5` at image size 224 and all default settings.<br>Runs logged to https://wandb.ai/glenn-jocher/YOLOv5-Classifier-v6-2
273273
- **Accuracy** values are for single-model single-scale on [ImageNet-1k](https://www.image-net.org/index.php) dataset.<br>Reproduce by `python classify/val.py --data ../datasets/imagenet --img 224`
274274
- **Speed** averaged over 100 inference images using a Google [Colab Pro](https://colab.research.google.com/signup) V100 High-RAM instance.<br>Reproduce by `python classify/val.py --data ../datasets/imagenet --img 224 --batch 1`
275275
- **Export** to ONNX at FP32 and TensorRT at FP16 done with `export.py`. <br>Reproduce by `python export.py --weights yolov5s-cls.pt --include engine onnx --imgsz 224`
@@ -291,14 +291,14 @@ python -m torch.distributed.run --nproc_per_node 4 --master_port 1 classify/trai
291291
```
292292

293293
### Val
294-
Validate accuracy on a pretrained model. To validate YOLOv5s-cls accuracy on ImageNet.
294+
Validate YOLOv5m-cls accuracy on ImageNet-1k dataset:
295295
```bash
296296
bash data/scripts/get_imagenet.sh --val # download ImageNet val split (6.3G, 50000 images)
297-
python classify/val.py --weights yolov5s-cls.pt --data ../datasets/imagenet --img 224
297+
python classify/val.py --weights yolov5m-cls.pt --data ../datasets/imagenet --img 224 # validate
298298
```
299299

300300
### Predict
301-
Run a classification prediction on an image.
301+
Use pretrained YOLOv5s-cls.pt to predict bus.jpg:
302302
```bash
303303
python classify/predict.py --weights yolov5s-cls.pt --data data/images/bus.jpg
304304
```
@@ -307,7 +307,7 @@ model = torch.hub.load('ultralytics/yolov5', 'custom', 'yolov5s-cls.pt') # load
307307
```
308308

309309
### Export
310-
Export a group of trained YOLOv5-cls, ResNet and EfficientNet models to ONNX and TensorRT.
310+
Export a group of trained YOLOv5s-cls, ResNet and EfficientNet models to ONNX and TensorRT:
311311
```bash
312312
python export.py --weights yolov5s-cls.pt resnet50.pt efficientnet_b0.pt --include onnx engine --img 224
313313
```

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ We trained YOLOv5-cls classification models on ImageNet for 90 epochs using a 4x
278278
<details>
279279
<summary>Table Notes (click to expand)</summary>
280280

281-
- All checkpoints are trained to 90 epochs with SGD optimizer with lr0=0.001 at image size 224 and all default settings. Runs logged to https://wandb.ai/glenn-jocher/YOLOv5-Classifier-v6-2.
281+
- All checkpoints are trained to 90 epochs with SGD optimizer with `lr0=0.001` and `weight_decay=5e-5` at image size 224 and all default settings.<br>Runs logged to https://wandb.ai/glenn-jocher/YOLOv5-Classifier-v6-2
282282
- **Accuracy** values are for single-model single-scale on [ImageNet-1k](https://www.image-net.org/index.php) dataset.<br>Reproduce by `python classify/val.py --data ../datasets/imagenet --img 224`
283283
- **Speed** averaged over 100 inference images using a Google [Colab Pro](https://colab.research.google.com/signup) V100 High-RAM instance.<br>Reproduce by `python classify/val.py --data ../datasets/imagenet --img 224 --batch 1`
284284
- **Export** to ONNX at FP32 and TensorRT at FP16 done with `export.py`. <br>Reproduce by `python export.py --weights yolov5s-cls.pt --include engine onnx --imgsz 224`
@@ -300,14 +300,14 @@ python -m torch.distributed.run --nproc_per_node 4 --master_port 1 classify/trai
300300
```
301301

302302
### Val
303-
Validate accuracy on a pretrained model. To validate YOLOv5s-cls accuracy on ImageNet.
303+
Validate YOLOv5m-cls accuracy on ImageNet-1k dataset:
304304
```bash
305305
bash data/scripts/get_imagenet.sh --val # download ImageNet val split (6.3G, 50000 images)
306-
python classify/val.py --weights yolov5s-cls.pt --data ../datasets/imagenet --img 224
306+
python classify/val.py --weights yolov5m-cls.pt --data ../datasets/imagenet --img 224 # validate
307307
```
308308

309309
### Predict
310-
Run a classification prediction on an image.
310+
Use pretrained YOLOv5s-cls.pt to predict bus.jpg:
311311
```bash
312312
python classify/predict.py --weights yolov5s-cls.pt --data data/images/bus.jpg
313313
```
@@ -316,7 +316,7 @@ model = torch.hub.load('ultralytics/yolov5', 'custom', 'yolov5s-cls.pt') # load
316316
```
317317

318318
### Export
319-
Export a group of trained YOLOv5-cls, ResNet and EfficientNet models to ONNX and TensorRT.
319+
Export a group of trained YOLOv5s-cls, ResNet and EfficientNet models to ONNX and TensorRT:
320320
```bash
321321
python export.py --weights yolov5s-cls.pt resnet50.pt efficientnet_b0.pt --include onnx engine --img 224
322322
```

classify/predict.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Run classification inference on images
44
55
Usage:
6-
$ python classify/predict.py --weights yolov5s-cls.pt --source im.jpg
6+
$ python classify/predict.py --weights yolov5s-cls.pt --source data/images/bus.jpg
77
"""
88

99
import argparse

classify/train.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
"""
33
Train a YOLOv5 classifier model on a classification dataset
44
Datasets: --data mnist, fashion-mnist, cifar10, cifar100, imagenette, imagewoof, imagenet, or 'path/to/custom/dataset'
5+
YOLOv5-cls models: --model yolov5n-cls.pt, yolov5s-cls.pt, yolov5m-cls.pt, yolov5l-cls.pt, yolov5x-cls.pt
6+
Torchvision models: --model resnet50, efficientnet_b0, etc. See https://pytorch.org/vision/stable/models.html
57
6-
Usage:
8+
Usage - Single-GPU and Multi-GPU DDP
79
$ python classify/train.py --model yolov5s-cls.pt --data cifar100 --epochs 5 --img 128
810
$ python -m torch.distributed.run --nproc_per_node 4 --master_port 1 classify/train.py --model yolov5s-cls.pt --data imagenet --epochs 5 --img 224 --device 0,1,2,3
911
"""

classify/val.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
Validate a classification model on a dataset
44
55
Usage:
6-
$ python classify/val.py --weights yolov5s-cls.pt --data ../datasets/imagenet
6+
$ bash data/scripts/get_imagenet.sh --val # download ImageNet val split (6.3G, 50000 images)
7+
$ python classify/val.py --weights yolov5m-cls.pt --data ../datasets/imagenet --img 224 # validate
78
"""
89

910
import argparse

0 commit comments

Comments
 (0)