jhj0517 commited on
Commit
a83a3d9
·
1 Parent(s): f2aa528
Files changed (1) hide show
  1. modules/utils/paths.py +16 -1
modules/utils/paths.py CHANGED
@@ -5,6 +5,7 @@ import os
5
  PROJECT_ROOT_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "..")
6
  MODELS_DIR = os.path.join(PROJECT_ROOT_DIR, "models")
7
  OUTPUTS_DIR = os.path.join(PROJECT_ROOT_DIR, "outputs")
 
8
  EXP_OUTPUT_DIR = os.path.join(OUTPUTS_DIR, "exp_data")
9
  MODEL_CONFIG = os.path.join(PROJECT_ROOT_DIR, "modules", "config", "models.yaml")
10
  MODEL_PATHS = {
@@ -18,12 +19,26 @@ MODEL_PATHS = {
18
  MASK_TEMPLATES = os.path.join(PROJECT_ROOT_DIR, "modules", "utils", "resources", "mask_template.png")
19
 
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  @functools.lru_cache
22
  def init_dirs():
23
  for dir_path in [
24
  MODELS_DIR,
25
  OUTPUTS_DIR,
26
- EXP_OUTPUT_DIR
 
27
  ]:
28
  os.makedirs(dir_path, exist_ok=True)
29
 
 
5
  PROJECT_ROOT_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "..")
6
  MODELS_DIR = os.path.join(PROJECT_ROOT_DIR, "models")
7
  OUTPUTS_DIR = os.path.join(PROJECT_ROOT_DIR, "outputs")
8
+ TEMP_DIR = os.path.join(OUTPUTS_DIR, "temp")
9
  EXP_OUTPUT_DIR = os.path.join(OUTPUTS_DIR, "exp_data")
10
  MODEL_CONFIG = os.path.join(PROJECT_ROOT_DIR, "modules", "config", "models.yaml")
11
  MODEL_PATHS = {
 
19
  MASK_TEMPLATES = os.path.join(PROJECT_ROOT_DIR, "modules", "utils", "resources", "mask_template.png")
20
 
21
 
22
+ def get_auto_incremental_file_path(dir_path: str, extension: str, prefix: str = ""):
23
+ counter = 0
24
+ while True:
25
+ if prefix:
26
+ filename = f"{prefix}_{counter:05d}.{extension}"
27
+ else:
28
+ filename = f"{counter:05d}.{extension}"
29
+ full_path = os.path.join(dir_path, filename)
30
+ if not os.path.exists(full_path):
31
+ return full_path
32
+ counter += 1
33
+
34
+
35
  @functools.lru_cache
36
  def init_dirs():
37
  for dir_path in [
38
  MODELS_DIR,
39
  OUTPUTS_DIR,
40
+ EXP_OUTPUT_DIR,
41
+ TEMP_DIR
42
  ]:
43
  os.makedirs(dir_path, exist_ok=True)
44