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
```
pull/5519/head
Glenn Jocher 2021-11-05 11:16:19 +01:00 committed by GitHub
parent 0155548384
commit 17b5f5b974
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 3 deletions

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