Spaces:
Running on Zero
Running on Zero
multimodalart commited on
Commit ·
d6e9e07
1
Parent(s): f6b1538
Lazy-cache examples; default inference params; rename to Lens
Browse files
README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
emoji: 🔍
|
| 4 |
colorFrom: yellow
|
| 5 |
colorTo: red
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Lens
|
| 3 |
emoji: 🔍
|
| 4 |
colorFrom: yellow
|
| 5 |
colorTo: red
|
app.py
CHANGED
|
@@ -58,19 +58,22 @@ def model_defaults(model_name: str):
|
|
| 58 |
@spaces.GPU(duration=120)
|
| 59 |
def generate(
|
| 60 |
prompt: str,
|
| 61 |
-
model_name: str,
|
| 62 |
-
base_resolution: int,
|
| 63 |
-
aspect_ratio: str,
|
| 64 |
-
steps: int,
|
| 65 |
-
cfg: float,
|
| 66 |
-
seed: int,
|
| 67 |
-
randomize_seed: bool,
|
| 68 |
progress=gr.Progress(track_tqdm=True),
|
| 69 |
):
|
| 70 |
if not prompt or not prompt.strip():
|
| 71 |
raise gr.Error("Please enter a prompt.")
|
| 72 |
|
| 73 |
pipe = PIPES[model_name]
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
if randomize_seed:
|
| 76 |
seed = random.randint(0, MAX_SEED)
|
|
@@ -81,8 +84,8 @@ def generate(
|
|
| 81 |
prompt=prompt.strip(),
|
| 82 |
base_resolution=int(base_resolution),
|
| 83 |
aspect_ratio=aspect_ratio,
|
| 84 |
-
num_inference_steps=
|
| 85 |
-
guidance_scale=
|
| 86 |
num_images_per_prompt=1,
|
| 87 |
generator=generator,
|
| 88 |
)
|
|
@@ -152,6 +155,10 @@ with gr.Blocks(theme=gr.themes.Citrus(), css=CSS, title="Lens / Lens-Turbo") as
|
|
| 152 |
["A green iguana basking on a moss-covered log in a tropical rainforest, every scale rendered sharply, dewdrops on its skin, National Geographic style", MODEL_CHOICES[1]],
|
| 153 |
],
|
| 154 |
inputs=[prompt, model],
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
)
|
| 156 |
|
| 157 |
def _sync_defaults(model_name):
|
|
|
|
| 58 |
@spaces.GPU(duration=120)
|
| 59 |
def generate(
|
| 60 |
prompt: str,
|
| 61 |
+
model_name: str = MODEL_CHOICES[0],
|
| 62 |
+
base_resolution: int = 1024,
|
| 63 |
+
aspect_ratio: str = "1:1",
|
| 64 |
+
steps: int | None = None,
|
| 65 |
+
cfg: float | None = None,
|
| 66 |
+
seed: int = 0,
|
| 67 |
+
randomize_seed: bool = True,
|
| 68 |
progress=gr.Progress(track_tqdm=True),
|
| 69 |
):
|
| 70 |
if not prompt or not prompt.strip():
|
| 71 |
raise gr.Error("Please enter a prompt.")
|
| 72 |
|
| 73 |
pipe = PIPES[model_name]
|
| 74 |
+
default_steps, default_cfg = model_defaults(model_name)
|
| 75 |
+
steps = default_steps if steps is None else int(steps)
|
| 76 |
+
cfg = default_cfg if cfg is None else float(cfg)
|
| 77 |
|
| 78 |
if randomize_seed:
|
| 79 |
seed = random.randint(0, MAX_SEED)
|
|
|
|
| 84 |
prompt=prompt.strip(),
|
| 85 |
base_resolution=int(base_resolution),
|
| 86 |
aspect_ratio=aspect_ratio,
|
| 87 |
+
num_inference_steps=steps,
|
| 88 |
+
guidance_scale=cfg,
|
| 89 |
num_images_per_prompt=1,
|
| 90 |
generator=generator,
|
| 91 |
)
|
|
|
|
| 155 |
["A green iguana basking on a moss-covered log in a tropical rainforest, every scale rendered sharply, dewdrops on its skin, National Geographic style", MODEL_CHOICES[1]],
|
| 156 |
],
|
| 157 |
inputs=[prompt, model],
|
| 158 |
+
outputs=[image, used_seed],
|
| 159 |
+
fn=generate,
|
| 160 |
+
cache_examples=True,
|
| 161 |
+
cache_mode="lazy",
|
| 162 |
)
|
| 163 |
|
| 164 |
def _sync_defaults(model_name):
|