Fix increment_dir to use run_xxx for logdir (#1058)
Browse files* 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
- utils/general.py +1 -1
utils/general.py
CHANGED
@@ -948,7 +948,7 @@ def increment_dir(dir, comment=''):
|
|
948 |
dir = str(Path(dir)) # os-agnostic
|
949 |
d = sorted(glob.glob(dir + '*')) # directories
|
950 |
if len(d):
|
951 |
-
n = max([int(x[len(dir):x.
|
952 |
return dir + str(n) + ('_' + comment if comment else '')
|
953 |
|
954 |
|
|
|
948 |
dir = str(Path(dir)) # os-agnostic
|
949 |
d = sorted(glob.glob(dir + '*')) # directories
|
950 |
if len(d):
|
951 |
+
n = max([int(x[len(dir):x.rfind('_') if '_' in Path(x).name else None]) for x in d]) + 1 # increment
|
952 |
return dir + str(n) + ('_' + comment if comment else '')
|
953 |
|
954 |
|