Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
3b98a6f
1
Parent(s):
6f25f9f
Add ZeroGPU support
Browse files
app.py
CHANGED
|
@@ -5,6 +5,7 @@ import torch
|
|
| 5 |
import gradio as gr
|
| 6 |
import numpy as np
|
| 7 |
import imageio
|
|
|
|
| 8 |
from PIL import Image
|
| 9 |
|
| 10 |
# Add project root to path
|
|
@@ -98,6 +99,7 @@ def load_video_frames(video_path: str, source_frames: int):
|
|
| 98 |
return input_video, original_height, original_width
|
| 99 |
|
| 100 |
class VideoCoF_Controller(Wan_Controller):
|
|
|
|
| 101 |
@timer
|
| 102 |
def generate(
|
| 103 |
self,
|
|
@@ -142,7 +144,14 @@ class VideoCoF_Controller(Wan_Controller):
|
|
| 142 |
):
|
| 143 |
self.clear_cache()
|
| 144 |
print(f"VideoCoF Generation started.")
|
| 145 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
if self.diffusion_transformer_dropdown != diffusion_transformer_dropdown:
|
| 147 |
self.update_diffusion_transformer(diffusion_transformer_dropdown)
|
| 148 |
|
|
|
|
| 5 |
import gradio as gr
|
| 6 |
import numpy as np
|
| 7 |
import imageio
|
| 8 |
+
import spaces
|
| 9 |
from PIL import Image
|
| 10 |
|
| 11 |
# Add project root to path
|
|
|
|
| 99 |
return input_video, original_height, original_width
|
| 100 |
|
| 101 |
class VideoCoF_Controller(Wan_Controller):
|
| 102 |
+
@spaces.GPU(duration=240)
|
| 103 |
@timer
|
| 104 |
def generate(
|
| 105 |
self,
|
|
|
|
| 144 |
):
|
| 145 |
self.clear_cache()
|
| 146 |
print(f"VideoCoF Generation started.")
|
| 147 |
+
|
| 148 |
+
# Ensure model is on CUDA inside the zero-gpu decorated function
|
| 149 |
+
if torch.cuda.is_available():
|
| 150 |
+
self.device = torch.device("cuda")
|
| 151 |
+
# If pipeline is not on cuda, move it (if possible, but usually accelerate handles this or it's handled by parts)
|
| 152 |
+
# However, Wan_Controller logic might rely on `self.device`.
|
| 153 |
+
# We explicitly set `self.device` to cuda here.
|
| 154 |
+
|
| 155 |
if self.diffusion_transformer_dropdown != diffusion_transformer_dropdown:
|
| 156 |
self.update_diffusion_transformer(diffusion_transformer_dropdown)
|
| 157 |
|