Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
CHANGED
@@ -13,17 +13,26 @@ if not hf_token:
|
|
13 |
# 🔹 لاگین به HuggingFace
|
14 |
login(hf_token)
|
15 |
|
16 |
-
# 🔹
|
17 |
-
LORA_ZIP_PATH = "dorna-diabetes-finetuned-20250514T183411Z-1-001.zip"
|
18 |
-
|
19 |
|
20 |
-
# ✅ اکسترکت
|
21 |
-
if not os.path.exists(
|
22 |
with zipfile.ZipFile(LORA_ZIP_PATH, 'r') as zip_ref:
|
23 |
-
zip_ref.extractall(
|
24 |
print("✅ فایل LoRA اکسترکت شد.")
|
25 |
|
26 |
-
# ✅
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
for filename in os.listdir(LORA_PATH):
|
28 |
if filename.endswith(".safetensors") and filename != "adapter_model.safetensors":
|
29 |
os.rename(
|
|
|
13 |
# 🔹 لاگین به HuggingFace
|
14 |
login(hf_token)
|
15 |
|
16 |
+
# 🔹 مسیر فایل زیپ
|
17 |
+
LORA_ZIP_PATH = "dorna-diabetes-finetuned-20250514T183411Z-1-001.zip"
|
18 |
+
EXTRACT_DIR = "lora" # پوشهای که فایلها داخلش اکسترکت میشن
|
19 |
|
20 |
+
# ✅ اکسترکت فایل ZIP در صورت نیاز
|
21 |
+
if not os.path.exists(EXTRACT_DIR):
|
22 |
with zipfile.ZipFile(LORA_ZIP_PATH, 'r') as zip_ref:
|
23 |
+
zip_ref.extractall(EXTRACT_DIR)
|
24 |
print("✅ فایل LoRA اکسترکت شد.")
|
25 |
|
26 |
+
# ✅ پیدا کردن مسیر فولدر واقعی شامل adapter_config.json
|
27 |
+
# معمولاً zip یک زیرپوشه میسازه داخل خودش
|
28 |
+
for root, dirs, files in os.walk(EXTRACT_DIR):
|
29 |
+
if "adapter_config.json" in files:
|
30 |
+
LORA_PATH = root
|
31 |
+
break
|
32 |
+
else:
|
33 |
+
raise FileNotFoundError("❌ adapter_config.json در هیچ زیرپوشهای یافت نشد.")
|
34 |
+
|
35 |
+
# ✅ تغییر نام فایل .safetensors به adapter_model.safetensors اگر لازم بود
|
36 |
for filename in os.listdir(LORA_PATH):
|
37 |
if filename.endswith(".safetensors") and filename != "adapter_model.safetensors":
|
38 |
os.rename(
|