mirror of
https://github.com/ultralytics/yolov5.git
synced 2025-06-03 14:49:29 +08:00
Fix increment_dir to use run_xxx for logdir (#1058)
* Fix increment_dir to use run_xxx for logdir Rerunning train.py with logdir in the form of `run_xxx` causes index slicing in ``` n = max([int(x[len(dir):x.find('_') if '_' in Path(x).name else None]) for x in d]) + 1 # increment ``` to underflow. * Replace find with rfind
This commit is contained in:
parent
35fe98543c
commit
c5d2331897
@ -948,7 +948,7 @@ def increment_dir(dir, comment=''):
|
||||
dir = str(Path(dir)) # os-agnostic
|
||||
d = sorted(glob.glob(dir + '*')) # directories
|
||||
if len(d):
|
||||
n = max([int(x[len(dir):x.find('_') if '_' in x else None]) for x in d]) + 1 # increment
|
||||
n = max([int(x[len(dir):x.rfind('_') if '_' in Path(x).name else None]) for x in d]) + 1 # increment
|
||||
return dir + str(n) + ('_' + comment if comment else '')
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user