|
96 | 96 |
|
97 | 97 |
|
98 | 98 | def train(hyp, opt, device, callbacks):
|
99 |
| - """ |
100 |
| - Trains the YOLOv5 model on a dataset, managing hyperparameters, model optimization, logging, and validation. |
101 |
| -
|
102 |
| - `hyp` is path/to/hyp.yaml or hyp dictionary. |
103 |
| - """ |
| 99 | + """Trains a YOLOv5 segmentation model on a dataset, handling hyperparameters, optimization, and validation.""" |
104 | 100 | (
|
105 | 101 | save_dir,
|
106 | 102 | epochs,
|
@@ -541,11 +537,7 @@ def lf(x):
|
541 | 537 |
|
542 | 538 |
|
543 | 539 | def parse_opt(known=False):
|
544 |
| - """ |
545 |
| - Parses command line arguments for training configurations, returning parsed arguments. |
546 |
| -
|
547 |
| - Supports both known and unknown args. |
548 |
| - """ |
| 540 | + """Parses command line arguments for YOLOv5 training configurations, supporting both known and unknown arguments.""" |
549 | 541 | parser = argparse.ArgumentParser()
|
550 | 542 | parser.add_argument("--weights", type=str, default=ROOT / "yolov5s-seg.pt", help="initial weights path")
|
551 | 543 | parser.add_argument("--cfg", type=str, default="", help="model.yaml path")
|
@@ -748,9 +740,18 @@ def main(opt, callbacks=Callbacks()):
|
748 | 740 |
|
749 | 741 | def run(**kwargs):
|
750 | 742 | """
|
751 |
| - Executes YOLOv5 training with given parameters, altering options programmatically; returns updated options. |
752 |
| -
|
753 |
| - Example: import train; train.run(data='coco128.yaml', imgsz=320, weights='yolov5m.pt') |
| 743 | + Executes YOLOv5 training with given parameters, altering options programmatically. |
| 744 | + |
| 745 | + Args: |
| 746 | + **kwargs (Any): Keyword arguments to override default training options. |
| 747 | + |
| 748 | + Returns: |
| 749 | + (argparse.Namespace): Updated options after parsing and applying keyword arguments. |
| 750 | + |
| 751 | + Examples: |
| 752 | + Run YOLOv5 training with custom data and image size |
| 753 | + >>> import train |
| 754 | + >>> train.run(data='coco128.yaml', imgsz=320, weights='yolov5m.pt') |
754 | 755 | """
|
755 | 756 | opt = parse_opt(True)
|
756 | 757 | for k, v in kwargs.items():
|
|
0 commit comments