Update app.py
Browse files
app.py
CHANGED
|
@@ -6,33 +6,6 @@ from quickmt import Translator
|
|
| 6 |
from quickmt.hub import hf_download, hf_list
|
| 7 |
from pathlib import Path
|
| 8 |
|
| 9 |
-
PERSIST_ROOT = Path("/home/user/data")
|
| 10 |
-
PERSIST_ROOT.mkdir(parents=True, exist_ok=True)
|
| 11 |
-
|
| 12 |
-
def preload_quickmt_models():
|
| 13 |
-
models = hf_list() # ví dụ: ["quickmt/en-vi", "quickmt/vi-en", ...]
|
| 14 |
-
print("Found quickmt models:", models)
|
| 15 |
-
|
| 16 |
-
for m in models:
|
| 17 |
-
model_name = m.replace("quickmt/", "") # ví dụ: en-vi
|
| 18 |
-
model_path = PERSIST_ROOT / model_name
|
| 19 |
-
|
| 20 |
-
if model_path.exists():
|
| 21 |
-
print(f"[SKIP] Model {model_name} đã tồn tại trong /data.")
|
| 22 |
-
continue
|
| 23 |
-
|
| 24 |
-
print(f"[DOWNLOAD] Đang tải model {m} → {model_path}")
|
| 25 |
-
try:
|
| 26 |
-
hf_download(
|
| 27 |
-
model_name=m,
|
| 28 |
-
output_dir=model_path
|
| 29 |
-
)
|
| 30 |
-
print(f"[DONE] Model {model_name} đã tải xong.")
|
| 31 |
-
except Exception as e:
|
| 32 |
-
print(f"[ERROR] Không thể tải {model_name}:", e)
|
| 33 |
-
|
| 34 |
-
# Gọi preload ngay khi chạy Space
|
| 35 |
-
preload_quickmt_models()
|
| 36 |
|
| 37 |
MODEL_ID = "bmiller22000/xyntrai-mistral-2.5-7b-chat-nsfw"
|
| 38 |
# Load model and tokenizer
|
|
|
|
| 6 |
from quickmt.hub import hf_download, hf_list
|
| 7 |
from pathlib import Path
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
MODEL_ID = "bmiller22000/xyntrai-mistral-2.5-7b-chat-nsfw"
|
| 11 |
# Load model and tokenizer
|