Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added lighter yolov5 config files #11813

Open
wants to merge 65 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
f134a68
added lighter yolov5 config files
jere357 Jul 4, 2023
4a50784
Merge branch 'master' into master
glenn-jocher Jul 4, 2023
a3ff54a
Merge branch 'master' into master
jere357 Jul 12, 2023
2964a99
Merge branch 'master' into master
jere357 Aug 1, 2023
b2c70c5
Merge branch 'master' into master
jere357 Nov 15, 2023
331dbfb
Merge branch 'master' into master
glenn-jocher Jan 17, 2024
18ce5cb
Merge branch 'master' into master
glenn-jocher Jan 17, 2024
1b9e211
Merge branch 'master' into master
glenn-jocher Apr 9, 2024
c1d9d48
Merge branch 'master' into master
UltralyticsAssistant Apr 14, 2024
b90c09a
Merge branch 'master' into master
UltralyticsAssistant Apr 18, 2024
b960329
Merge branch 'master' into master
UltralyticsAssistant Apr 27, 2024
34d6dfd
Merge branch 'master' into master
UltralyticsAssistant Apr 28, 2024
6443e46
Merge branch 'master' into master
UltralyticsAssistant May 5, 2024
8e83e65
Merge branch 'master' into master
UltralyticsAssistant May 12, 2024
d92fd5b
Merge branch 'master' into master
UltralyticsAssistant May 12, 2024
4c4713c
Merge branch 'master' into master
UltralyticsAssistant May 12, 2024
83c3c6f
Merge branch 'master' into master
UltralyticsAssistant May 12, 2024
04cb074
Merge branch 'master' into master
UltralyticsAssistant May 13, 2024
13d08ee
Merge branch 'master' into master
UltralyticsAssistant May 18, 2024
33177dc
Merge branch 'master' into master
UltralyticsAssistant May 24, 2024
e79425c
Merge branch 'master' into master
UltralyticsAssistant May 28, 2024
568bc61
Merge branch 'master' into master
UltralyticsAssistant May 29, 2024
ac88a68
Merge branch 'master' into master
UltralyticsAssistant May 29, 2024
e537a3a
Merge branch 'master' into master
UltralyticsAssistant May 30, 2024
99efda2
Auto-format by https://ultralytics.com/actions
UltralyticsAssistant May 30, 2024
cbe0721
Merge branch 'master' into master
UltralyticsAssistant Jun 8, 2024
5bfa40a
Merge branch 'master' into master
UltralyticsAssistant Jun 8, 2024
a93faf1
Merge branch 'master' into master
UltralyticsAssistant Jun 9, 2024
f92bae4
Merge branch 'master' into master
UltralyticsAssistant Jun 16, 2024
7a1c3f4
Merge branch 'master' into master
UltralyticsAssistant Jun 16, 2024
8aaf21a
Merge branch 'master' into master
UltralyticsAssistant Jun 17, 2024
6cf3f1b
Merge branch 'master' into master
UltralyticsAssistant Jun 19, 2024
001526c
Merge branch 'master' into master
UltralyticsAssistant Jun 19, 2024
b0ec1bc
Merge branch 'master' into master
UltralyticsAssistant Jun 20, 2024
c79bbf6
Merge branch 'master' into master
UltralyticsAssistant Jun 20, 2024
d7b2a3b
Merge branch 'master' into master
UltralyticsAssistant Jun 20, 2024
97a1a40
Merge branch 'master' into master
UltralyticsAssistant Jun 20, 2024
6819d65
Merge branch 'master' into master
UltralyticsAssistant Jun 22, 2024
29480af
Merge branch 'master' into master
UltralyticsAssistant Jun 30, 2024
d09d1c5
Merge branch 'master' into master
UltralyticsAssistant Jun 30, 2024
c642e30
Merge branch 'master' into master
UltralyticsAssistant Jun 30, 2024
162b2f1
Merge branch 'master' into master
UltralyticsAssistant Jul 5, 2024
0fad25f
Merge branch 'master' into master
UltralyticsAssistant Jul 8, 2024
187cd15
Merge branch 'master' into master
UltralyticsAssistant Jul 8, 2024
0a876a1
Merge branch 'master' into master
UltralyticsAssistant Jul 8, 2024
b2464be
Merge branch 'master' into master
UltralyticsAssistant Jul 10, 2024
66af98d
Merge branch 'master' into master
UltralyticsAssistant Jul 13, 2024
14cffd5
Merge branch 'master' into master
UltralyticsAssistant Jul 15, 2024
0ceea87
Merge branch 'master' into master
UltralyticsAssistant Jul 15, 2024
42afc84
Merge branch 'master' into master
UltralyticsAssistant Jul 17, 2024
8e50eee
Merge branch 'master' into master
UltralyticsAssistant Jul 17, 2024
32963c9
Merge branch 'master' into master
UltralyticsAssistant Jul 17, 2024
d1bcd6d
Merge branch 'master' into master
UltralyticsAssistant Jul 22, 2024
e648ec7
Merge branch 'master' into master
UltralyticsAssistant Jul 23, 2024
a86f9f3
Merge branch 'master' into master
UltralyticsAssistant Jul 25, 2024
98be5a3
Merge branch 'master' into master
UltralyticsAssistant Jul 29, 2024
3ed147e
Merge branch 'master' into master
UltralyticsAssistant Jul 29, 2024
44ecdb1
Merge branch 'master' into master
UltralyticsAssistant Aug 11, 2024
2f87b47
Merge branch 'master' into master
UltralyticsAssistant Aug 14, 2024
f6df747
Merge branch 'master' into master
UltralyticsAssistant Aug 14, 2024
11793fb
Merge branch 'master' into master
UltralyticsAssistant Aug 19, 2024
47b7517
Merge branch 'master' into master
UltralyticsAssistant Aug 20, 2024
27dd3d4
Merge branch 'master' into master
UltralyticsAssistant Aug 20, 2024
1ec2016
Merge branch 'master' into master
UltralyticsAssistant Aug 24, 2024
ad6310b
Auto-format by https://ultralytics.com/actions
UltralyticsAssistant Aug 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions export.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ def transform_fn(data_item):
Quantization transform function.

Extracts and preprocess input data from dataloader item for quantization.

Parameters:
data_item: Tuple with data item produced by DataLoader during iteration
Returns:
Expand Down
49 changes: 49 additions & 0 deletions models/yolov5femto.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license

# Parameters
nc: 80 # number of classes
depth_multiple: 0.04 # model depth multiple
width_multiple: 0.03125 # layer channel multiple
anchors:
- [10, 13, 16, 30, 33, 23] # P3/8
- [30, 61, 62, 45, 59, 119] # P4/16
- [116, 90, 156, 198, 373, 326] # P5/32

# YOLOv5 v6.0 backbone
backbone:
# [from, number, module, args]
[
[-1, 1, Conv, [64, 6, 2, 2]], # 0-P1/2
[-1, 1, Conv, [128, 3, 2]], # 1-P2/4
[-1, 3, C3, [128]],
[-1, 1, Conv, [256, 3, 2]], # 3-P3/8
[-1, 6, C3, [256]],
[-1, 1, Conv, [512, 3, 2]], # 5-P4/16
[-1, 9, C3, [512]],
[-1, 1, Conv, [1024, 3, 2]], # 7-P5/32
[-1, 3, C3, [1024]],
[-1, 1, SPPF, [1024, 5]], # 9
]

# YOLOv5 v6.0 head
head: [
[-1, 1, Conv, [512, 1, 1]],
[-1, 1, nn.Upsample, [None, 2, "nearest"]],
[[-1, 6], 1, Concat, [1]], # cat backbone P4
[-1, 3, C3, [512, False]], # 13

[-1, 1, Conv, [256, 1, 1]],
[-1, 1, nn.Upsample, [None, 2, "nearest"]],
[[-1, 4], 1, Concat, [1]], # cat backbone P3
[-1, 3, C3, [256, False]], # 17 (P3/8-small)

[-1, 1, Conv, [256, 3, 2]],
[[-1, 14], 1, Concat, [1]], # cat head P4
[-1, 3, C3, [512, False]], # 20 (P4/16-medium)

[-1, 1, Conv, [512, 3, 2]],
[[-1, 10], 1, Concat, [1]], # cat head P5
[-1, 3, C3, [1024, False]], # 23 (P5/32-large)

[[17, 20, 23], 1, Detect, [nc, anchors]], # Detect(P3, P4, P5)
]
49 changes: 49 additions & 0 deletions models/yolov5micro.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license

# Parameters
nc: 80 # number of classes
depth_multiple: 0.16 # model depth multiple
width_multiple: 0.125 # layer channel multiple
anchors:
- [10, 13, 16, 30, 33, 23] # P3/8
- [30, 61, 62, 45, 59, 119] # P4/16
- [116, 90, 156, 198, 373, 326] # P5/32

# YOLOv5 v6.0 backbone
backbone:
# [from, number, module, args]
[
[-1, 1, Conv, [64, 6, 2, 2]], # 0-P1/2
[-1, 1, Conv, [128, 3, 2]], # 1-P2/4
[-1, 3, C3, [128]],
[-1, 1, Conv, [256, 3, 2]], # 3-P3/8
[-1, 6, C3, [256]],
[-1, 1, Conv, [512, 3, 2]], # 5-P4/16
[-1, 9, C3, [512]],
[-1, 1, Conv, [1024, 3, 2]], # 7-P5/32
[-1, 3, C3, [1024]],
[-1, 1, SPPF, [1024, 5]], # 9
]

# YOLOv5 v6.0 head
head: [
[-1, 1, Conv, [512, 1, 1]],
[-1, 1, nn.Upsample, [None, 2, "nearest"]],
[[-1, 6], 1, Concat, [1]], # cat backbone P4
[-1, 3, C3, [512, False]], # 13

[-1, 1, Conv, [256, 1, 1]],
[-1, 1, nn.Upsample, [None, 2, "nearest"]],
[[-1, 4], 1, Concat, [1]], # cat backbone P3
[-1, 3, C3, [256, False]], # 17 (P3/8-small)

[-1, 1, Conv, [256, 3, 2]],
[[-1, 14], 1, Concat, [1]], # cat head P4
[-1, 3, C3, [512, False]], # 20 (P4/16-medium)

[-1, 1, Conv, [512, 3, 2]],
[[-1, 10], 1, Concat, [1]], # cat head P5
[-1, 3, C3, [1024, False]], # 23 (P5/32-large)

[[17, 20, 23], 1, Detect, [nc, anchors]], # Detect(P3, P4, P5)
]
49 changes: 49 additions & 0 deletions models/yolov5pico.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license

# Parameters
nc: 80 # number of classes
depth_multiple: 0.08 # model depth multiple
width_multiple: 0.0625 # layer channel multiple
anchors:
- [10, 13, 16, 30, 33, 23] # P3/8
- [30, 61, 62, 45, 59, 119] # P4/16
- [116, 90, 156, 198, 373, 326] # P5/32

# YOLOv5 v6.0 backbone
backbone:
# [from, number, module, args]
[
[-1, 1, Conv, [64, 6, 2, 2]], # 0-P1/2
[-1, 1, Conv, [128, 3, 2]], # 1-P2/4
[-1, 3, C3, [128]],
[-1, 1, Conv, [256, 3, 2]], # 3-P3/8
[-1, 6, C3, [256]],
[-1, 1, Conv, [512, 3, 2]], # 5-P4/16
[-1, 9, C3, [512]],
[-1, 1, Conv, [1024, 3, 2]], # 7-P5/32
[-1, 3, C3, [1024]],
[-1, 1, SPPF, [1024, 5]], # 9
]

# YOLOv5 v6.0 head
head: [
[-1, 1, Conv, [512, 1, 1]],
[-1, 1, nn.Upsample, [None, 2, "nearest"]],
[[-1, 6], 1, Concat, [1]], # cat backbone P4
[-1, 3, C3, [512, False]], # 13

[-1, 1, Conv, [256, 1, 1]],
[-1, 1, nn.Upsample, [None, 2, "nearest"]],
[[-1, 4], 1, Concat, [1]], # cat backbone P3
[-1, 3, C3, [256, False]], # 17 (P3/8-small)

[-1, 1, Conv, [256, 3, 2]],
[[-1, 14], 1, Concat, [1]], # cat head P4
[-1, 3, C3, [512, False]], # 20 (P4/16-medium)

[-1, 1, Conv, [512, 3, 2]],
[[-1, 10], 1, Concat, [1]], # cat head P5
[-1, 3, C3, [1024, False]], # 23 (P5/32-large)

[[17, 20, 23], 1, Detect, [nc, anchors]], # Detect(P3, P4, P5)
]
1 change: 0 additions & 1 deletion utils/augmentations.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ def random_perspective(
):
# torchvision.transforms.RandomAffine(degrees=(-10, 10), translate=(0.1, 0.1), scale=(0.9, 1.1), shear=(-10, 10))
# targets = [cls, xyxy]

"""Applies random perspective transformation to an image, modifying the image and corresponding labels."""
height = im.shape[0] + border[0] * 2 # shape(h,w,c)
width = im.shape[1] + border[1] * 2
Expand Down
1 change: 0 additions & 1 deletion utils/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def run(self, hook, *args, thread=False, **kwargs):
thread: (boolean) Run callbacks in daemon thread
kwargs: Keyword Arguments to receive from YOLOv5
"""

assert hook in self._callbacks, f"hook '{hook}' not found in callbacks {self._callbacks}"
for logger in self._callbacks[hook]:
if thread:
Expand Down
7 changes: 4 additions & 3 deletions utils/dataloaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,8 @@ def extract_boxes(path=DATASETS_DIR / "coco128"):
def autosplit(path=DATASETS_DIR / "coco128/images", weights=(0.9, 0.1, 0.0), annotated_only=False):
"""Autosplit a dataset into train/val/test splits and save path/autosplit_*.txt files
Usage: from utils.dataloaders import *; autosplit()
Arguments

Arguments:
path: Path to images directory
weights: Train, val, test weights (list, tuple)
annotated_only: Only use images with an annotated txt file
Expand Down Expand Up @@ -1183,7 +1184,7 @@ class HUBDatasetStats:
"""
Class for generating HUB dataset JSON and `-hub` dataset directory.

Arguments
Arguments:
path: Path to data.yaml or data.zip (with data.yaml inside data.zip)
autodownload: Attempt to download dataset if not found locally

Expand Down Expand Up @@ -1314,7 +1315,7 @@ class ClassificationDataset(torchvision.datasets.ImageFolder):
"""
YOLOv5 Classification Dataset.

Arguments
Arguments:
root: Dataset path
transform: torchvision transforms, used by default
album_transform: Albumentations transforms, used if installed
Expand Down
2 changes: 0 additions & 2 deletions utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,6 @@ def check_font(font=FONT, progress=False):

def check_dataset(data, autodownload=True):
"""Validates and/or auto-downloads a dataset, returning its configuration as a dictionary."""

# Download (optional)
extract_dir = ""
if isinstance(data, (str, Path)) and (is_zipfile(data) or is_tarfile(data)):
Expand Down Expand Up @@ -1023,7 +1022,6 @@ def non_max_suppression(
Returns:
list of detections, on (n,6) tensor per image [xyxy, conf, cls]
"""

# Checks
assert 0 <= conf_thres <= 1, f"Invalid Confidence threshold {conf_thres}, valid values are between 0.0 and 1.0"
assert 0 <= iou_thres <= 1, f"Invalid IoU {iou_thres}, valid values are between 0.0 and 1.0"
Expand Down
3 changes: 2 additions & 1 deletion utils/loggers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ class GenericLogger:
"""
YOLOv5 General purpose logger for non-task specific logging
Usage: from utils.loggers import GenericLogger; logger = GenericLogger(...)
Arguments

Arguments:
opt: Run arguments
console_logger: Console logger
include: loggers to include
Expand Down
14 changes: 7 additions & 7 deletions utils/loggers/clearml/clearml_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def __init__(self, opt, hyp):
- Initialize ClearML Task, this object will capture the experiment
- Upload dataset version to ClearML Data if opt.upload_dataset is True

arguments:
Arguments:
opt (namespace) -- Commandline arguments for this run
hyp (dict) -- Hyperparameters for this run

Expand Down Expand Up @@ -133,7 +133,7 @@ def log_scalars(self, metrics, epoch):
"""
Log scalars/metrics to ClearML.

arguments:
Arguments:
metrics (dict) Metrics in dict format: {"metrics/mAP": 0.8, ...}
epoch (int) iteration number for the current set of metrics
"""
Expand All @@ -145,7 +145,7 @@ def log_model(self, model_path, model_name, epoch=0):
"""
Log model weights to ClearML.

arguments:
Arguments:
model_path (PosixPath or str) Path to the model weights
model_name (str) Name of the model visible in ClearML
epoch (int) Iteration / epoch of the model weights
Expand All @@ -158,7 +158,7 @@ def log_summary(self, metrics):
"""
Log final metrics to a summary table.

arguments:
Arguments:
metrics (dict) Metrics in dict format: {"metrics/mAP": 0.8, ...}
"""
for k, v in metrics.items():
Expand All @@ -168,7 +168,7 @@ def log_plot(self, title, plot_path):
"""
Log image as plot in the plot section of ClearML.

arguments:
Arguments:
title (str) Title of the plot
plot_path (PosixPath or str) Path to the saved image file
"""
Expand All @@ -183,7 +183,7 @@ def log_debug_samples(self, files, title="Debug Samples"):
"""
Log files (images) as debug samples in the ClearML task.

arguments:
Arguments:
files (List(PosixPath)) a list of file paths in PosixPath format
title (str) A title that groups together images with the same values
"""
Expand All @@ -199,7 +199,7 @@ def log_image_with_boxes(self, image_path, boxes, class_names, image, conf_thres
"""
Draw the bounding boxes on a single image and report the result as a ClearML debug sample.

arguments:
Arguments:
image_path (PosixPath) the path the original image file
boxes (list): list of scaled predictions in the format - [xmin, ymin, xmax, ymax, confidence, class]
class_names (dict): dict containing mapping of class int to class name
Expand Down
12 changes: 6 additions & 6 deletions utils/loggers/wandb/wandb_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(self, opt, run_id=None, job_type="Training"):
- Upload dataset if opt.upload_dataset is True
- Setup training processes if job_type is 'Training'

arguments:
Arguments:
opt (namespace) -- Commandline arguments for this run
run_id (str) -- Run ID of W&B run to be resumed
job_type (str) -- To set the job_type for this run
Expand Down Expand Up @@ -90,7 +90,7 @@ def setup_training(self, opt):
- Update data_dict, to contain info of previous run if resumed and the paths of dataset artifact if downloaded
- Setup log_dict, initialize bbox_interval

arguments:
Arguments:
opt (namespace) -- commandline arguments for this run

"""
Expand Down Expand Up @@ -120,7 +120,7 @@ def log_model(self, path, opt, epoch, fitness_score, best_model=False):
"""
Log the model checkpoint as W&B artifact.

arguments:
Arguments:
path (Path) -- Path of directory containing the checkpoints
opt (namespace) -- Command line arguments for this run
epoch (int) -- Current epoch number
Expand Down Expand Up @@ -159,7 +159,7 @@ def log(self, log_dict):
"""
Save the metrics to the logging dictionary.

arguments:
Arguments:
log_dict (Dict) -- metrics/media to be logged in current step
"""
if self.wandb_run:
Expand All @@ -170,7 +170,7 @@ def end_epoch(self):
"""
Commit the log_dict, model artifacts and Tables to W&B and flush the log_dict.

arguments:
Arguments:
best_result (boolean): Boolean representing if the result of this evaluation is best or not
"""
if self.wandb_run:
Expand All @@ -197,7 +197,7 @@ def finish_run(self):

@contextmanager
def all_logging_disabled(highest_level=logging.CRITICAL):
"""source - https://gist.github.com/simon-weber/7853144
"""Source - https://gist.github.com/simon-weber/7853144
A context manager that will prevent any logging messages triggered during the body from being processed.
:param highest_level: the maximum logging level in use.
This would only need to be changed if a custom level greater than CRITICAL is defined.
Expand Down
Loading