|
76 | 76 |
|
77 | 77 |
|
78 | 78 | def train(opt, device): |
79 | | - """Trains a YOLOv5 model, managing datasets, model optimization, logging, and saving checkpoints.""" |
| 79 | + """Trains a YOLOv5 model on a dataset, managing data loading, optimization, logging, and checkpoint saving.""" |
80 | 80 | init_seeds(opt.seed + 1 + RANK, deterministic=True) |
81 | 81 | save_dir, data, bs, epochs, nw, imgsz, pretrained = ( |
82 | 82 | opt.save_dir, |
@@ -311,9 +311,7 @@ def lf(x): |
311 | 311 |
|
312 | 312 |
|
313 | 313 | def parse_opt(known=False): |
314 | | - """Parses command line arguments for YOLOv5 training including model path, dataset, epochs, and more, returning |
315 | | - parsed arguments. |
316 | | - """ |
| 314 | + """Parses command line arguments for YOLOv5 training, returning parsed arguments.""" |
317 | 315 | parser = argparse.ArgumentParser() |
318 | 316 | parser.add_argument("--model", type=str, default="yolov5s-cls.pt", help="initial weights path") |
319 | 317 | parser.add_argument("--data", type=str, default="imagenette160", help="cifar10, cifar100, mnist, imagenet, ...") |
@@ -367,8 +365,17 @@ def main(opt): |
367 | 365 | def run(**kwargs): |
368 | 366 | """ |
369 | 367 | Executes YOLOv5 model training or inference with specified parameters, returning updated options. |
370 | | -
|
371 | | - Example: from yolov5 import classify; classify.train.run(data=mnist, imgsz=320, model='yolov5m') |
| 368 | + |
| 369 | + Args: |
| 370 | + **kwargs (Any): Arbitrary keyword arguments to override default training or inference options. |
| 371 | + |
| 372 | + Returns: |
| 373 | + (argparse.Namespace): Updated options after parsing and applying overrides. |
| 374 | + |
| 375 | + Examples: |
| 376 | + Run YOLOv5 training with custom parameters |
| 377 | + >>> from yolov5 import classify |
| 378 | + >>> classify.train.run(data='mnist', imgsz=320, model='yolov5m') |
372 | 379 | """ |
373 | 380 | opt = parse_opt(True) |
374 | 381 | for k, v in kwargs.items(): |
|
0 commit comments