matthewkram commited on
Commit
c20db4f
Β·
verified Β·
1 Parent(s): 4d24a58

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -19,9 +19,8 @@ class WanAnimateApp:
19
  model_name,
20
  torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
21
  variant="fp16",
22
- device_map="cpu" # With accelerate, this works
23
  )
24
- self.pipe.enable_model_cpu_offload() # Now safe with accelerate
25
 
26
  def predict(
27
  self,
@@ -34,8 +33,12 @@ class WanAnimateApp:
34
  return None, "Upload both image and video."
35
 
36
  try:
37
- # Local processing
38
- ref_image = Image.open(ref_img).convert("RGB").resize((576, 320))
 
 
 
 
39
  cap = cv2.VideoCapture(video)
40
  frame_count = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
41
  cap.release()
@@ -142,7 +145,7 @@ def start_app():
142
  with gr.Column():
143
  ref_img = gr.Image(
144
  label="Reference Image(参考图像)",
145
- type="filepath",
146
  sources=["upload"],
147
  )
148
 
 
19
  model_name,
20
  torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
21
  variant="fp16",
22
+ device_map="cpu"
23
  )
 
24
 
25
  def predict(
26
  self,
 
33
  return None, "Upload both image and video."
34
 
35
  try:
36
+ # Local processing β€” PIL directly (no open for PIL type)
37
+ if isinstance(ref_img, Image.Image):
38
+ ref_image = ref_img.convert("RGB").resize((576, 320))
39
+ else:
40
+ ref_image = Image.open(ref_img).convert("RGB").resize((576, 320))
41
+
42
  cap = cv2.VideoCapture(video)
43
  frame_count = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
44
  cap.release()
 
145
  with gr.Column():
146
  ref_img = gr.Image(
147
  label="Reference Image(参考图像)",
148
+ type="pil", # PIL type to fix FileNotFound
149
  sources=["upload"],
150
  )
151