glenn-jocher commited on
Commit
17b5f5b
·
unverified ·
1 Parent(s): 0155548

Fix `increment_path()` with periods (#5518)

Browse files

Fix for https://github.com/ultralytics/yolov5/issues/5503
```
python detect.py --visualize --source path/to/file.suffix1.jpg
```

Files changed (1) hide show
  1. utils/general.py +2 -3
utils/general.py CHANGED
@@ -837,7 +837,6 @@ def increment_path(path, exist_ok=False, sep='', mkdir=False):
837
  i = [int(m.groups()[0]) for m in matches if m] # indices
838
  n = max(i) + 1 if i else 2 # increment number
839
  path = Path(f"{path}{sep}{n}{suffix}") # update path
840
- dir = path if path.suffix == '' else path.parent # directory
841
- if not dir.exists() and mkdir:
842
- dir.mkdir(parents=True, exist_ok=True) # make directory
843
  return path
 
837
  i = [int(m.groups()[0]) for m in matches if m] # indices
838
  n = max(i) + 1 if i else 2 # increment number
839
  path = Path(f"{path}{sep}{n}{suffix}") # update path
840
+ if mkdir:
841
+ path.mkdir(parents=True, exist_ok=True) # make directory
 
842
  return path