You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Air_Ground_CEC/YOLOv6/yolov6/utils/general.py

17 lines
501 B

#!/usr/bin/env python3
# -*- coding:utf-8 -*-
import os
from pathlib import Path
def increment_name(path, master_process):
"increase save directory's id"
path = Path(path)
sep = ''
if path.exists() and master_process:
path, suffix = (path.with_suffix(''), path.suffix) if path.is_file() else (path, '')
for n in range(1, 9999):
p = f'{path}{sep}{n}{suffix}'
if not os.path.exists(p):
break
path = Path(p)
return path