1Root1AI commited on
Commit
00fdc7d
·
verified ·
1 Parent(s): 8d64e20

Update convert_wan.py

Browse files
Files changed (1) hide show
  1. convert_wan.py +18 -2
convert_wan.py CHANGED
@@ -9,12 +9,28 @@ import math
9
  import os
10
  import gdown
11
 
12
- # Add Wan2.1 to path
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  sys.path.append("/app/Wan2.1")
14
 
15
  # --- 1. DOWNLOAD WEIGHTS FROM DRIVE ---
16
  print("--- DOWNLOADING MODEL FROM GOOGLE DRIVE ---")
17
- # The ID from your link: 1pf-fhkWayK3_sv9bujvT2Od04ki2Wh4y
18
  file_id = '1pf-fhkWayK3_sv9bujvT2Od04ki2Wh4y'
19
  url = f'https://drive.google.com/uc?id={file_id}'
20
  ckpt_path = "/app/wan13bNSFWFull_v20I2v.safetensors"
 
9
  import os
10
  import gdown
11
 
12
+ # --- 0. FORCE CPU PATCH (CRITICAL FIX) ---
13
+ # The T5 code tries to call torch.cuda.current_device() on import.
14
+ # We must edit the file on disk BEFORE importing it.
15
+ t5_path = "/app/Wan2.1/wan/modules/t5.py"
16
+ if os.path.exists(t5_path):
17
+ print("--- PATCHING T5.PY TO REMOVE CUDA REQUIREMENT ---")
18
+ with open(t5_path, 'r') as f:
19
+ content = f.read()
20
+
21
+ # Replace the hardcoded cuda call with "cpu"
22
+ new_content = content.replace("device=torch.cuda.current_device(),", "device='cpu',")
23
+
24
+ with open(t5_path, 'w') as f:
25
+ f.write(new_content)
26
+ else:
27
+ print("WARNING: Could not find t5.py to patch!")
28
+
29
+ # Add Wan2.1 to path AFTER patching
30
  sys.path.append("/app/Wan2.1")
31
 
32
  # --- 1. DOWNLOAD WEIGHTS FROM DRIVE ---
33
  print("--- DOWNLOADING MODEL FROM GOOGLE DRIVE ---")
 
34
  file_id = '1pf-fhkWayK3_sv9bujvT2Od04ki2Wh4y'
35
  url = f'https://drive.google.com/uc?id={file_id}'
36
  ckpt_path = "/app/wan13bNSFWFull_v20I2v.safetensors"