Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/docstrings' into docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
glenn-jocher committed Feb 25, 2024
2 parents 0633078 + 4aaaf6a commit ae89774
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
10 changes: 7 additions & 3 deletions classify/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@ def train(opt, device):


def parse_opt(known=False):
"""Parses command line arguments for YOLOv5 training including model path, dataset, epochs, and more, returning parsed arguments."""
"""Parses command line arguments for YOLOv5 training including model path, dataset, epochs, and more, returning
parsed arguments.
"""
parser = argparse.ArgumentParser()
parser.add_argument("--model", type=str, default="yolov5s-cls.pt", help="initial weights path")
parser.add_argument("--data", type=str, default="imagenette160", help="cifar10, cifar100, mnist, imagenet, ...")
Expand Down Expand Up @@ -359,9 +361,11 @@ def main(opt):


def run(**kwargs):
"""Executes YOLOv5 model training or inference with specified parameters, returning updated options.
"""
Executes YOLOv5 model training or inference with specified parameters, returning updated options.
Example: from yolov5 import classify; classify.train.run(data=mnist, imgsz=320, model='yolov5m')"""
Example: from yolov5 import classify; classify.train.run(data=mnist, imgsz=320, model='yolov5m')
"""
opt = parse_opt(True)
for k, v in kwargs.items():
setattr(opt, k, v)
Expand Down
4 changes: 3 additions & 1 deletion segment/predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ def run(


def parse_opt():
"""Parses command-line options for YOLOv5 inference including model paths, data sources, inference settings, and output preferences."""
"""Parses command-line options for YOLOv5 inference including model paths, data sources, inference settings, and
output preferences.
"""
parser = argparse.ArgumentParser()
parser.add_argument("--weights", nargs="+", type=str, default=ROOT / "yolov5s-seg.pt", help="model path(s)")
parser.add_argument("--source", type=str, default=ROOT / "data/images", help="file/dir/URL/glob/screen/0(webcam)")
Expand Down
12 changes: 9 additions & 3 deletions segment/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,11 @@ def train(hyp, opt, device, callbacks): # hyp is path/to/hyp.yaml or hyp dictio


def parse_opt(known=False):
"""Parses command line arguments for training configurations, returning parsed arguments. Supports both known and unknown args."""
"""
Parses command line arguments for training configurations, returning parsed arguments.
Supports both known and unknown args.
"""
parser = argparse.ArgumentParser()
parser.add_argument("--weights", type=str, default=ROOT / "yolov5s-seg.pt", help="initial weights path")
parser.add_argument("--cfg", type=str, default="", help="model.yaml path")
Expand Down Expand Up @@ -734,9 +738,11 @@ def main(opt, callbacks=Callbacks()):


def run(**kwargs):
"""Executes YOLOv5 training with given parameters, altering options programmatically; returns updated options.
"""
Executes YOLOv5 training with given parameters, altering options programmatically; returns updated options.
Example: mport train; train.run(data='coco128.yaml', imgsz=320, weights='yolov5m.pt')"""
Example: mport train; train.run(data='coco128.yaml', imgsz=320, weights='yolov5m.pt')
"""
opt = parse_opt(True)
for k, v in kwargs.items():
setattr(opt, k, v)
Expand Down
4 changes: 3 additions & 1 deletion utils/flask_rest_api/restapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

@app.route(DETECTION_URL, methods=["POST"])
def predict(model):
"""Predict and return object detections in JSON format given an image and model name via a Flask REST API POST request."""
"""Predict and return object detections in JSON format given an image and model name via a Flask REST API POST
request.
"""
if request.method != "POST":
return

Expand Down
3 changes: 2 additions & 1 deletion utils/segment/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ def plot_images_and_masks(images, targets, masks, paths=None, fname="images.jpg"


def plot_results_with_masks(file="path/to/results.csv", dir="", best=True):
"""Plots training results from CSV files, plotting best or last result highlights based on `best` parameter.
"""
Plots training results from CSV files, plotting best or last result highlights based on `best` parameter.
Example: from utils.plots import *; plot_results('path/to/results.csv')
"""
Expand Down

0 comments on commit ae89774

Please sign in to comment.