Spaces:
Running
on
Zero
Running
on
Zero
Dynamic duration
Browse files
app.py
CHANGED
|
@@ -41,8 +41,26 @@ aspect_ratios = {
|
|
| 41 |
"3:4": (1140, 1472)
|
| 42 |
}
|
| 43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
# Generation function for Qwen/Qwen-Image
|
| 45 |
-
@spaces.GPU
|
| 46 |
def generate_qwen(
|
| 47 |
prompt: str,
|
| 48 |
negative_prompt: str = "",
|
|
@@ -89,7 +107,7 @@ def generate_qwen(
|
|
| 89 |
return image_paths, seed, f"{duration:.2f}", zip_path
|
| 90 |
|
| 91 |
# Wrapper function to handle UI logic
|
| 92 |
-
@spaces.GPU
|
| 93 |
def generate(
|
| 94 |
prompt: str,
|
| 95 |
negative_prompt: str,
|
|
|
|
| 41 |
"3:4": (1140, 1472)
|
| 42 |
}
|
| 43 |
|
| 44 |
+
def get_duration(
|
| 45 |
+
prompt: str,
|
| 46 |
+
negative_prompt: str,
|
| 47 |
+
use_negative_prompt: bool,
|
| 48 |
+
seed: int,
|
| 49 |
+
width: int,
|
| 50 |
+
height: int,
|
| 51 |
+
guidance_scale: float,
|
| 52 |
+
randomize_seed: bool,
|
| 53 |
+
num_inference_steps: int,
|
| 54 |
+
num_images: int,
|
| 55 |
+
zip_images: bool,
|
| 56 |
+
progress=gr.Progress(track_tqdm=True),
|
| 57 |
+
):
|
| 58 |
+
step_duration = 0.6
|
| 59 |
+
step_duration *= (width * height) / (1024 * 1024)
|
| 60 |
+
per_image_duration = 5 + num_inference_steps * step_duration
|
| 61 |
+
return 10 + num_images * per_image_duration
|
| 62 |
+
|
| 63 |
# Generation function for Qwen/Qwen-Image
|
|
|
|
| 64 |
def generate_qwen(
|
| 65 |
prompt: str,
|
| 66 |
negative_prompt: str = "",
|
|
|
|
| 107 |
return image_paths, seed, f"{duration:.2f}", zip_path
|
| 108 |
|
| 109 |
# Wrapper function to handle UI logic
|
| 110 |
+
@spaces.GPU(duration=get_duration)
|
| 111 |
def generate(
|
| 112 |
prompt: str,
|
| 113 |
negative_prompt: str,
|