From 62d54d2f22d0380ee509373deecd5009bb0a031b Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Fri, 5 Nov 2021 11:16:19 +0100 Subject: [PATCH] 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 ``` --- utils/general.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/utils/general.py b/utils/general.py index 22086a79464d..adbf1bd48c5f 100755 --- a/utils/general.py +++ b/utils/general.py @@ -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