nitish-spz commited on
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!

Files changed (1) hide show
  1. app.py +5 -4
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
- # Download or use local model
705
- if not os.path.exists(MODEL_SAVE_PATH):
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: