From 8a72424816037562941c67f5a6f0c96ac0d866ac Mon Sep 17 00:00:00 2001 From: UltralyticsAssistant Date: Mon, 26 Aug 2024 00:20:37 +0000 Subject: [PATCH] Auto-format by https://ultralytics.com/actions --- README.md | 2 -- export.py | 4 ++-- hubconf.py | 2 +- models/tf.py | 2 +- segment/val.py | 2 +- utils/dataloaders.py | 4 ++-- utils/loggers/__init__.py | 2 +- utils/loggers/clearml/clearml_utils.py | 2 +- utils/loggers/wandb/wandb_utils.py | 4 ++-- utils/metrics.py | 2 +- utils/plots.py | 2 +- utils/segment/general.py | 12 ++++++------ utils/segment/metrics.py | 6 +++--- utils/torch_utils.py | 4 ++-- utils/triton.py | 2 +- 15 files changed, 25 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 7b215a42fb..e4314803be 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,6 @@ YOLOv3 🚀 is the world's most loved vision AI, representing Ultralytics open-source research into future vision AI methods, incorporating lessons learned and best practices evolved over thousands of hours of research and development. - - We hope that the resources here will help you get the most out of YOLOv3. Please browse the YOLOv3 Docs for details, raise an issue on GitHub for support, and join our Discord community for questions and discussions! To request an Enterprise License please complete the form at [Ultralytics Licensing](https://ultralytics.com/license). diff --git a/export.py b/export.py index 182f544c69..fad82dbac6 100644 --- a/export.py +++ b/export.py @@ -1,6 +1,6 @@ # Ultralytics YOLOv3 🚀, AGPL-3.0 license """ -Export a YOLOv3 PyTorch model to other formats. TensorFlow exports authored by https://github.com/zldrobit +Export a YOLOv3 PyTorch model to other formats. TensorFlow exports authored by https://github.com/zldrobit. Format | `export.py --include` | Model --- | --- | --- @@ -1562,7 +1562,7 @@ def parse_opt(known=False): def main(opt): - """Run(**vars(opt))""" + """Run(**vars(opt)).""" for opt.weights in opt.weights if isinstance(opt.weights, list) else [opt.weights]: run(**vars(opt)) diff --git a/hubconf.py b/hubconf.py index a3e8eef583..7e34f06adc 100644 --- a/hubconf.py +++ b/hubconf.py @@ -1,6 +1,6 @@ # Ultralytics YOLOv3 🚀, AGPL-3.0 license """ -PyTorch Hub models https://pytorch.org/hub/ultralytics_yolov5 +PyTorch Hub models https://pytorch.org/hub/ultralytics_yolov5. Usage: import torch diff --git a/models/tf.py b/models/tf.py index 1731e76a6f..13edcdcfca 100644 --- a/models/tf.py +++ b/models/tf.py @@ -1,7 +1,7 @@ # Ultralytics YOLOv3 🚀, AGPL-3.0 license """ TensorFlow, Keras and TFLite versions of YOLOv3 -Authored by https://github.com/zldrobit in PR https://github.com/ultralytics/yolov5/pull/1127 +Authored by https://github.com/zldrobit in PR https://github.com/ultralytics/yolov5/pull/1127. Usage: $ python models/tf.py --weights yolov5s.pt diff --git a/segment/val.py b/segment/val.py index 619bcc1951..52cf7137ea 100644 --- a/segment/val.py +++ b/segment/val.py @@ -115,7 +115,7 @@ def process_batch(detections, labels, iouv, pred_masks=None, gt_masks=None, over detections (array[N, 6]), x1, y1, x2, y2, conf, class labels (array[M, 5]), class, x1, y1, x2, y2 Returns: - correct (array[N, 10]), for 10 IoU levels + correct (array[N, 10]), for 10 IoU levels. """ if masks: if overlap: diff --git a/utils/dataloaders.py b/utils/dataloaders.py index 96fe83c15e..dc9ff22f3c 100644 --- a/utils/dataloaders.py +++ b/utils/dataloaders.py @@ -92,7 +92,7 @@ def exif_size(img): def exif_transpose(image): """ Transpose a PIL image accordingly if it has an EXIF Orientation tag. - Inplace version of https://github.com/python-pillow/Pillow/blob/master/src/PIL/ImageOps.py exif_transpose() + Inplace version of https://github.com/python-pillow/Pillow/blob/master/src/PIL/ImageOps.py exif_transpose(). :param image: The image to transpose. :return: An image. @@ -1052,7 +1052,7 @@ def extract_boxes(path=DATASETS_DIR / "coco128"): # from utils.dataloaders impo 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() + Usage: from utils.dataloaders import *; autosplit(). Arguments: path: Path to images directory diff --git a/utils/loggers/__init__.py b/utils/loggers/__init__.py index fd9f704a88..0a15554cfa 100644 --- a/utils/loggers/__init__.py +++ b/utils/loggers/__init__.py @@ -339,7 +339,7 @@ def on_params_update(self, params: dict): class GenericLogger: """ YOLOv3 General purpose logger for non-task specific logging - Usage: from utils.loggers import GenericLogger; logger = GenericLogger(...) + Usage: from utils.loggers import GenericLogger; logger = GenericLogger(...). Arguments: opt: Run arguments diff --git a/utils/loggers/clearml/clearml_utils.py b/utils/loggers/clearml/clearml_utils.py index f4841f0376..e9cec6be97 100644 --- a/utils/loggers/clearml/clearml_utils.py +++ b/utils/loggers/clearml/clearml_utils.py @@ -76,7 +76,7 @@ class ClearmlLogger: 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 + - Upload dataset version to ClearML Data if opt.upload_dataset is True. Arguments: opt (namespace) -- Commandline arguments for this run diff --git a/utils/loggers/wandb/wandb_utils.py b/utils/loggers/wandb/wandb_utils.py index 059c0a7ef6..0481339dd6 100644 --- a/utils/loggers/wandb/wandb_utils.py +++ b/utils/loggers/wandb/wandb_utils.py @@ -47,7 +47,7 @@ def __init__(self, opt, run_id=None, job_type="Training"): """ - Initialize WandbLogger instance - Upload dataset if opt.upload_dataset is True - - Setup training processes if job_type is 'Training' + - Setup training processes if job_type is 'Training'. Arguments: opt (namespace) -- Commandline arguments for this run @@ -88,7 +88,7 @@ def setup_training(self, opt): Setup the necessary processes for training YOLO models: - Attempt to download model checkpoint and dataset artifacts if opt.resume stats with WANDB_ARTIFACT_PREFIX - 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 + - Setup log_dict, initialize bbox_interval. Arguments: opt (namespace) -- commandline arguments for this run diff --git a/utils/metrics.py b/utils/metrics.py index 0323398ce5..20d9928359 100644 --- a/utils/metrics.py +++ b/utils/metrics.py @@ -100,7 +100,7 @@ def compute_ap(recall, precision): recall: The recall curve (list) precision: The precision curve (list) # Returns - Average precision, precision curve, recall curve + Average precision, precision curve, recall curve. """ # Append sentinel values to beginning and end mrec = np.concatenate(([0.0], recall, [1.0])) diff --git a/utils/plots.py b/utils/plots.py index 2919133e02..9bb865dcd3 100644 --- a/utils/plots.py +++ b/utils/plots.py @@ -77,7 +77,7 @@ def feature_visualization(x, module_type, stage, n=32, save_dir=Path("runs/detec module_type: Module type stage: Module stage within model n: Maximum number of feature maps to plot - save_dir: Directory to save results + save_dir: Directory to save results. """ if "Detect" not in module_type: batch, channels, height, width = x.shape # batch, channels, height, width diff --git a/utils/segment/general.py b/utils/segment/general.py index 9226065bb5..7ddca4656b 100644 --- a/utils/segment/general.py +++ b/utils/segment/general.py @@ -28,7 +28,7 @@ def process_mask_upsample(protos, masks_in, bboxes, shape): protos: [mask_dim, mask_h, mask_w] masks_in: [n, mask_dim], n is number of masks after nms bboxes: [n, 4], n is number of masks after nms - shape: input_image_size, (h, w) + shape: input_image_size, (h, w). return: h, w, n """ @@ -45,7 +45,7 @@ def process_mask(protos, masks_in, bboxes, shape, upsample=False): proto_out: [mask_dim, mask_h, mask_w] out_masks: [n, mask_dim], n is number of masks after nms bboxes: [n, 4], n is number of masks after nms - shape:input_image_size, (h, w) + shape:input_image_size, (h, w). return: h, w, n """ @@ -71,7 +71,7 @@ def process_mask_native(protos, masks_in, bboxes, shape): protos: [mask_dim, mask_h, mask_w] masks_in: [n, mask_dim], n is number of masks after nms bboxes: [n, 4], n is number of masks after nms - shape: input_image_size, (h, w) + shape: input_image_size, (h, w). return: h, w, n """ @@ -92,7 +92,7 @@ def scale_image(im1_shape, masks, im0_shape, ratio_pad=None): """ img1_shape: model input shape, [h, w] img0_shape: origin pic shape, [h, w, 3] - masks: [h, w, num] + masks: [h, w, num]. """ # Rescale coordinates (xyxy) from im1_shape to im0_shape if ratio_pad is None: # calculate from im0_shape @@ -120,7 +120,7 @@ def mask_iou(mask1, mask2, eps=1e-7): """ mask1: [N, n] m1 means number of predicted objects mask2: [M, n] m2 means number of gt objects - Note: n means image_w x image_h + Note: n means image_w x image_h. return: masks iou, [N, M] """ @@ -133,7 +133,7 @@ def masks_iou(mask1, mask2, eps=1e-7): """ mask1: [N, n] m1 means number of predicted objects mask2: [N, n] m2 means number of gt objects - Note: n means image_w x image_h + Note: n means image_w x image_h. return: masks iou, (N, ) """ diff --git a/utils/segment/metrics.py b/utils/segment/metrics.py index 519604db05..d4689ca015 100644 --- a/utils/segment/metrics.py +++ b/utils/segment/metrics.py @@ -125,7 +125,7 @@ def mean_results(self): return (self.mp, self.mr, self.map50, self.map) def class_result(self, i): - """Class-aware result, return p[i], r[i], ap50[i], ap[i]""" + """Class-aware result, return p[i], r[i], ap50[i], ap[i].""" return (self.p[i], self.r[i], self.ap50[i], self.ap[i]) def get_maps(self, nc): @@ -140,7 +140,7 @@ def get_maps(self, nc): def update(self, results): """ Args: - results: tuple(p, r, ap, f1, ap_class) + results: tuple(p, r, ap, f1, ap_class). """ p, r, all_ap, f1, ap_class_index = results self.p = p @@ -161,7 +161,7 @@ def __init__(self) -> None: def update(self, results): """ Args: - results: Dict{'boxes': Dict{}, 'masks': Dict{}} + results: Dict{'boxes': Dict{}, 'masks': Dict{}}. """ self.metric_box.update(list(results["boxes"].values())) self.metric_mask.update(list(results["masks"].values())) diff --git a/utils/torch_utils.py b/utils/torch_utils.py index 115e4d9f89..b3eb9871e9 100644 --- a/utils/torch_utils.py +++ b/utils/torch_utils.py @@ -165,7 +165,7 @@ def profile(input, ops, n=10, device=None): input = torch.randn(16, 3, 640, 640) m1 = lambda x: x * torch.sigmoid(x) m2 = nn.SiLU() - profile(input, [m1, m2], n=100) # profile over 100 iterations + profile(input, [m1, m2], n=100) # profile over 100 iterations. """ results = [] if not isinstance(device, torch.device): @@ -453,7 +453,7 @@ def __call__(self, epoch, fitness): class ModelEMA: """Updated Exponential Moving Average (EMA) from https://github.com/rwightman/pytorch-image-models Keeps a moving average of everything in the model state_dict (parameters and buffers) - For EMA details see https://www.tensorflow.org/api_docs/python/tf/train/ExponentialMovingAverage + For EMA details see https://www.tensorflow.org/api_docs/python/tf/train/ExponentialMovingAverage. """ def __init__(self, model, decay=0.9999, tau=2000, updates=0): diff --git a/utils/triton.py b/utils/triton.py index 9902dcbf47..dad9dcd472 100644 --- a/utils/triton.py +++ b/utils/triton.py @@ -18,7 +18,7 @@ class TritonRemoteModel: def __init__(self, url: str): """ Keyword Arguments: - url: Fully qualified address of the Triton server - for e.g. grpc://localhost:8000 + url: Fully qualified address of the Triton server - for e.g. grpc://localhost:8000. """ parsed_url = urlparse(url) if parsed_url.scheme == "grpc":