fix: check hf download failure

This commit is contained in:
Bingsu
2023-10-07 13:06:13 +09:00
parent 46e4d94a46
commit 5021519fef
2 changed files with 8 additions and 1 deletions

View File

@@ -1 +1 @@
__version__ = "23.9.3"
__version__ = "23.10.0.dev0"

View File

@@ -10,6 +10,7 @@ from PIL import Image, ImageDraw
from rich import print
repo_id = "Bingsu/adetailer"
_download_failed = False
@dataclass
@@ -20,12 +21,18 @@ class PredictOutput:
def hf_download(file: str):
global _download_failed
if _download_failed:
return "INVALID"
try:
path = hf_hub_download(repo_id, file)
except Exception:
msg = f"[-] ADetailer: Failed to load model {file!r} from huggingface"
print(msg)
path = "INVALID"
_download_failed = True
return path