Spaces:
Running
Running
Update sorawm/iopaint/helper.py
Browse files- sorawm/iopaint/helper.py +5 -3
sorawm/iopaint/helper.py
CHANGED
|
@@ -32,16 +32,18 @@ def switch_mps_device(model_name, device):
|
|
| 32 |
return device
|
| 33 |
|
| 34 |
|
| 35 |
-
def get_cache_path_by_url(url):
|
| 36 |
parts = urlparse(url)
|
| 37 |
-
hub_dir =
|
| 38 |
model_dir = os.path.join(hub_dir, "checkpoints")
|
| 39 |
if not os.path.isdir(model_dir):
|
| 40 |
-
os.makedirs(model_dir)
|
| 41 |
filename = os.path.basename(parts.path)
|
| 42 |
cached_file = os.path.join(model_dir, filename)
|
| 43 |
return cached_file
|
| 44 |
|
|
|
|
|
|
|
| 45 |
|
| 46 |
def download_model(url, model_md5: str = None):
|
| 47 |
if os.path.exists(url):
|
|
|
|
| 32 |
return device
|
| 33 |
|
| 34 |
|
| 35 |
+
def get_cache_path_by_url(url: str):
|
| 36 |
parts = urlparse(url)
|
| 37 |
+
hub_dir = "/tmp/torch/hub"
|
| 38 |
model_dir = os.path.join(hub_dir, "checkpoints")
|
| 39 |
if not os.path.isdir(model_dir):
|
| 40 |
+
os.makedirs(model_dir, exist_ok=True)
|
| 41 |
filename = os.path.basename(parts.path)
|
| 42 |
cached_file = os.path.join(model_dir, filename)
|
| 43 |
return cached_file
|
| 44 |
|
| 45 |
+
|
| 46 |
+
|
| 47 |
|
| 48 |
def download_model(url, model_md5: str = None):
|
| 49 |
if os.path.exists(url):
|