Skip to content

Commit

Permalink
[Bug-fix] Remove non-conditional reading of kwargs (#220)
Browse files Browse the repository at this point in the history
* Avoid parsing args if skip_parse is set to True

* Fix bug

* Actual bug fix

* Add train script update as well
  • Loading branch information
KSGulin authored Jun 26, 2023
1 parent cd02ab8 commit b5bc91d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions export.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,13 +676,12 @@ def parse_opt(skip_parse=False):
default=None,
help="local path or SparseZoo stub to a recipe to be applied"
" in one-shot manner before exporting")
opt = parser.parse_args()
print_args(vars(opt))

if skip_parse:
opt = parser.parse_args([])
else:
opt = parser.parse_args()
print_args(vars(opt))
return opt


Expand All @@ -691,7 +690,7 @@ def main(opt):
run(**vars(opt))

def export_run(**kwargs):
opt = parse_opt() if not kwargs else parse_opt(skip_parse=True)
opt = parse_opt(True, skip_parse=bool(kwargs))
for k, v in kwargs.items():
setattr(opt, k, v)
main(opt)
Expand Down
2 changes: 1 addition & 1 deletion train.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ def main(opt, callbacks=Callbacks()):

def run(**kwargs):
# Usage: import train; train.run(data='coco128.yaml', imgsz=320, weights='yolov5m.pt')
opt = parse_opt(True)
opt = parse_opt(True, skip_parse=bool(kwargs))
for k, v in kwargs.items():
setattr(opt, k, v)
main(opt)
Expand Down

0 comments on commit b5bc91d

Please sign in to comment.