pormungtai commited on
Commit
dd5894d
Β·
verified Β·
1 Parent(s): d5535da

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -7
app.py CHANGED
@@ -12,9 +12,8 @@ if not os.path.exists(WAN_DIR):
12
  subprocess.run(["git", "clone", "--depth", "1", WAN_REPO, WAN_DIR], check=True)
13
  print("Clone complete.")
14
 
15
- # β€” Patch wan/modules/t5.py: it calls torch.cuda.current_device() at class
16
- # definition time which fails at startup (no GPU yet in ZeroGPU).
17
- # Replace with literal 0 β€” the GPU decorator will handle real init. β€”
18
  t5_path = os.path.join(WAN_DIR, "wan", "modules", "t5.py")
19
  if os.path.exists(t5_path):
20
  with open(t5_path) as f:
@@ -35,16 +34,29 @@ for sitedir in site.getsitepackages():
35
  site.addsitedir(sitedir)
36
  importlib.invalidate_caches()
37
 
38
- # β€” Download SAM2 weights (no GPU needed, just files) β€”
39
  try:
40
  snapshot_download(repo_id="alexnasa/sam2_C_cpu", local_dir=os.getcwd())
41
  print("sam2 weights downloaded successfully.")
42
  except Exception as e:
43
  print(f"Warning: sam2 download failed: {e}")
44
 
45
- # β€” Download Wan2.2-Animate-14B weights (just files, no GPU needed) β€”
46
- print("Downloading Wan2.2-Animate-14B model weights...")
47
- snapshot_download(repo_id="Wan-AI/Wan2.2-Animate-14B", local_dir="./Wan2.2-Animate-14B")
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  print("Model weights downloaded.")
49
 
50
  # β€” Now safe to import wan (t5.py is patched) β€”
 
12
  subprocess.run(["git", "clone", "--depth", "1", WAN_REPO, WAN_DIR], check=True)
13
  print("Clone complete.")
14
 
15
+ # β€” Patch wan/modules/t5.py: calls torch.cuda.current_device() at class
16
+ # definition time which fails at startup (no GPU yet in ZeroGPU). β€”
 
17
  t5_path = os.path.join(WAN_DIR, "wan", "modules", "t5.py")
18
  if os.path.exists(t5_path):
19
  with open(t5_path) as f:
 
34
  site.addsitedir(sitedir)
35
  importlib.invalidate_caches()
36
 
37
+ # β€” Download SAM2 weights (small, just files) β€”
38
  try:
39
  snapshot_download(repo_id="alexnasa/sam2_C_cpu", local_dir=os.getcwd())
40
  print("sam2 weights downloaded successfully.")
41
  except Exception as e:
42
  print(f"Warning: sam2 download failed: {e}")
43
 
44
+ # β€” Download Wan2.2-Animate-14B weights β€”
45
+ # ZeroGPU free tier has 50GB storage limit. Full model is ~51.5GB.
46
+ # We skip the T5 encoder (11.4GB) + tokenizer since the animate task
47
+ # is video-to-video motion transfer and uses internal text conditioning.
48
+ # DiT (~34.5GB) + CLIP (~4.8GB) + VAE (~0.5GB) β‰ˆ 40GB β†’ fits under 50GB.
49
+ print("Downloading Wan2.2-Animate-14B model weights (DiT + CLIP + VAE)...")
50
+ snapshot_download(
51
+ repo_id="Wan-AI/Wan2.2-Animate-14B",
52
+ local_dir="./Wan2.2-Animate-14B",
53
+ ignore_patterns=[
54
+ "models_t5_*", # T5 text encoder (11.4GB) β€” skipped to fit 50GB
55
+ "google/*", # umt5-xxl tokenizer files
56
+ "tokenizer*",
57
+ "special_tokens_map.json",
58
+ ]
59
+ )
60
  print("Model weights downloaded.")
61
 
62
  # β€” Now safe to import wan (t5.py is patched) β€”