Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -316,22 +316,11 @@ if __name__ == "__main__":
|
|
| 316 |
with gr.Blocks() as demo:
|
| 317 |
|
| 318 |
gr.Markdown("""
|
| 319 |
-
###
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
</a>
|
| 325 |
-
<a href="https://bytedance.github.io/XVerse/">
|
| 326 |
-
<img alt="Project Page" src="https://img.shields.io/badge/Project-Page-blue">
|
| 327 |
-
</a>
|
| 328 |
-
<a href="https://huggingface.co/ByteDance/XVerse">
|
| 329 |
-
<img alt="Build" src="https://img.shields.io/badge/🤗-HF%20Model-yellow">
|
| 330 |
-
</a>
|
| 331 |
-
<a href="https://github.com/ByteDance/XVerse">
|
| 332 |
-
<img alt="Build" src="https://img.shields.io/badge/Github-Repo-blue">
|
| 333 |
-
</a>
|
| 334 |
-
</p>
|
| 335 |
|
| 336 |
#### Input Images and Prompts
|
| 337 |
|
|
@@ -363,100 +352,102 @@ if __name__ == "__main__":
|
|
| 363 |
det_btns.append(det_btn)
|
| 364 |
vlm_btns.append(vlm_btn)
|
| 365 |
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 370 |
* **Generated Height/Width**: Use the sliders to set the shape of the output image.
|
| 371 |
* **Weight_id/ip**: Adjust these weight parameters. Higher values generally lead to better subject consistency but might slightly impact the naturalness of the generated image.
|
| 372 |
* **latent_lora_scale and vae_lora_scale**: Control the LoRA scale. Similar to Weight_id/ip, larger LoRA values can improve subject consistency but may reduce image naturalness.
|
| 373 |
* **vae_skip_iter_before and vae_skip_iter_after**: Configure VAE skip iterations. Skipping more steps can result in better naturalness but might compromise subject consistency.
|
| 374 |
""")
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 392 |
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
)
|
| 414 |
-
vae_skip_iter_s1.change(
|
| 415 |
-
lambda s1, s2: f"0-{s1}:1,{s2}-1:1",
|
| 416 |
-
inputs=[vae_skip_iter_s1, vae_skip_iter_s2],
|
| 417 |
-
outputs=vae_skip_iter
|
| 418 |
-
)
|
| 419 |
-
vae_skip_iter_s2.change(
|
| 420 |
-
lambda s1, s2: f"0-{s1}:1,{s2}-1:1",
|
| 421 |
-
inputs=[vae_skip_iter_s1, vae_skip_iter_s2],
|
| 422 |
-
outputs=vae_skip_iter
|
| 423 |
-
)
|
| 424 |
-
|
| 425 |
-
with gr.Row():
|
| 426 |
-
db_latent_lora_scale_str = gr.Textbox(
|
| 427 |
-
value="0-1:0.85",
|
| 428 |
-
label="db_latent_lora_scale_str",
|
| 429 |
-
interactive=False, visible=False
|
| 430 |
-
)
|
| 431 |
-
sb_latent_lora_scale_str = gr.Textbox(
|
| 432 |
-
value="0-1:0.85",
|
| 433 |
-
label="sb_latent_lora_scale_str",
|
| 434 |
-
interactive=False, visible=False
|
| 435 |
)
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
|
| 440 |
)
|
| 441 |
-
vae_lora_scale.change(
|
| 442 |
-
lambda s: f"0-1:{s}",
|
| 443 |
-
inputs=vae_lora_scale,
|
| 444 |
-
outputs=vae_lora_scale_str
|
| 445 |
-
)
|
| 446 |
-
ip_scale_str.change(
|
| 447 |
-
lambda s: [f"0-1:{s}", f"0-1:{s}"],
|
| 448 |
-
inputs=ip_scale_str,
|
| 449 |
-
outputs=[db_latent_lora_scale_str, sb_latent_lora_scale_str]
|
| 450 |
-
)
|
| 451 |
-
|
| 452 |
-
with gr.Row():
|
| 453 |
-
double_attention = gr.Checkbox(value=False, label="Double Attention", visible=False)
|
| 454 |
-
single_attention = gr.Checkbox(value=True, label="Single Attention", visible=False)
|
| 455 |
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
|
| 461 |
gr.Markdown("### Examples")
|
| 462 |
gen_btn.click(
|
|
|
|
| 316 |
with gr.Blocks() as demo:
|
| 317 |
|
| 318 |
gr.Markdown("""
|
| 319 |
+
### XVerse Demo
|
| 320 |
+
|
| 321 |
+
- **Paper**: [XVerse: A Versatile Image Generation Framework for Subject Consistency](https://arxiv.org/abs/2506.21416)
|
| 322 |
+
- **GitHub**: [ByteDance/XVerse](https://github.com/bytedance/XVerse)
|
| 323 |
+
- **Project Page**: [ByteDance/XVerse](https://bytedance.github.io/XVerse/)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 324 |
|
| 325 |
#### Input Images and Prompts
|
| 326 |
|
|
|
|
| 352 |
det_btns.append(det_btn)
|
| 353 |
vlm_btns.append(vlm_btn)
|
| 354 |
|
| 355 |
+
with gr.Column():
|
| 356 |
+
output = gr.Image(label="Generated Image")
|
| 357 |
+
seed = gr.Number(value=42, label="Seed", info="")
|
| 358 |
+
gen_btn = gr.Button("Generate Image")
|
| 359 |
+
|
| 360 |
+
with gr.Row():
|
| 361 |
+
|
| 362 |
+
# 将其他设置参数压缩到 Advanced Accordion 内
|
| 363 |
+
with gr.Accordion("Advanced Settings Explained", open=False):
|
| 364 |
+
gr.Markdown("""The Gradio demo provides several parameters to control your image generation process:
|
| 365 |
* **Generated Height/Width**: Use the sliders to set the shape of the output image.
|
| 366 |
* **Weight_id/ip**: Adjust these weight parameters. Higher values generally lead to better subject consistency but might slightly impact the naturalness of the generated image.
|
| 367 |
* **latent_lora_scale and vae_lora_scale**: Control the LoRA scale. Similar to Weight_id/ip, larger LoRA values can improve subject consistency but may reduce image naturalness.
|
| 368 |
* **vae_skip_iter_before and vae_skip_iter_after**: Configure VAE skip iterations. Skipping more steps can result in better naturalness but might compromise subject consistency.
|
| 369 |
""")
|
| 370 |
+
# 使用 Row 和 Column 来布局四个图像和描述
|
| 371 |
+
with gr.Row():
|
| 372 |
+
target_height = gr.Slider(512, 1024, step=128, value=768, label="Generated Height", info="")
|
| 373 |
+
target_width = gr.Slider(512, 1024, step=128, value=768, label="Generated Width", info="")
|
| 374 |
+
cond_size = gr.Slider(256, 384, step=128, value=256, label="Condition Size", info="")
|
| 375 |
+
with gr.Row():
|
| 376 |
+
# 修改 weight_id_ip_str 为两个 Slider
|
| 377 |
+
weight_id = gr.Slider(0.1, 5, step=0.1, value=3, label="weight_id")
|
| 378 |
+
weight_ip = gr.Slider(0.1, 5, step=0.1, value=5, label="weight_ip")
|
| 379 |
+
with gr.Row():
|
| 380 |
+
# 修改 ip_scale_str 为 Slider,并添加 Textbox 显示转换后的格式
|
| 381 |
+
ip_scale_str = gr.Slider(0.5, 1.5, step=0.01, value=0.85, label="latent_lora_scale")
|
| 382 |
+
vae_lora_scale = gr.Slider(0.5, 1.5, step=0.01, value=1.3, label="vae_lora_scale")
|
| 383 |
+
with gr.Row():
|
| 384 |
+
# 修改 vae_skip_iter 为两个 Slider
|
| 385 |
+
vae_skip_iter_s1 = gr.Slider(0, 1, step=0.01, value=0.05, label="vae_skip_iter_before")
|
| 386 |
+
vae_skip_iter_s2 = gr.Slider(0, 1, step=0.01, value=0.8, label="vae_skip_iter_after")
|
| 387 |
+
|
| 388 |
+
with gr.Row():
|
| 389 |
+
weight_id_ip_str = gr.Textbox(
|
| 390 |
+
value="0-1:1/3/5",
|
| 391 |
+
label="weight_id_ip_str",
|
| 392 |
+
interactive=False, visible=False
|
| 393 |
+
)
|
| 394 |
+
weight_id.change(
|
| 395 |
+
lambda s1, s2: f"0-1:1/{s1}/{s2}",
|
| 396 |
+
inputs=[weight_id, weight_ip],
|
| 397 |
+
outputs=weight_id_ip_str
|
| 398 |
+
)
|
| 399 |
+
weight_ip.change(
|
| 400 |
+
lambda s1, s2: f"0-1:1/{s1}/{s2}",
|
| 401 |
+
inputs=[weight_id, weight_ip],
|
| 402 |
+
outputs=weight_id_ip_str
|
| 403 |
+
)
|
| 404 |
+
vae_skip_iter = gr.Textbox(
|
| 405 |
+
value="0-0.05:1,0.8-1:1",
|
| 406 |
+
label="vae_skip_iter",
|
| 407 |
+
interactive=False, visible=False
|
| 408 |
+
)
|
| 409 |
+
vae_skip_iter_s1.change(
|
| 410 |
+
lambda s1, s2: f"0-{s1}:1,{s2}-1:1",
|
| 411 |
+
inputs=[vae_skip_iter_s1, vae_skip_iter_s2],
|
| 412 |
+
outputs=vae_skip_iter
|
| 413 |
+
)
|
| 414 |
+
vae_skip_iter_s2.change(
|
| 415 |
+
lambda s1, s2: f"0-{s1}:1,{s2}-1:1",
|
| 416 |
+
inputs=[vae_skip_iter_s1, vae_skip_iter_s2],
|
| 417 |
+
outputs=vae_skip_iter
|
| 418 |
+
)
|
| 419 |
|
| 420 |
+
with gr.Row():
|
| 421 |
+
db_latent_lora_scale_str = gr.Textbox(
|
| 422 |
+
value="0-1:0.85",
|
| 423 |
+
label="db_latent_lora_scale_str",
|
| 424 |
+
interactive=False, visible=False
|
| 425 |
+
)
|
| 426 |
+
sb_latent_lora_scale_str = gr.Textbox(
|
| 427 |
+
value="0-1:0.85",
|
| 428 |
+
label="sb_latent_lora_scale_str",
|
| 429 |
+
interactive=False, visible=False
|
| 430 |
+
)
|
| 431 |
+
vae_lora_scale_str = gr.Textbox(
|
| 432 |
+
value="0-1:1.3",
|
| 433 |
+
label="vae_lora_scale_str",
|
| 434 |
+
interactive=False, visible=False
|
| 435 |
+
)
|
| 436 |
+
vae_lora_scale.change(
|
| 437 |
+
lambda s: f"0-1:{s}",
|
| 438 |
+
inputs=vae_lora_scale,
|
| 439 |
+
outputs=vae_lora_scale_str
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 440 |
)
|
| 441 |
+
ip_scale_str.change(
|
| 442 |
+
lambda s: [f"0-1:{s}", f"0-1:{s}"],
|
| 443 |
+
inputs=ip_scale_str,
|
| 444 |
+
outputs=[db_latent_lora_scale_str, sb_latent_lora_scale_str]
|
| 445 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 446 |
|
| 447 |
+
with gr.Row():
|
| 448 |
+
double_attention = gr.Checkbox(value=False, label="Double Attention", visible=False)
|
| 449 |
+
single_attention = gr.Checkbox(value=True, label="Single Attention", visible=False)
|
| 450 |
+
|
| 451 |
|
| 452 |
gr.Markdown("### Examples")
|
| 453 |
gen_btn.click(
|