Spaces:
Running on Zero
Running on Zero
tqdm progress on the render step
Browse files
app.py
CHANGED
|
@@ -119,8 +119,7 @@ def _duration(embeds_path, images, width, height, seed):
|
|
| 119 |
return int(30 + 4 * megapixels + 0.15 * megapixels**2)
|
| 120 |
|
| 121 |
|
| 122 |
-
|
| 123 |
-
def _generate(embeds_path, images, width, height, seed):
|
| 124 |
embeds = load_file(embeds_path)
|
| 125 |
kwargs = dict(
|
| 126 |
prompt_embeds=embeds["prompt_embeds"].to("cuda", torch.bfloat16),
|
|
@@ -139,6 +138,11 @@ def _generate(embeds_path, images, width, height, seed):
|
|
| 139 |
return path
|
| 140 |
|
| 141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
def generate(prompt, images=None, aspect=AUTO, resolution="4 MP", seed=0, randomize=True, enhance=False,
|
| 143 |
reasoning_effort="low", progress=gr.Progress(track_tqdm=True)):
|
| 144 |
"""Text-to-image, or an edit of up to 8 images referred to as `<Picture 1>`, `<Picture 2>`, ... in the prompt.
|
|
@@ -194,10 +198,15 @@ def studio(state, seed, randomize, effort):
|
|
| 194 |
yield f"Generating {width}脳{height} ...", final, thinking, seed, plan
|
| 195 |
|
| 196 |
|
| 197 |
-
def
|
| 198 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
t0 = time.time()
|
| 200 |
-
path =
|
| 201 |
return path, f"{plan['width']}脳{plan['height']} 路 seed {plan['seed']} 路 {time.time() - t0:.0f}s"
|
| 202 |
|
| 203 |
IDEAS = [
|
|
|
|
| 119 |
return int(30 + 4 * megapixels + 0.15 * megapixels**2)
|
| 120 |
|
| 121 |
|
| 122 |
+
def _run(embeds_path, images, width, height, seed):
|
|
|
|
| 123 |
embeds = load_file(embeds_path)
|
| 124 |
kwargs = dict(
|
| 125 |
prompt_embeds=embeds["prompt_embeds"].to("cuda", torch.bfloat16),
|
|
|
|
| 138 |
return path
|
| 139 |
|
| 140 |
|
| 141 |
+
@spaces.GPU(duration=_duration, size="xlarge")
|
| 142 |
+
def _generate(embeds_path, images, width, height, seed):
|
| 143 |
+
return _run(embeds_path, images, width, height, seed)
|
| 144 |
+
|
| 145 |
+
|
| 146 |
def generate(prompt, images=None, aspect=AUTO, resolution="4 MP", seed=0, randomize=True, enhance=False,
|
| 147 |
reasoning_effort="low", progress=gr.Progress(track_tqdm=True)):
|
| 148 |
"""Text-to-image, or an edit of up to 8 images referred to as `<Picture 1>`, `<Picture 2>`, ... in the prompt.
|
|
|
|
| 198 |
yield f"Generating {width}脳{height} ...", final, thinking, seed, plan
|
| 199 |
|
| 200 |
|
| 201 |
+
def _render_duration(plan, progress=None):
|
| 202 |
+
return _duration(plan["embeds"], plan["images"], plan["width"], plan["height"], plan["seed"])
|
| 203 |
+
|
| 204 |
+
|
| 205 |
+
@spaces.GPU(duration=_render_duration, size="xlarge")
|
| 206 |
+
def render(plan, progress=gr.Progress(track_tqdm=True)):
|
| 207 |
+
"""Part 2: the image, as its own event so the result panel shows the loading UI and the denoising steps."""
|
| 208 |
t0 = time.time()
|
| 209 |
+
path = _run(plan["embeds"], plan["images"], plan["width"], plan["height"], plan["seed"])
|
| 210 |
return path, f"{plan['width']}脳{plan['height']} 路 seed {plan['seed']} 路 {time.time() - t0:.0f}s"
|
| 211 |
|
| 212 |
IDEAS = [
|