Yolov5

Latest version: v7.0.13

Safety actively analyzes 638466 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 10 of 16

6.0.5

What's Changed
* coco dataset support, automatic aws weight upload by fcakyon in https://github.com/fcakyon/yolov5-pip/pull/54
* add dataset upload, add neptune dataset tracking by fcakyon in https://github.com/fcakyon/yolov5-pip/pull/59
* add windows support for dataset upload by fcakyon in https://github.com/fcakyon/yolov5-pip/pull/61
* make pycocotools optional by fcakyon in https://github.com/fcakyon/yolov5-pip/pull/56
* remove python 3.6 in tests by fcakyon in https://github.com/fcakyon/yolov5-pip/pull/57
* add missing argument in readme by fcakyon in https://github.com/fcakyon/yolov5-pip/pull/60
* fix omp error in windows by fcakyon in https://github.com/fcakyon/yolov5-pip/pull/62
* fix weight s3 uri for windows by fcakyon in https://github.com/fcakyon/yolov5-pip/pull/63

**Full Changelog**: https://github.com/fcakyon/yolov5-pip/compare/6.0.4...6.0.5

COCO Dataset Support
- Start a training using a COCO formatted dataset:

yaml
data.yml
train_json_path: "train.json"
train_image_dir: "train_image_dir/"
val_json_path: "val.json"
val_image_dir: "val_image_dir/"


bash
$ yolov5 train --data data.yaml --weights yolov5s.pt


New AWS and Neptune.AI Utilities
- Automatically upload weights and datasets to AWS S3 (with Neptune.AI artifact tracking integration):

bash
export AWS_ACCESS_KEY_ID=YOUR_KEY
export AWS_SECRET_ACCESS_KEY=YOUR_KEY


bash
$ yolov5 train --data data.yaml --weights yolov5s.pt --s3_upload_dir YOUR_S3_FOLDER_DIRECTORY --upload_dataset


- Add `yolo_s3_data_dir` into `data.yaml` to match Neptune dataset with a present dataset in S3.

yaml
data.yml
train_json_path: "train.json"
train_image_dir: "train_image_dir/"
val_json_path: "val.json"
val_image_dir: "val_image_dir/"
yolo_s3_data_dir: s3://bucket_name/data_dir/

6.0.4

new features
- export and log `results.html` at the end of training, log category based metrics (51)
- handle when neptune installed but not set (50)

6.0.3

- update to 19.10.21 ultralytics/yolov5: https://github.com/ultralytics/yolov5/tree/a18b0c36cd4df0d3b9c2623c5dda009c5f281ac9
- fix a neptune logging error

6.0.1

<div align="center">
<a href="https://github.com/ultralytics/yolov5">YOLOv5 object detector</a> v6.0 is now in <a href="https://pypi.org/project/yolov5/">pip</a> !
</p>
<img src="https://user-images.githubusercontent.com/26833433/136901921-abcfcd9d-f978-4942-9b97-0e3f202907df.png" width="1000">
</div>

</details>

<div align="center">Use from Python</div>


<details open>
<summary>Basic</summary>

python
import yolov5

load model
model = yolov5.load('yolov5s')

set image
img = 'https://github.com/ultralytics/yolov5/raw/master/data/images/zidane.jpg'

perform inference
results = model(img)

inference with larger input size
results = model(img, size=1280)

inference with test time augmentation
results = model(img, augment=True)

parse results
predictions = results.pred[0]
boxes = predictions[:, :4] x1, x2, y1, y2
scores = predictions[:, 4]
categories = predictions[:, 5]

show detection bounding boxes on image
results.show()

save results into "results/" folder
results.save(save_dir='results/')



</details>

<details closed>
<summary>Alternative</summary>

python
from yolov5 import YOLOv5

set model params
model_path = "yolov5/weights/yolov5s.pt"
device = "cuda:0" or "cpu"

init yolov5 model
yolov5 = YOLOv5(model_path, device)

load images
image1 = 'https://github.com/ultralytics/yolov5/raw/master/data/images/zidane.jpg'
image2 = 'https://github.com/ultralytics/yolov5/blob/master/data/images/bus.jpg'

perform inference
results = yolov5.predict(image1)

perform inference with larger input size
results = yolov5.predict(image1, size=1280)

perform inference with test time augmentation
results = yolov5.predict(image1, augment=True)

perform inference on multiple images
results = yolov5.predict([image1, image2], size=1280, augment=True)

parse results
predictions = results.pred[0]
boxes = predictions[:, :4] x1, x2, y1, y2
scores = predictions[:, 4]
categories = predictions[:, 5]

show detection bounding boxes on image
results.show()

save results into "results/" folder
results.save(save_dir='results/')


</details>

<details closed>
<summary>Train/Detect/Test/Export</summary>

- You can directly use these functions by importing them:

python
from yolov5 import train, val, detect, export

train.run(imgsz=640, data='coco128.yaml')
val.run(imgsz=640, data='coco128.yaml', weights='yolov5s.pt')
detect.run(imgsz=640)
export.run(imgsz=640, weights='yolov5s.pt')


- You can pass any argument as input:

python
from yolov5 import detect

img_url = 'https://github.com/ultralytics/yolov5/raw/master/data/images/zidane.jpg'

detect.run(source=img_url, weights="yolov5s6.pt", conf_thres=0.25, imgsz=640)



</details>

<div align="center">Use from CLI</div>

You can call `yolov5 train`, `yolov5 detect`, `yolov5 val` and `yolov5 export` commands after installing the package via `pip`:

<details open>
<summary>Training</summary>

Finetune one of the pretrained YOLOv5 models using your custom `data.yaml`:

bash
$ yolov5 train --data data.yaml --weights yolov5s.pt --batch-size 16 --img 640
yolov5m.pt 8
yolov5l.pt 4
yolov5x.pt 2


Visualize your experiments via [Neptune.AI](https://neptune.ai/):

bash
$ yolov5 train --data data.yaml --weights yolov5s.pt --neptune_project NAMESPACE/PROJECT_NAME --neptune_token YOUR_NEPTUNE_TOKEN


</details>

<details open>
<summary>Inference</summary>

yolov5 detect command runs inference on a variety of sources, downloading models automatically from the [latest YOLOv5 release](https://github.com/ultralytics/yolov5/releases) and saving results to `runs/detect`.

bash
$ yolov5 detect --source 0 webcam
file.jpg image
file.mp4 video
path/ directory
path/*.jpg glob
rtsp://170.93.143.139/rtplive/470011e600ef003a004ee33696235daa rtsp stream
rtmp://192.168.1.105/live/test rtmp stream
http://112.50.243.8/PLTV/88888888/224/3221225900/1.m3u8 # http stream


</details>

<details open>
<summary>Export</summary>

You can export your fine-tuned YOLOv5 weights to any format such as `torchscript`, `onnx`, `coreml`, `pb`, `tflite`, `tfjs`:

bash
$ yolov5 export --weights yolov5s.pt --include 'torchscript,onnx,coreml,pb,tfjs'


</details>

6.0

[assets]: https://github.com/ultralytics/yolov5/releases
[TTA]: https://github.com/ultralytics/yolov5/issues/303

This release incorporates many new features and bug fixes ([**465 PRs** from **73 contributors**](https://github.com/ultralytics/yolov5/compare/v5.0...v6.0)) since our last [release v5.0](https://github.com/ultralytics/yolov5/releases/tag/v5.0) in April, brings architecture tweaks, and also introduces new P5 and P6 'Nano' models: **YOLOv5n** and **YOLOv5n6**. Nano models maintain the YOLOv5s depth multiple of 0.33 but reduce the YOLOv5s width multiple from 0.50 to 0.25, resulting in ~75% fewer parameters, from 7.5M to 1.9M, ideal for mobile and CPU solutions.

Example usage:
bash
python detect.py --weights yolov5n.pt --img 640 Nano P5 model trained at --img 640 (28.4 mAP0.5:0.95)
python detect.py --weights yolov5n6.pt --img 1280 Nano P6 model trained at --img 1280 (34.0 mAP0.5:0.95)



Important Updates

- **Roboflow Integration ⭐ NEW**: Train YOLOv5 models directly on any Roboflow dataset with our new integration! (https://github.com/ultralytics/yolov5/issues/4975 by Jacobsolawetz)

- **YOLOv5n 'Nano' models ⭐ NEW**: New smaller YOLOv5n (1.9M params) model below YOLOv5s (7.5M params), exports to 2.1 MB INT8 size, ideal for ultralight mobile solutions. (https://github.com/ultralytics/yolov5/discussions/5027 by glenn-jocher)
- **TensorFlow and Keras Export**: TensorFlow, Keras, TFLite, TF.js model export now fully integrated using `python export.py --include saved_model pb tflite tfjs` (https://github.com/ultralytics/yolov5/pull/1127 by zldrobit)
- **OpenCV DNN**: YOLOv5 ONNX models are now compatible with both OpenCV DNN and ONNX Runtime (https://github.com/ultralytics/yolov5/pull/4833 by SamFC10).
- **Model Architecture:** Updated backbones are slightly smaller, faster and more accurate.
- Replacement of `Focus()` with an equivalent `Conv(k=6, s=2, p=2)` layer (https://github.com/ultralytics/yolov5/issues/4825 by thomasbi1) for improved exportability
- New `SPPF()` replacement for `SPP()` layer for reduced ops (https://github.com/ultralytics/yolov5/pull/4420 by glenn-jocher)
- Reduction in P3 backbone layer `C3()` repeats from 9 to 6 for improved speeds
- Reorder places `SPPF()` at end of backbone
- Reintroduction of shortcut in the last `C3()` backbone layer
- Updated [hyperparameters](https://github.com/ultralytics/yolov5/blob/master/data/hyps/hyp.scratch-high.yaml) with increased mixup and copy-paste augmentation


New Results

<p align="left"><img width="800" src="https://user-images.githubusercontent.com/26833433/136901921-abcfcd9d-f978-4942-9b97-0e3f202907df.png"></p>
<details>
<summary>YOLOv5-P5 640 Figure (click to expand)</summary>

<p align="left"><img width="800" src="https://user-images.githubusercontent.com/26833433/136763877-b174052b-c12f-48d2-8bc4-545e3853398e.png"></p>
</details>
<details>
<summary>Figure Notes (click to expand)</summary>

* **COCO AP val** denotes mAP0.5:0.95 metric measured on the 5000-image [COCO val2017](http://cocodataset.org) dataset over various inference sizes from 256 to 1536.
* **GPU Speed** measures average inference time per image on [COCO val2017](http://cocodataset.org) dataset using a [AWS p3.2xlarge](https://aws.amazon.com/ec2/instance-types/p3/) V100 instance at batch-size 32.
* **EfficientDet** data from [google/automl](https://github.com/google/automl) at batch size 8.
* **Reproduce** by `python val.py --task study --data coco.yaml --iou 0.7 --weights yolov5n6.pt yolov5s6.pt yolov5m6.pt yolov5l6.pt yolov5x6.pt`
</details>

mAP improves from +0.3% to +1.1% across all models, and ~5% FLOPs reduction produces slight speed improvements and a reduced CUDA memory footprint. Example YOLOv5l before and after metrics:

|YOLOv5l<br><sup>Large|size<br><sup>(pixels) |mAP<sup>val<br>0.5:0.95 |mAP<sup>val<br>0.5 |Speed<br><sup>CPU b1<br>(ms) |Speed<br><sup>V100 b1<br>(ms) |Speed<br><sup>V100 b32<br>(ms) |params<br><sup>(M) |FLOPs<br><sup>640 (B)
--- |--- |--- |--- |--- |--- |--- |--- |---

5.0.10

- fix https://github.com/fcakyon/yolov5-pip/issues/40

Page 10 of 16

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.