Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,8 @@
|
|
| 1 |
import os
|
| 2 |
from huggingface_hub import hf_hub_download
|
| 3 |
|
| 4 |
-
# تنظیم مسیرهای کش
|
| 5 |
os.environ["HF_HOME"] = "/home/user/app/hf_cache"
|
| 6 |
-
os.environ["HUGGINGFACE_HUB_CACHE"] = "/home/user/app/hf_cache"
|
| 7 |
-
os.environ["TRANSFORMERS_CACHE"] = "/home/user/app/hf_cache"
|
| 8 |
|
| 9 |
# مسیر CelebAMask-HQ
|
| 10 |
celeb_path = "/home/user/app/huggingface_models/CelebAMask-HQ"
|
|
@@ -13,30 +11,15 @@ face_parsing_path = os.path.join(celeb_path, "face_parsing")
|
|
| 13 |
print("[Info] PYTHONPATH:", os.environ.get("PYTHONPATH"))
|
| 14 |
print("[Info] CelebAMask-HQ path exists:", os.path.exists(celeb_path))
|
| 15 |
print("[Info] face_parsing folder exists:", os.path.exists(face_parsing_path))
|
| 16 |
-
print("[Info] HF_HOME:", os.environ.get("HF_HOME"))
|
| 17 |
-
print("[Info] Cache directory exists:", os.path.exists("/home/user/app/hf_cache"))
|
| 18 |
-
print("[Info] Cache directory writable:", os.access("/home/user/app/hf_cache", os.W_OK))
|
| 19 |
|
|
|
|
| 20 |
try:
|
| 21 |
-
# دانلود مدل از Hugging Face
|
| 22 |
model_path = hf_hub_download(
|
| 23 |
repo_id="public-data/CelebAMask-HQ-Face-Parsing",
|
| 24 |
-
filename="model.pth",
|
| 25 |
-
cache_dir="/home/user/app/hf_cache"
|
| 26 |
-
force_download=False,
|
| 27 |
-
resume_download=True
|
| 28 |
)
|
| 29 |
print("[Success] Model downloaded to:", model_path)
|
| 30 |
|
| 31 |
except Exception as e:
|
| 32 |
-
print("[Error] Failed to download model:", str(e))
|
| 33 |
-
# تلاش با نام فایل متفاوت
|
| 34 |
-
try:
|
| 35 |
-
model_path = hf_hub_download(
|
| 36 |
-
repo_id="public-data/CelebAMask-HQ-Face-Parsing",
|
| 37 |
-
filename="models/model.pth",
|
| 38 |
-
cache_dir="/home/user/app/hf_cache"
|
| 39 |
-
)
|
| 40 |
-
print("[Success] Model downloaded to:", model_path)
|
| 41 |
-
except Exception as e2:
|
| 42 |
-
print("[Error] Also failed with alternative filename:", str(e2))
|
|
|
|
| 1 |
import os
|
| 2 |
from huggingface_hub import hf_hub_download
|
| 3 |
|
| 4 |
+
# تنظیم مسیرهای کش
|
| 5 |
os.environ["HF_HOME"] = "/home/user/app/hf_cache"
|
|
|
|
|
|
|
| 6 |
|
| 7 |
# مسیر CelebAMask-HQ
|
| 8 |
celeb_path = "/home/user/app/huggingface_models/CelebAMask-HQ"
|
|
|
|
| 11 |
print("[Info] PYTHONPATH:", os.environ.get("PYTHONPATH"))
|
| 12 |
print("[Info] CelebAMask-HQ path exists:", os.path.exists(celeb_path))
|
| 13 |
print("[Info] face_parsing folder exists:", os.path.exists(face_parsing_path))
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
# دانلود مدل از Hugging Face
|
| 16 |
try:
|
|
|
|
| 17 |
model_path = hf_hub_download(
|
| 18 |
repo_id="public-data/CelebAMask-HQ-Face-Parsing",
|
| 19 |
+
filename="models/model.pth",
|
| 20 |
+
cache_dir="/home/user/app/hf_cache"
|
|
|
|
|
|
|
| 21 |
)
|
| 22 |
print("[Success] Model downloaded to:", model_path)
|
| 23 |
|
| 24 |
except Exception as e:
|
| 25 |
+
print("[Error] Failed to download model:", str(e))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|