Skip to content

Commit

Permalink
Standardize headers and docstrings (#4417)
Browse files Browse the repository at this point in the history
* Implement new headers

* Reformat 1

* Reformat 2

* Reformat 3 - math

* Reformat 4 - yaml
  • Loading branch information
glenn-jocher authored Aug 14, 2021
1 parent bb0aed1 commit 24bea5e
Show file tree
Hide file tree
Showing 64 changed files with 164 additions and 54 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/ci-testing.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/greetings.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rebase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Automatic Rebase

on:
issue_comment:
types: [ created ]
types: [created]

jobs:
rebase:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license

name: Close stale issues
on:
schedule:
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion data/Argoverse.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion data/GlobalWheat2020.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion data/Objects365.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion data/SKU-110K.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion data/VOC.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion data/VisDrone.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion data/coco.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion data/coco128.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion data/hyps/hyp.finetune.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions data/hyps/hyp.finetune_objects365.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license

lr0: 0.00258
lrf: 0.17
momentum: 0.779
Expand Down
2 changes: 1 addition & 1 deletion data/hyps/hyp.scratch-p6.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion data/hyps/hyp.scratch.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion data/scripts/download_weights.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion data/scripts/get_coco.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion data/scripts/get_coco128.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion data/xView.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion detect.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion export.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion hubconf.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 5 additions & 2 deletions models/common.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 5 additions & 2 deletions models/experimental.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
3 changes: 2 additions & 1 deletion models/hub/anchors.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Default YOLOv5 anchors for COCO data
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license
# Default anchors for COCO data


# P5 -------------------------------------------------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions models/hub/yolov3-spp.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license

# Parameters
nc: 80 # number of classes
depth_multiple: 1.0 # model depth multiple
Expand Down
2 changes: 2 additions & 0 deletions models/hub/yolov3-tiny.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license

# Parameters
nc: 80 # number of classes
depth_multiple: 1.0 # model depth multiple
Expand Down
2 changes: 2 additions & 0 deletions models/hub/yolov3.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license

# Parameters
nc: 80 # number of classes
depth_multiple: 1.0 # model depth multiple
Expand Down
2 changes: 2 additions & 0 deletions models/hub/yolov5-bifpn.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license

# Parameters
nc: 80 # number of classes
depth_multiple: 1.0 # model depth multiple
Expand Down
2 changes: 2 additions & 0 deletions models/hub/yolov5-fpn.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license

# Parameters
nc: 80 # number of classes
depth_multiple: 1.0 # model depth multiple
Expand Down
2 changes: 2 additions & 0 deletions models/hub/yolov5-p2.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license

# Parameters
nc: 80 # number of classes
depth_multiple: 1.0 # model depth multiple
Expand Down
2 changes: 2 additions & 0 deletions models/hub/yolov5-p6.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license

# Parameters
nc: 80 # number of classes
depth_multiple: 1.0 # model depth multiple
Expand Down
2 changes: 2 additions & 0 deletions models/hub/yolov5-p7.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license

# Parameters
nc: 80 # number of classes
depth_multiple: 1.0 # model depth multiple
Expand Down
2 changes: 2 additions & 0 deletions models/hub/yolov5-panet.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license

# Parameters
nc: 80 # number of classes
depth_multiple: 1.0 # model depth multiple
Expand Down
2 changes: 2 additions & 0 deletions models/hub/yolov5l6.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license

# Parameters
nc: 80 # number of classes
depth_multiple: 1.0 # model depth multiple
Expand Down
2 changes: 2 additions & 0 deletions models/hub/yolov5m6.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license

# Parameters
nc: 80 # number of classes
depth_multiple: 0.67 # model depth multiple
Expand Down
2 changes: 2 additions & 0 deletions models/hub/yolov5s-ghost.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license

# Parameters
nc: 80 # number of classes
depth_multiple: 0.33 # model depth multiple
Expand Down
2 changes: 2 additions & 0 deletions models/hub/yolov5s-transformer.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license

# Parameters
nc: 80 # number of classes
depth_multiple: 0.33 # model depth multiple
Expand Down
2 changes: 2 additions & 0 deletions models/hub/yolov5s6.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license

# Parameters
nc: 80 # number of classes
depth_multiple: 0.33 # model depth multiple
Expand Down
2 changes: 2 additions & 0 deletions models/hub/yolov5x6.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license

# Parameters
nc: 80 # number of classes
depth_multiple: 1.33 # model depth multiple
Expand Down
4 changes: 3 additions & 1 deletion models/yolo.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions models/yolov5l.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license

# Parameters
nc: 80 # number of classes
depth_multiple: 1.0 # model depth multiple
Expand Down
2 changes: 2 additions & 0 deletions models/yolov5m.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license

# Parameters
nc: 80 # number of classes
depth_multiple: 0.67 # model depth multiple
Expand Down
2 changes: 2 additions & 0 deletions models/yolov5s.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license

# Parameters
nc: 80 # number of classes
depth_multiple: 0.33 # model depth multiple
Expand Down
2 changes: 2 additions & 0 deletions models/yolov5x.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license

# Parameters
nc: 80 # number of classes
depth_multiple: 1.33 # model depth multiple
Expand Down
6 changes: 4 additions & 2 deletions train.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
"""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
"""

import argparse
import logging
import math
import os
import random
import sys
import time
from copy import deepcopy
from pathlib import Path

import math
import numpy as np
import torch
import torch.distributed as dist
Expand Down
5 changes: 4 additions & 1 deletion utils/activations.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Activation functions
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license
"""
Activation functions
"""

import torch
import torch.nn as nn
Expand Down
Loading

0 comments on commit 24bea5e

Please sign in to comment.