Skip to content

Commit

Permalink
Fix increment_path() with periods (#5518)
Browse files Browse the repository at this point in the history
Fix for #5503
```
python detect.py --visualize --source path/to/file.suffix1.jpg
```
  • Loading branch information
glenn-jocher authored Nov 5, 2021
1 parent 0155548 commit 17b5f5b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 17b5f5b

Please sign in to comment.