Spaces:
Paused
Paused
Add model links and compact example table
Browse files
README.md
CHANGED
|
@@ -1,10 +1,11 @@
|
|
| 1 |
---
|
| 2 |
-
title: SeFi
|
| 3 |
sdk: gradio
|
| 4 |
sdk_version: 6.19.0
|
| 5 |
app_file: app.py
|
| 6 |
python_version: 3.12
|
| 7 |
license: cc-by-nc-4.0
|
|
|
|
| 8 |
models:
|
| 9 |
- SeFi-Image/SeFi-Image-1B-Base
|
| 10 |
- SeFi-Image/SeFi-Image-2B-Base
|
|
@@ -15,10 +16,17 @@ models:
|
|
| 15 |
- SeFi-Image/SeFi-Image-5B-turbo
|
| 16 |
---
|
| 17 |
|
| 18 |
-
# SeFi
|
| 19 |
|
| 20 |
Public Gradio ZeroGPU Space for SeFi-Image 1B, 2B, and 5B Base/RL/Turbo checkpoints.
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
The model defaults match the SeFi model cards:
|
| 23 |
|
| 24 |
| Family | Models | Steps | Guidance |
|
|
|
|
| 1 |
---
|
| 2 |
+
title: SeFi-Image
|
| 3 |
sdk: gradio
|
| 4 |
sdk_version: 6.19.0
|
| 5 |
app_file: app.py
|
| 6 |
python_version: 3.12
|
| 7 |
license: cc-by-nc-4.0
|
| 8 |
+
short_description: SeFi-Image Base, Turbo, and 5B RL ZeroGPU demo.
|
| 9 |
models:
|
| 10 |
- SeFi-Image/SeFi-Image-1B-Base
|
| 11 |
- SeFi-Image/SeFi-Image-2B-Base
|
|
|
|
| 16 |
- SeFi-Image/SeFi-Image-5B-turbo
|
| 17 |
---
|
| 18 |
|
| 19 |
+
# SeFi-Image
|
| 20 |
|
| 21 |
Public Gradio ZeroGPU Space for SeFi-Image 1B, 2B, and 5B Base/RL/Turbo checkpoints.
|
| 22 |
|
| 23 |
+
- Models on Hugging Face: https://huggingface.co/SeFi-Image
|
| 24 |
+
- Project page: https://jmliu206.github.io/sefi-web/
|
| 25 |
+
|
| 26 |
+
Base checkpoints use the 50-step guidance-4.0 setting. Turbo checkpoints use
|
| 27 |
+
the 4-step guidance-1.0 setting. The 5B RL checkpoint is the reinforced-learning
|
| 28 |
+
variant of the 5B model family.
|
| 29 |
+
|
| 30 |
The model defaults match the SeFi model cards:
|
| 31 |
|
| 32 |
| Family | Models | Steps | Guidance |
|
app.py
CHANGED
|
@@ -89,6 +89,9 @@ MODEL_PRESETS: dict[str, ModelPreset] = {
|
|
| 89 |
}
|
| 90 |
|
| 91 |
DEFAULT_MODEL = "1b-turbo"
|
|
|
|
|
|
|
|
|
|
| 92 |
IMAGE_SIZE = 1024
|
| 93 |
TURBO_STEPS = {4, 8, 10}
|
| 94 |
GPU_DURATION_BY_MODEL = {
|
|
@@ -157,16 +160,24 @@ def _model_choices() -> list[tuple[str, str]]:
|
|
| 157 |
return [(preset.label, key) for key, preset in MODEL_PRESETS.items()]
|
| 158 |
|
| 159 |
|
| 160 |
-
def
|
| 161 |
-
|
| 162 |
for example in EXAMPLES:
|
| 163 |
preset = MODEL_PRESETS[str(example["model_key"])]
|
| 164 |
-
|
| 165 |
-
f"{example['
|
| 166 |
-
f"{example['
|
| 167 |
)
|
| 168 |
-
|
| 169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
|
| 171 |
|
| 172 |
def _torch_cleanup() -> None:
|
|
@@ -235,8 +246,7 @@ def model_defaults(model_key: str):
|
|
| 235 |
)
|
| 236 |
|
| 237 |
|
| 238 |
-
def load_example(
|
| 239 |
-
index = evt.index[0] if isinstance(evt.index, (list, tuple)) else evt.index
|
| 240 |
example = EXAMPLES[int(index)]
|
| 241 |
preset = MODEL_PRESETS[str(example["model_key"])]
|
| 242 |
status = (
|
|
@@ -336,25 +346,51 @@ def generate(
|
|
| 336 |
|
| 337 |
|
| 338 |
APP_CSS = """
|
| 339 |
-
#
|
| 340 |
width: 100%;
|
| 341 |
}
|
| 342 |
|
| 343 |
-
#
|
| 344 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 345 |
object-fit: cover;
|
|
|
|
| 346 |
}
|
| 347 |
|
| 348 |
-
#
|
| 349 |
-
#examples_gallery .caption {
|
| 350 |
white-space: normal;
|
| 351 |
line-height: 1.35;
|
| 352 |
}
|
| 353 |
"""
|
| 354 |
|
| 355 |
|
| 356 |
-
with gr.Blocks(title=
|
| 357 |
-
gr.Markdown(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 358 |
|
| 359 |
with gr.Row():
|
| 360 |
with gr.Column(scale=1, min_width=320):
|
|
@@ -407,22 +443,27 @@ with gr.Blocks(title="SeFi Image ZeroGPU") as demo:
|
|
| 407 |
)
|
| 408 |
)
|
| 409 |
|
| 410 |
-
examples = gr.
|
| 411 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 412 |
label="Examples",
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
height=None,
|
| 416 |
-
object_fit="cover",
|
| 417 |
-
allow_preview=False,
|
| 418 |
-
interactive=False,
|
| 419 |
-
type="filepath",
|
| 420 |
-
elem_id="examples_gallery",
|
| 421 |
)
|
| 422 |
|
| 423 |
model.change(model_defaults, inputs=model, outputs=[steps, guidance, status])
|
| 424 |
-
examples.
|
| 425 |
load_example,
|
|
|
|
| 426 |
outputs=[
|
| 427 |
model,
|
| 428 |
prompt,
|
|
@@ -454,4 +495,8 @@ with gr.Blocks(title="SeFi Image ZeroGPU") as demo:
|
|
| 454 |
demo.queue(default_concurrency_limit=1)
|
| 455 |
|
| 456 |
if __name__ == "__main__":
|
| 457 |
-
demo.launch(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
}
|
| 90 |
|
| 91 |
DEFAULT_MODEL = "1b-turbo"
|
| 92 |
+
APP_TITLE = "SeFi-Image"
|
| 93 |
+
MODEL_PUBLISHER_URL = "https://huggingface.co/SeFi-Image"
|
| 94 |
+
PROJECT_PAGE_URL = "https://jmliu206.github.io/sefi-web/"
|
| 95 |
IMAGE_SIZE = 1024
|
| 96 |
TURBO_STEPS = {4, 8, 10}
|
| 97 |
GPU_DURATION_BY_MODEL = {
|
|
|
|
| 160 |
return [(preset.label, key) for key, preset in MODEL_PRESETS.items()]
|
| 161 |
|
| 162 |
|
| 163 |
+
def _example_samples() -> list[list[str]]:
|
| 164 |
+
samples = []
|
| 165 |
for example in EXAMPLES:
|
| 166 |
preset = MODEL_PRESETS[str(example["model_key"])]
|
| 167 |
+
settings = (
|
| 168 |
+
f"{IMAGE_SIZE}x{IMAGE_SIZE}, {example['steps']} steps, "
|
| 169 |
+
f"guidance {example['guidance']}, seed {example['seed']}"
|
| 170 |
)
|
| 171 |
+
samples.append(
|
| 172 |
+
[
|
| 173 |
+
str(example["image"]),
|
| 174 |
+
str(example["label"]),
|
| 175 |
+
preset.label,
|
| 176 |
+
str(example["prompt"]),
|
| 177 |
+
settings,
|
| 178 |
+
]
|
| 179 |
+
)
|
| 180 |
+
return samples
|
| 181 |
|
| 182 |
|
| 183 |
def _torch_cleanup() -> None:
|
|
|
|
| 246 |
)
|
| 247 |
|
| 248 |
|
| 249 |
+
def load_example(index: int):
|
|
|
|
| 250 |
example = EXAMPLES[int(index)]
|
| 251 |
preset = MODEL_PRESETS[str(example["model_key"])]
|
| 252 |
status = (
|
|
|
|
| 346 |
|
| 347 |
|
| 348 |
APP_CSS = """
|
| 349 |
+
#examples_table {
|
| 350 |
width: 100%;
|
| 351 |
}
|
| 352 |
|
| 353 |
+
#examples_table .table-wrap,
|
| 354 |
+
#examples_table .table-wrap.fixed-height {
|
| 355 |
+
height: auto !important;
|
| 356 |
+
max-height: none !important;
|
| 357 |
+
}
|
| 358 |
+
|
| 359 |
+
#examples_table table {
|
| 360 |
+
width: 100%;
|
| 361 |
+
}
|
| 362 |
+
|
| 363 |
+
#examples_table th,
|
| 364 |
+
#examples_table td {
|
| 365 |
+
vertical-align: middle;
|
| 366 |
+
}
|
| 367 |
+
|
| 368 |
+
#examples_table img {
|
| 369 |
+
width: 64px !important;
|
| 370 |
+
height: 64px !important;
|
| 371 |
object-fit: cover;
|
| 372 |
+
border-radius: 6px;
|
| 373 |
}
|
| 374 |
|
| 375 |
+
#examples_table td {
|
|
|
|
| 376 |
white-space: normal;
|
| 377 |
line-height: 1.35;
|
| 378 |
}
|
| 379 |
"""
|
| 380 |
|
| 381 |
|
| 382 |
+
with gr.Blocks(title=APP_TITLE) as demo:
|
| 383 |
+
gr.Markdown(
|
| 384 |
+
f"""
|
| 385 |
+
# {APP_TITLE}
|
| 386 |
+
|
| 387 |
+
SeFi-Image text-to-image checkpoints in Base, Turbo, and 5B RL variants. Base
|
| 388 |
+
models use the 50-step guidance-4.0 setting, Turbo models use the 4-step
|
| 389 |
+
guidance-1.0 setting, and 5B RL is the reinforced-learning checkpoint.
|
| 390 |
+
|
| 391 |
+
[Models on Hugging Face]({MODEL_PUBLISHER_URL}) | [Project page]({PROJECT_PAGE_URL})
|
| 392 |
+
"""
|
| 393 |
+
)
|
| 394 |
|
| 395 |
with gr.Row():
|
| 396 |
with gr.Column(scale=1, min_width=320):
|
|
|
|
| 443 |
)
|
| 444 |
)
|
| 445 |
|
| 446 |
+
examples = gr.Dataset(
|
| 447 |
+
samples=_example_samples(),
|
| 448 |
+
components=[
|
| 449 |
+
gr.Image(label="Image", type="filepath", height=64, width=64, render=False),
|
| 450 |
+
gr.Textbox(label="Example", render=False),
|
| 451 |
+
gr.Textbox(label="Model", render=False),
|
| 452 |
+
gr.Textbox(label="Prompt", render=False),
|
| 453 |
+
gr.Textbox(label="Settings", render=False),
|
| 454 |
+
],
|
| 455 |
+
headers=["Image", "Example", "Model", "Prompt", "Settings"],
|
| 456 |
+
type="index",
|
| 457 |
+
layout="table",
|
| 458 |
label="Examples",
|
| 459 |
+
samples_per_page=10,
|
| 460 |
+
elem_id="examples_table",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 461 |
)
|
| 462 |
|
| 463 |
model.change(model_defaults, inputs=model, outputs=[steps, guidance, status])
|
| 464 |
+
examples.click(
|
| 465 |
load_example,
|
| 466 |
+
inputs=examples,
|
| 467 |
outputs=[
|
| 468 |
model,
|
| 469 |
prompt,
|
|
|
|
| 495 |
demo.queue(default_concurrency_limit=1)
|
| 496 |
|
| 497 |
if __name__ == "__main__":
|
| 498 |
+
demo.launch(
|
| 499 |
+
allowed_paths=[str(EXAMPLE_ASSETS_DIR)],
|
| 500 |
+
css=APP_CSS,
|
| 501 |
+
ssr_mode=False,
|
| 502 |
+
)
|