Commit
·
2e0c6aa
1
Parent(s):
f5fb53f
Automatically create the dir
Browse files
app.py
CHANGED
@@ -19,9 +19,18 @@ use_cpu = not torch.cuda.is_available()
|
|
19 |
device = "cpu" if use_cpu else "cuda"
|
20 |
|
21 |
# Custom file cache decorator
|
|
|
|
|
|
|
22 |
def file_cache(file_path):
|
23 |
def decorator(func):
|
24 |
def wrapper(*args, **kwargs):
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
# Check if the file already exists
|
26 |
if os.path.exists(file_path):
|
27 |
# Load from cache
|
|
|
19 |
device = "cpu" if use_cpu else "cuda"
|
20 |
|
21 |
# Custom file cache decorator
|
22 |
+
import os
|
23 |
+
import pickle
|
24 |
+
|
25 |
def file_cache(file_path):
|
26 |
def decorator(func):
|
27 |
def wrapper(*args, **kwargs):
|
28 |
+
# Ensure the directory exists
|
29 |
+
dir_path = os.path.dirname(file_path)
|
30 |
+
if not os.path.exists(dir_path):
|
31 |
+
os.makedirs(dir_path, exist_ok=True)
|
32 |
+
print(f"Created directory {dir_path}")
|
33 |
+
|
34 |
# Check if the file already exists
|
35 |
if os.path.exists(file_path):
|
36 |
# Load from cache
|