Spaces:
Running on Zero
Running on Zero
fix: remove non-ASCII unicode characters from print calls in model_loader.py
Browse files- app/core/model_loader.py +12 -10
app/core/model_loader.py
CHANGED
|
@@ -19,20 +19,22 @@ MODEL_MANIFEST = [
|
|
| 19 |
|
| 20 |
def ensure_models_downloaded(base_dir: str = "."):
|
| 21 |
"""Downloads all 8 production models from Hugging Face Hub on startup."""
|
| 22 |
-
print("
|
| 23 |
for rel_dir, filename in MODEL_MANIFEST:
|
| 24 |
dest_dir = Path(base_dir) / rel_dir
|
| 25 |
dest_dir.mkdir(parents=True, exist_ok=True)
|
| 26 |
dest_path = dest_dir / filename
|
| 27 |
|
| 28 |
if not dest_path.exists() or dest_path.stat().st_size == 0:
|
| 29 |
-
print(f"
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
| 37 |
else:
|
| 38 |
-
print(f"
|
|
|
|
| 19 |
|
| 20 |
def ensure_models_downloaded(base_dir: str = "."):
|
| 21 |
"""Downloads all 8 production models from Hugging Face Hub on startup."""
|
| 22 |
+
print("Verifying and downloading Agrovia AI models from Hub...")
|
| 23 |
for rel_dir, filename in MODEL_MANIFEST:
|
| 24 |
dest_dir = Path(base_dir) / rel_dir
|
| 25 |
dest_dir.mkdir(parents=True, exist_ok=True)
|
| 26 |
dest_path = dest_dir / filename
|
| 27 |
|
| 28 |
if not dest_path.exists() or dest_path.stat().st_size == 0:
|
| 29 |
+
print(f"Downloading {filename} to {dest_dir}...")
|
| 30 |
+
try:
|
| 31 |
+
downloaded = hf_hub_download(
|
| 32 |
+
repo_id=REPO_ID,
|
| 33 |
+
filename=filename,
|
| 34 |
+
local_dir=str(dest_dir),
|
| 35 |
+
)
|
| 36 |
+
print(f"Model {filename} downloaded successfully.")
|
| 37 |
+
except Exception as exc:
|
| 38 |
+
print(f"Failed to download {filename}: {exc}")
|
| 39 |
else:
|
| 40 |
+
print(f"Model {filename} already present ({dest_path.stat().st_size:,} bytes).")
|