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:
1 parent
35fe98543c
commit
c5d2331897
1 file changed
+1
-1
+1
-1
@@ -948,7 +948,7 @@ def increment_dir(dir, comment=''):
|
|||||||
dir = str(Path(dir)) # os-agnostic
|
dir = str(Path(dir)) # os-agnostic
|
||||||
d = sorted(glob.glob(dir + '*')) # directories
|
d = sorted(glob.glob(dir + '*')) # directories
|
||||||
if len(d):
|
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 '')
|
return dir + str(n) + ('_' + comment if comment else '')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user