Browse Source

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

Fix for https://github.com/ultralytics/yolov5/issues/5503
```
python detect.py --visualize --source path/to/file.suffix1.jpg
```
modifyDataloader
Glenn Jocher GitHub 3 years ago
parent
commit
17b5f5b974
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 3 deletions
  1. +2
    -3
      utils/general.py

+ 2
- 3
utils/general.py View File

@@ -837,7 +837,6 @@ def increment_path(path, exist_ok=False, sep='', mkdir=False):
i = [int(m.groups()[0]) for m in matches if m] # indices
n = max(i) + 1 if i else 2 # increment number
path = Path(f"{path}{sep}{n}{suffix}") # update path
dir = path if path.suffix == '' else path.parent # directory
if not dir.exists() and mkdir:
dir.mkdir(parents=True, exist_ok=True) # make directory
if mkdir:
path.mkdir(parents=True, exist_ok=True) # make directory
return path

Loading…
Cancel
Save