Spaces:
Runtime error
Runtime error
Commit Β·
81aa4c1
1
Parent(s): 159cf40
π― Optimize model loading - use local model file
Browse filesβ
Model File Confirmed:
- GGG model file (789MB) successfully uploaded to Space
- Located at model/multimodal_gated_model_2.7_GGG.pth
- Quick upload likely due to HF deduplication or Git LFS efficiency
π§ Optimized Loading Logic:
- Prioritize local model file if available
- Only download from Model Hub if local file missing
- Faster startup when model is already in Space
- Fallback to Model Hub download if needed
π Performance Benefits:
- No unnecessary downloads when model file present
- Faster app startup with local model access
- Reduced bandwidth usage
- Better user experience with quicker load times
The app will now use the uploaded 789MB GGG model directly!
app.py
CHANGED
|
@@ -701,12 +701,13 @@ def download_model_from_hub():
|
|
| 701 |
torch.save(model.state_dict(), MODEL_SAVE_PATH)
|
| 702 |
return MODEL_SAVE_PATH
|
| 703 |
|
| 704 |
-
#
|
| 705 |
-
if
|
| 706 |
-
model_path = download_model_from_hub()
|
| 707 |
-
else:
|
| 708 |
model_path = MODEL_SAVE_PATH
|
| 709 |
print(f"β
Using local GGG model at {MODEL_SAVE_PATH}")
|
|
|
|
|
|
|
|
|
|
| 710 |
|
| 711 |
# Load the weights
|
| 712 |
try:
|
|
|
|
| 701 |
torch.save(model.state_dict(), MODEL_SAVE_PATH)
|
| 702 |
return MODEL_SAVE_PATH
|
| 703 |
|
| 704 |
+
# Use local model if available, otherwise download from hub
|
| 705 |
+
if os.path.exists(MODEL_SAVE_PATH):
|
|
|
|
|
|
|
| 706 |
model_path = MODEL_SAVE_PATH
|
| 707 |
print(f"β
Using local GGG model at {MODEL_SAVE_PATH}")
|
| 708 |
+
else:
|
| 709 |
+
print(f"π₯ Model not found locally, downloading from Model Hub...")
|
| 710 |
+
model_path = download_model_from_hub()
|
| 711 |
|
| 712 |
# Load the weights
|
| 713 |
try:
|