From 24bea5e4b7ad369753f45e93b736d9205c37d20a Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sat, 14 Aug 2021 21:17:51 +0200 Subject: [PATCH] Standardize headers and docstrings (#4417) * Implement new headers * Reformat 1 * Reformat 2 * Reformat 3 - math * Reformat 4 - yaml --- .github/workflows/ci-testing.yml | 12 +++++++----- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/greetings.yml | 4 +++- .github/workflows/rebase.yml | 2 +- .github/workflows/stale.yml | 2 ++ Dockerfile | 2 ++ data/Argoverse.yaml | 2 +- data/GlobalWheat2020.yaml | 2 +- data/Objects365.yaml | 2 +- data/SKU-110K.yaml | 2 +- data/VOC.yaml | 2 +- data/VisDrone.yaml | 2 +- data/coco.yaml | 2 +- data/coco128.yaml | 2 +- data/hyps/hyp.finetune.yaml | 2 +- data/hyps/hyp.finetune_objects365.yaml | 2 ++ data/hyps/hyp.scratch-p6.yaml | 2 +- data/hyps/hyp.scratch.yaml | 2 +- data/scripts/download_weights.sh | 2 +- data/scripts/get_coco.sh | 2 +- data/scripts/get_coco128.sh | 2 +- data/xView.yaml | 2 +- detect.py | 4 +++- export.py | 4 +++- hubconf.py | 4 +++- models/common.py | 7 +++++-- models/experimental.py | 7 +++++-- models/hub/anchors.yaml | 3 ++- models/hub/yolov3-spp.yaml | 2 ++ models/hub/yolov3-tiny.yaml | 2 ++ models/hub/yolov3.yaml | 2 ++ models/hub/yolov5-bifpn.yaml | 2 ++ models/hub/yolov5-fpn.yaml | 2 ++ models/hub/yolov5-p2.yaml | 2 ++ models/hub/yolov5-p6.yaml | 2 ++ models/hub/yolov5-p7.yaml | 2 ++ models/hub/yolov5-panet.yaml | 2 ++ models/hub/yolov5l6.yaml | 2 ++ models/hub/yolov5m6.yaml | 2 ++ models/hub/yolov5s-ghost.yaml | 2 ++ models/hub/yolov5s-transformer.yaml | 2 ++ models/hub/yolov5s6.yaml | 2 ++ models/hub/yolov5x6.yaml | 2 ++ models/yolo.py | 4 +++- models/yolov5l.yaml | 2 ++ models/yolov5m.yaml | 2 ++ models/yolov5s.yaml | 2 ++ models/yolov5x.yaml | 2 ++ train.py | 6 ++++-- utils/activations.py | 5 ++++- utils/augmentations.py | 7 +++++-- utils/autoanchor.py | 5 ++++- utils/callbacks.py | 6 +++++- utils/datasets.py | 5 ++++- utils/downloads.py | 5 ++++- utils/flask_rest_api/README.md | 9 +++++++-- utils/general.py | 7 +++++-- utils/loggers/__init__.py | 6 +++++- utils/loggers/wandb/wandb_utils.py | 2 +- utils/loss.py | 5 ++++- utils/metrics.py | 7 +++++-- utils/plots.py | 5 ++++- utils/torch_utils.py | 7 +++++-- val.py | 4 +++- 64 files changed, 164 insertions(+), 54 deletions(-) diff --git a/.github/workflows/ci-testing.yml b/.github/workflows/ci-testing.yml index a7964ea..02e8f74 100644 --- a/.github/workflows/ci-testing.yml +++ b/.github/workflows/ci-testing.yml @@ -1,11 +1,13 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license + name: CI CPU testing on: # https://help.github.com/en/actions/reference/events-that-trigger-workflows push: - branches: [ master, develop ] + branches: [master, develop] pull_request: # The branches below must be a subset of the branches above - branches: [ master, develop ] + branches: [master, develop] jobs: cpu-tests: @@ -14,9 +16,9 @@ jobs: strategy: fail-fast: false matrix: - os: [ ubuntu-latest, macos-latest, windows-latest ] - python-version: [ 3.8 ] - model: [ 'yolov5s' ] # models to test + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: [3.8] + model: ['yolov5s'] # models to test # Timeout: https://stackoverflow.com/a/59076067/4521646 timeout-minutes: 50 diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 458465d..2305ea0 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - language: [ 'python' ] + language: ['python'] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] # Learn more: # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml index ddd739e..c557e77 100644 --- a/.github/workflows/greetings.yml +++ b/.github/workflows/greetings.yml @@ -1,6 +1,8 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license + name: Greetings -on: [ pull_request_target, issues ] +on: [pull_request_target, issues] jobs: greeting: diff --git a/.github/workflows/rebase.yml b/.github/workflows/rebase.yml index 38e1457..e86c577 100644 --- a/.github/workflows/rebase.yml +++ b/.github/workflows/rebase.yml @@ -3,7 +3,7 @@ name: Automatic Rebase on: issue_comment: - types: [ created ] + types: [created] jobs: rebase: diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index d620e54..c81c0ca 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -1,3 +1,5 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license + name: Close stale issues on: schedule: diff --git a/Dockerfile b/Dockerfile index e22c110..858b22b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,5 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license + # Start FROM Nvidia PyTorch image https://ngc.nvidia.com/catalog/containers/nvidia:pytorch FROM nvcr.io/nvidia/pytorch:21.05-py3 diff --git a/data/Argoverse.yaml b/data/Argoverse.yaml index 3bf91ce..1625dd1 100644 --- a/data/Argoverse.yaml +++ b/data/Argoverse.yaml @@ -1,4 +1,4 @@ -# YOLOv5 🚀 by Ultralytics https://ultralytics.com, licensed under GNU GPL v3.0 +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license # Argoverse-HD dataset (ring-front-center camera) http://www.cs.cmu.edu/~mengtial/proj/streaming/ # Example usage: python train.py --data Argoverse.yaml # parent diff --git a/data/GlobalWheat2020.yaml b/data/GlobalWheat2020.yaml index de9c783..75b3bfd 100644 --- a/data/GlobalWheat2020.yaml +++ b/data/GlobalWheat2020.yaml @@ -1,4 +1,4 @@ -# YOLOv5 🚀 by Ultralytics https://ultralytics.com, licensed under GNU GPL v3.0 +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license # Global Wheat 2020 dataset http://www.global-wheat.com/ # Example usage: python train.py --data GlobalWheat2020.yaml # parent diff --git a/data/Objects365.yaml b/data/Objects365.yaml index 457b9fd..dc5bfbc 100644 --- a/data/Objects365.yaml +++ b/data/Objects365.yaml @@ -1,4 +1,4 @@ -# YOLOv5 🚀 by Ultralytics https://ultralytics.com, licensed under GNU GPL v3.0 +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license # Objects365 dataset https://www.objects365.org/ # Example usage: python train.py --data Objects365.yaml # parent diff --git a/data/SKU-110K.yaml b/data/SKU-110K.yaml index c85fa81..653485e 100644 --- a/data/SKU-110K.yaml +++ b/data/SKU-110K.yaml @@ -1,4 +1,4 @@ -# YOLOv5 🚀 by Ultralytics https://ultralytics.com, licensed under GNU GPL v3.0 +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license # SKU-110K retail items dataset https://github.com/eg4000/SKU110K_CVPR19 # Example usage: python train.py --data SKU-110K.yaml # parent diff --git a/data/VOC.yaml b/data/VOC.yaml index e59fb6a..8dbaacf 100644 --- a/data/VOC.yaml +++ b/data/VOC.yaml @@ -1,4 +1,4 @@ -# YOLOv5 🚀 by Ultralytics https://ultralytics.com, licensed under GNU GPL v3.0 +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license # PASCAL VOC dataset http://host.robots.ox.ac.uk/pascal/VOC # Example usage: python train.py --data VOC.yaml # parent diff --git a/data/VisDrone.yaml b/data/VisDrone.yaml index fe6cb91..7753da9 100644 --- a/data/VisDrone.yaml +++ b/data/VisDrone.yaml @@ -1,4 +1,4 @@ -# YOLOv5 🚀 by Ultralytics https://ultralytics.com, licensed under GNU GPL v3.0 +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license # VisDrone2019-DET dataset https://github.com/VisDrone/VisDrone-Dataset # Example usage: python train.py --data VisDrone.yaml # parent diff --git a/data/coco.yaml b/data/coco.yaml index acf8e84..2ccc647 100644 --- a/data/coco.yaml +++ b/data/coco.yaml @@ -1,4 +1,4 @@ -# YOLOv5 🚀 by Ultralytics https://ultralytics.com, licensed under GNU GPL v3.0 +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license # COCO 2017 dataset http://cocodataset.org # Example usage: python train.py --data coco.yaml # parent diff --git a/data/coco128.yaml b/data/coco128.yaml index eda39dc..70cf52c 100644 --- a/data/coco128.yaml +++ b/data/coco128.yaml @@ -1,4 +1,4 @@ -# YOLOv5 🚀 by Ultralytics https://ultralytics.com, licensed under GNU GPL v3.0 +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license # COCO128 dataset https://www.kaggle.com/ultralytics/coco128 (first 128 images from COCO train2017) # Example usage: python train.py --data coco128.yaml # parent diff --git a/data/hyps/hyp.finetune.yaml b/data/hyps/hyp.finetune.yaml index 237cd5b..b89d66f 100644 --- a/data/hyps/hyp.finetune.yaml +++ b/data/hyps/hyp.finetune.yaml @@ -1,8 +1,8 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license # Hyperparameters for VOC finetuning # python train.py --batch 64 --weights yolov5m.pt --data VOC.yaml --img 512 --epochs 50 # See tutorials for hyperparameter evolution https://github.com/ultralytics/yolov5#tutorials - # Hyperparameter Evolution Results # Generations: 306 # P R mAP.5 mAP.5:.95 box obj cls diff --git a/data/hyps/hyp.finetune_objects365.yaml b/data/hyps/hyp.finetune_objects365.yaml index 435fa7a..073720a 100644 --- a/data/hyps/hyp.finetune_objects365.yaml +++ b/data/hyps/hyp.finetune_objects365.yaml @@ -1,3 +1,5 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license + lr0: 0.00258 lrf: 0.17 momentum: 0.779 diff --git a/data/hyps/hyp.scratch-p6.yaml b/data/hyps/hyp.scratch-p6.yaml index fc1d8eb..7aad818 100644 --- a/data/hyps/hyp.scratch-p6.yaml +++ b/data/hyps/hyp.scratch-p6.yaml @@ -1,8 +1,8 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license # Hyperparameters for COCO training from scratch # python train.py --batch 32 --cfg yolov5m6.yaml --weights '' --data coco.yaml --img 1280 --epochs 300 # See tutorials for hyperparameter evolution https://github.com/ultralytics/yolov5#tutorials - lr0: 0.01 # initial learning rate (SGD=1E-2, Adam=1E-3) lrf: 0.2 # final OneCycleLR learning rate (lr0 * lrf) momentum: 0.937 # SGD momentum/Adam beta1 diff --git a/data/hyps/hyp.scratch.yaml b/data/hyps/hyp.scratch.yaml index b2cf2e3..77405a5 100644 --- a/data/hyps/hyp.scratch.yaml +++ b/data/hyps/hyp.scratch.yaml @@ -1,8 +1,8 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license # Hyperparameters for COCO training from scratch # python train.py --batch 40 --cfg yolov5m.yaml --weights '' --data coco.yaml --img 640 --epochs 300 # See tutorials for hyperparameter evolution https://github.com/ultralytics/yolov5#tutorials - lr0: 0.01 # initial learning rate (SGD=1E-2, Adam=1E-3) lrf: 0.2 # final OneCycleLR learning rate (lr0 * lrf) momentum: 0.937 # SGD momentum/Adam beta1 diff --git a/data/scripts/download_weights.sh b/data/scripts/download_weights.sh index a576c95..b4b0ccd 100755 --- a/data/scripts/download_weights.sh +++ b/data/scripts/download_weights.sh @@ -1,5 +1,5 @@ #!/bin/bash -# YOLOv5 🚀 by Ultralytics https://ultralytics.com, licensed under GNU GPL v3.0 +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license # Download latest models from https://github.com/ultralytics/yolov5/releases # Example usage: bash path/to/download_weights.sh # parent diff --git a/data/scripts/get_coco.sh b/data/scripts/get_coco.sh index f6c0756..0210c8e 100755 --- a/data/scripts/get_coco.sh +++ b/data/scripts/get_coco.sh @@ -1,5 +1,5 @@ #!/bin/bash -# YOLOv5 🚀 by Ultralytics https://ultralytics.com, licensed under GNU GPL v3.0 +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license # Download COCO 2017 dataset http://cocodataset.org # Example usage: bash data/scripts/get_coco.sh # parent diff --git a/data/scripts/get_coco128.sh b/data/scripts/get_coco128.sh index 6eb47bf..4238e36 100644 --- a/data/scripts/get_coco128.sh +++ b/data/scripts/get_coco128.sh @@ -1,5 +1,5 @@ #!/bin/bash -# YOLOv5 🚀 by Ultralytics https://ultralytics.com, licensed under GNU GPL v3.0 +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license # Download COCO128 dataset https://www.kaggle.com/ultralytics/coco128 (first 128 images from COCO train2017) # Example usage: bash data/scripts/get_coco128.sh # parent diff --git a/data/xView.yaml b/data/xView.yaml index e191188..fabcdb0 100644 --- a/data/xView.yaml +++ b/data/xView.yaml @@ -1,4 +1,4 @@ -# YOLOv5 🚀 by Ultralytics https://ultralytics.com, licensed under GNU GPL v3.0 +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license # xView 2018 dataset https://challenge.xviewdataset.org # -------- DOWNLOAD DATA MANUALLY from URL above and unzip to 'datasets/xView' before running train command! -------- # Example usage: python train.py --data xView.yaml diff --git a/detect.py b/detect.py index db0c545..49ebbe9 100644 --- a/detect.py +++ b/detect.py @@ -1,4 +1,6 @@ -"""Run inference with a YOLOv5 model on images, videos, directories, streams +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license +""" +Run inference on images, videos, directories, streams, etc. Usage: $ python path/to/detect.py --source path/to/img.jpg --weights yolov5s.pt --img 640 diff --git a/export.py b/export.py index db5a691..db805cb 100644 --- a/export.py +++ b/export.py @@ -1,4 +1,6 @@ -"""Export a YOLOv5 *.pt model to TorchScript, ONNX, CoreML formats +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license +""" +Export a PyTorch model to TorchScript, ONNX, CoreML formats Usage: $ python path/to/export.py --weights yolov5s.pt --img 640 --batch 1 diff --git a/hubconf.py b/hubconf.py index 93ea84d..36f3bd8 100644 --- a/hubconf.py +++ b/hubconf.py @@ -1,4 +1,6 @@ -"""YOLOv5 PyTorch Hub models https://pytorch.org/hub/ultralytics_yolov5/ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license +""" +PyTorch Hub models https://pytorch.org/hub/ultralytics_yolov5/ Usage: import torch diff --git a/models/common.py b/models/common.py index 3579080..fe4319b 100644 --- a/models/common.py +++ b/models/common.py @@ -1,11 +1,14 @@ -# YOLOv5 common modules +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license +""" +Common modules +""" import logging +import math import warnings from copy import copy from pathlib import Path -import math import numpy as np import pandas as pd import requests diff --git a/models/experimental.py b/models/experimental.py index 5c690cc..7dfaf96 100644 --- a/models/experimental.py +++ b/models/experimental.py @@ -1,10 +1,13 @@ -# YOLOv5 experimental modules +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license +""" +Experimental modules +""" import numpy as np import torch import torch.nn as nn -from models.common import Conv, DWConv +from models.common import Conv from utils.downloads import attempt_download diff --git a/models/hub/anchors.yaml b/models/hub/anchors.yaml index 5751295..e4d7beb 100644 --- a/models/hub/anchors.yaml +++ b/models/hub/anchors.yaml @@ -1,4 +1,5 @@ -# Default YOLOv5 anchors for COCO data +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license +# Default anchors for COCO data # P5 ------------------------------------------------------------------------------------------------------------------- diff --git a/models/hub/yolov3-spp.yaml b/models/hub/yolov3-spp.yaml index ddc0549..c669821 100644 --- a/models/hub/yolov3-spp.yaml +++ b/models/hub/yolov3-spp.yaml @@ -1,3 +1,5 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license + # Parameters nc: 80 # number of classes depth_multiple: 1.0 # model depth multiple diff --git a/models/hub/yolov3-tiny.yaml b/models/hub/yolov3-tiny.yaml index 537ad75..b28b443 100644 --- a/models/hub/yolov3-tiny.yaml +++ b/models/hub/yolov3-tiny.yaml @@ -1,3 +1,5 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license + # Parameters nc: 80 # number of classes depth_multiple: 1.0 # model depth multiple diff --git a/models/hub/yolov3.yaml b/models/hub/yolov3.yaml index 3adfc2c..4f4b240 100644 --- a/models/hub/yolov3.yaml +++ b/models/hub/yolov3.yaml @@ -1,3 +1,5 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license + # Parameters nc: 80 # number of classes depth_multiple: 1.0 # model depth multiple diff --git a/models/hub/yolov5-bifpn.yaml b/models/hub/yolov5-bifpn.yaml index 69f7b59..119aebb 100644 --- a/models/hub/yolov5-bifpn.yaml +++ b/models/hub/yolov5-bifpn.yaml @@ -1,3 +1,5 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license + # Parameters nc: 80 # number of classes depth_multiple: 1.0 # model depth multiple diff --git a/models/hub/yolov5-fpn.yaml b/models/hub/yolov5-fpn.yaml index 217e4ca..707b213 100644 --- a/models/hub/yolov5-fpn.yaml +++ b/models/hub/yolov5-fpn.yaml @@ -1,3 +1,5 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license + # Parameters nc: 80 # number of classes depth_multiple: 1.0 # model depth multiple diff --git a/models/hub/yolov5-p2.yaml b/models/hub/yolov5-p2.yaml index 6a932a8..44d8da5 100644 --- a/models/hub/yolov5-p2.yaml +++ b/models/hub/yolov5-p2.yaml @@ -1,3 +1,5 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license + # Parameters nc: 80 # number of classes depth_multiple: 1.0 # model depth multiple diff --git a/models/hub/yolov5-p6.yaml b/models/hub/yolov5-p6.yaml index 58b86b0..85e1425 100644 --- a/models/hub/yolov5-p6.yaml +++ b/models/hub/yolov5-p6.yaml @@ -1,3 +1,5 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license + # Parameters nc: 80 # number of classes depth_multiple: 1.0 # model depth multiple diff --git a/models/hub/yolov5-p7.yaml b/models/hub/yolov5-p7.yaml index f6e8fc7..88a7a95 100644 --- a/models/hub/yolov5-p7.yaml +++ b/models/hub/yolov5-p7.yaml @@ -1,3 +1,5 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license + # Parameters nc: 80 # number of classes depth_multiple: 1.0 # model depth multiple diff --git a/models/hub/yolov5-panet.yaml b/models/hub/yolov5-panet.yaml index c5f3b48..76b9b7e 100644 --- a/models/hub/yolov5-panet.yaml +++ b/models/hub/yolov5-panet.yaml @@ -1,3 +1,5 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license + # Parameters nc: 80 # number of classes depth_multiple: 1.0 # model depth multiple diff --git a/models/hub/yolov5l6.yaml b/models/hub/yolov5l6.yaml index d5afd7d..1288f15 100644 --- a/models/hub/yolov5l6.yaml +++ b/models/hub/yolov5l6.yaml @@ -1,3 +1,5 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license + # Parameters nc: 80 # number of classes depth_multiple: 1.0 # model depth multiple diff --git a/models/hub/yolov5m6.yaml b/models/hub/yolov5m6.yaml index 16a841a..f14f0b0 100644 --- a/models/hub/yolov5m6.yaml +++ b/models/hub/yolov5m6.yaml @@ -1,3 +1,5 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license + # Parameters nc: 80 # number of classes depth_multiple: 0.67 # model depth multiple diff --git a/models/hub/yolov5s-ghost.yaml b/models/hub/yolov5s-ghost.yaml index d99d56d..dbf2c8e 100644 --- a/models/hub/yolov5s-ghost.yaml +++ b/models/hub/yolov5s-ghost.yaml @@ -1,3 +1,5 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license + # Parameters nc: 80 # number of classes depth_multiple: 0.33 # model depth multiple diff --git a/models/hub/yolov5s-transformer.yaml b/models/hub/yolov5s-transformer.yaml index b999ebb..aeac1ac 100644 --- a/models/hub/yolov5s-transformer.yaml +++ b/models/hub/yolov5s-transformer.yaml @@ -1,3 +1,5 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license + # Parameters nc: 80 # number of classes depth_multiple: 0.33 # model depth multiple diff --git a/models/hub/yolov5s6.yaml b/models/hub/yolov5s6.yaml index 2fb2450..2baee5a 100644 --- a/models/hub/yolov5s6.yaml +++ b/models/hub/yolov5s6.yaml @@ -1,3 +1,5 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license + # Parameters nc: 80 # number of classes depth_multiple: 0.33 # model depth multiple diff --git a/models/hub/yolov5x6.yaml b/models/hub/yolov5x6.yaml index c518710..e94f592 100644 --- a/models/hub/yolov5x6.yaml +++ b/models/hub/yolov5x6.yaml @@ -1,3 +1,5 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license + # Parameters nc: 80 # number of classes depth_multiple: 1.33 # model depth multiple diff --git a/models/yolo.py b/models/yolo.py index 88adb71..f3c1516 100644 --- a/models/yolo.py +++ b/models/yolo.py @@ -1,4 +1,6 @@ -"""YOLOv5-specific modules +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license +""" +YOLO-specific modules Usage: $ python path/to/models/yolo.py --cfg yolov5s.yaml diff --git a/models/yolov5l.yaml b/models/yolov5l.yaml index 0c130c1..30b22a2 100644 --- a/models/yolov5l.yaml +++ b/models/yolov5l.yaml @@ -1,3 +1,5 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license + # Parameters nc: 80 # number of classes depth_multiple: 1.0 # model depth multiple diff --git a/models/yolov5m.yaml b/models/yolov5m.yaml index e477b34..f5f518a 100644 --- a/models/yolov5m.yaml +++ b/models/yolov5m.yaml @@ -1,3 +1,5 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license + # Parameters nc: 80 # number of classes depth_multiple: 0.67 # model depth multiple diff --git a/models/yolov5s.yaml b/models/yolov5s.yaml index e85442d..b311ab7 100644 --- a/models/yolov5s.yaml +++ b/models/yolov5s.yaml @@ -1,3 +1,5 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license + # Parameters nc: 80 # number of classes depth_multiple: 0.33 # model depth multiple diff --git a/models/yolov5x.yaml b/models/yolov5x.yaml index c7ca035..7dcb822 100644 --- a/models/yolov5x.yaml +++ b/models/yolov5x.yaml @@ -1,3 +1,5 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license + # Parameters nc: 80 # number of classes depth_multiple: 1.33 # model depth multiple diff --git a/train.py b/train.py index 24152f1..0aa7a13 100644 --- a/train.py +++ b/train.py @@ -1,4 +1,6 @@ -"""Train a YOLOv5 model on a custom dataset +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license +""" +Train a YOLOv5 model on a custom dataset Usage: $ python path/to/train.py --data coco128.yaml --weights yolov5s.pt --img 640 @@ -6,6 +8,7 @@ Usage: import argparse import logging +import math import os import random import sys @@ -13,7 +16,6 @@ import time from copy import deepcopy from pathlib import Path -import math import numpy as np import torch import torch.distributed as dist diff --git a/utils/activations.py b/utils/activations.py index 92a3b5e..62eb532 100644 --- a/utils/activations.py +++ b/utils/activations.py @@ -1,4 +1,7 @@ -# Activation functions +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license +""" +Activation functions +""" import torch import torch.nn as nn diff --git a/utils/augmentations.py b/utils/augmentations.py index cf64f2f..49f957e 100644 --- a/utils/augmentations.py +++ b/utils/augmentations.py @@ -1,10 +1,13 @@ -# YOLOv5 image augmentation functions +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license +""" +Image augmentation functions +""" import logging +import math import random import cv2 -import math import numpy as np from utils.general import colorstr, segment2box, resample_segments, check_version diff --git a/utils/autoanchor.py b/utils/autoanchor.py index eca1d5b..66a2712 100644 --- a/utils/autoanchor.py +++ b/utils/autoanchor.py @@ -1,4 +1,7 @@ -# Auto-anchor utils +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license +""" +Auto-anchor utils +""" import random diff --git a/utils/callbacks.py b/utils/callbacks.py index a204ec1..19c3344 100644 --- a/utils/callbacks.py +++ b/utils/callbacks.py @@ -1,4 +1,8 @@ -#!/usr/bin/env python +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license +""" +Callback utils +""" + class Callbacks: """" diff --git a/utils/datasets.py b/utils/datasets.py index b402723..7d831cd 100755 --- a/utils/datasets.py +++ b/utils/datasets.py @@ -1,4 +1,7 @@ -# YOLOv5 dataset utils and dataloaders +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license +""" +Dataloaders and dataset utils +""" import glob import hashlib diff --git a/utils/downloads.py b/utils/downloads.py index 6b2c374..27cb899 100644 --- a/utils/downloads.py +++ b/utils/downloads.py @@ -1,4 +1,7 @@ -# Download utils +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license +""" +Download utils +""" import os import platform diff --git a/utils/flask_rest_api/README.md b/utils/flask_rest_api/README.md index 6c83593..a726acb 100644 --- a/utils/flask_rest_api/README.md +++ b/utils/flask_rest_api/README.md @@ -1,9 +1,13 @@ # Flask REST API -[REST](https://en.wikipedia.org/wiki/Representational_state_transfer) [API](https://en.wikipedia.org/wiki/API)s are commonly used to expose Machine Learning (ML) models to other services. This folder contains an example REST API created using Flask to expose the YOLOv5s model from [PyTorch Hub](https://pytorch.org/hub/ultralytics_yolov5/). + +[REST](https://en.wikipedia.org/wiki/Representational_state_transfer) [API](https://en.wikipedia.org/wiki/API)s are +commonly used to expose Machine Learning (ML) models to other services. This folder contains an example REST API +created using Flask to expose the YOLOv5s model from [PyTorch Hub](https://pytorch.org/hub/ultralytics_yolov5/). ## Requirements [Flask](https://palletsprojects.com/p/flask/) is required. Install with: + ```shell $ pip install Flask ``` @@ -65,4 +69,5 @@ The model inference results are returned as a JSON response: ] ``` -An example python script to perform inference using [requests](https://docs.python-requests.org/en/master/) is given in `example_request.py` +An example python script to perform inference using [requests](https://docs.python-requests.org/en/master/) is given +in `example_request.py` diff --git a/utils/general.py b/utils/general.py index 4fc32f5..850ca6b 100755 --- a/utils/general.py +++ b/utils/general.py @@ -1,8 +1,12 @@ -# YOLOv5 general utils +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license +""" +General utils +""" import contextlib import glob import logging +import math import os import platform import random @@ -16,7 +20,6 @@ from pathlib import Path from subprocess import check_output import cv2 -import math import numpy as np import pandas as pd import pkg_resources as pkg diff --git a/utils/loggers/__init__.py b/utils/loggers/__init__.py index d40c0c3..3d67e93 100644 --- a/utils/loggers/__init__.py +++ b/utils/loggers/__init__.py @@ -1,4 +1,8 @@ -# YOLOv5 experiment logging utils +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license +""" +Logging utils +""" + import warnings from threading import Thread diff --git a/utils/loggers/wandb/wandb_utils.py b/utils/loggers/wandb/wandb_utils.py index 019aebf..4631e8a 100644 --- a/utils/loggers/wandb/wandb_utils.py +++ b/utils/loggers/wandb/wandb_utils.py @@ -507,4 +507,4 @@ def all_logging_disabled(highest_level=logging.CRITICAL): try: yield finally: - logging.disable(previous_level) \ No newline at end of file + logging.disable(previous_level) diff --git a/utils/loss.py b/utils/loss.py index 79e8f24..29aac31 100644 --- a/utils/loss.py +++ b/utils/loss.py @@ -1,4 +1,7 @@ -# Loss functions +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license +""" +Loss functions +""" import torch import torch.nn as nn diff --git a/utils/metrics.py b/utils/metrics.py index c94c4a7..ddc4259 100644 --- a/utils/metrics.py +++ b/utils/metrics.py @@ -1,9 +1,12 @@ -# Model validation metrics +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license +""" +Model validation metrics +""" +import math import warnings from pathlib import Path -import math import matplotlib.pyplot as plt import numpy as np import torch diff --git a/utils/plots.py b/utils/plots.py index 71e90b0..76c161a 100644 --- a/utils/plots.py +++ b/utils/plots.py @@ -1,4 +1,7 @@ -# Plotting utils +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license +""" +Plotting utils +""" import math from copy import copy diff --git a/utils/torch_utils.py b/utils/torch_utils.py index 628f672..dff0617 100644 --- a/utils/torch_utils.py +++ b/utils/torch_utils.py @@ -1,7 +1,11 @@ -# YOLOv5 PyTorch utils +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license +""" +PyTorch utils +""" import datetime import logging +import math import os import platform import subprocess @@ -10,7 +14,6 @@ from contextlib import contextmanager from copy import deepcopy from pathlib import Path -import math import torch import torch.backends.cudnn as cudnn import torch.distributed as dist diff --git a/val.py b/val.py index 4c1d7d2..cbee8cf 100644 --- a/val.py +++ b/val.py @@ -1,4 +1,6 @@ -"""Validate a trained YOLOv5 model accuracy on a custom dataset +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license +""" +Validate a trained YOLOv5 model accuracy on a custom dataset Usage: $ python path/to/val.py --data coco128.yaml --weights yolov5s.pt --img 640