vaibhavpandeyvpz commited on
Commit
747f11e
·
1 Parent(s): 6d31310

Download model from HF hub

Browse files
Files changed (1) hide show
  1. app.py +19 -5
app.py CHANGED
@@ -3,8 +3,10 @@ import gc
3
  import os
4
  import sys
5
  import warnings
 
6
 
7
  import gradio as gr
 
8
 
9
  warnings.filterwarnings("ignore")
10
 
@@ -39,8 +41,22 @@ def load_model():
39
  )
40
  cfg = WAN_CONFIGS["flf2v-14B"]
41
 
42
- # Load from Hugging Face Hub
43
- checkpoint_dir = MODEL_ID
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
  wan_flf2v_720P = wan.WanFLF2V(
46
  config=cfg,
@@ -305,9 +321,7 @@ def create_interface():
305
 
306
  with gr.Column(scale=1):
307
  gr.Markdown("### 🎥 Generated Video")
308
- result_video = gr.Video(
309
- label="Output Video", height=600, show_download_button=True
310
- )
311
  result_status = gr.Textbox(label="Status", interactive=False)
312
 
313
  # Event handlers
 
3
  import os
4
  import sys
5
  import warnings
6
+ from pathlib import Path
7
 
8
  import gradio as gr
9
+ from huggingface_hub import snapshot_download
10
 
11
  warnings.filterwarnings("ignore")
12
 
 
41
  )
42
  cfg = WAN_CONFIGS["flf2v-14B"]
43
 
44
+ # Download model from Hugging Face Hub to local cache
45
+ print("\nDownloading model files from Hugging Face Hub...", flush=True)
46
+ # Use HF_HOME environment variable if set (for Hugging Face Spaces)
47
+ # Otherwise use default cache location
48
+ cache_base = os.environ.get("HF_HOME")
49
+ if cache_base:
50
+ cache_dir_path = Path(cache_base) / "hub"
51
+ else:
52
+ cache_dir_path = Path.home() / ".cache" / "huggingface" / "hub"
53
+
54
+ checkpoint_dir = snapshot_download(
55
+ repo_id=MODEL_ID,
56
+ cache_dir=str(cache_dir_path),
57
+ local_files_only=False,
58
+ )
59
+ print(f"Model downloaded to: {checkpoint_dir}", flush=True)
60
 
61
  wan_flf2v_720P = wan.WanFLF2V(
62
  config=cfg,
 
321
 
322
  with gr.Column(scale=1):
323
  gr.Markdown("### 🎥 Generated Video")
324
+ result_video = gr.Video(label="Output Video", height=600)
 
 
325
  result_status = gr.Textbox(label="Status", interactive=False)
326
 
327
  # Event handlers