Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import numpy as np
|
| 3 |
import random
|
| 4 |
import torch
|
|
@@ -15,6 +23,48 @@ import os
|
|
| 15 |
|
| 16 |
from huggingface_hub import hf_hub_download
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
def update_textbox(selected_items):
|
| 19 |
# Join the selected list of strings into a comma-separated string
|
| 20 |
return ", ".join(selected_items)
|
|
@@ -315,10 +365,13 @@ _HEADER_ = '''
|
|
| 315 |
</div>
|
| 316 |
|
| 317 |
|
| 318 |
-
<p style="font-size: 1rem; margin-bottom: 1.5rem;">Paper: <a href='https://witcherofresearch.github.io/TeleStyleV2' target='_blank'>
|
| 319 |
</p>
|
| 320 |
<p style="font-size: 1rem; margin-bottom: 1.5rem;">Please light a star for the <a href='https://github.com/Tele-AI/TeleStyleV2' target='_blank'>Code</a> if you find the demo useful, thank you.</p>
|
| 321 |
-
|
|
|
|
|
|
|
|
|
|
| 322 |
|
| 323 |
<p style="font-size: 1rem; margin-bottom: 1.5rem;">If you encounter an Error with this demo, the most possible reason is ZeroGPU out-of-memory and the solution is to decrease the Min Edge of the generated image from 1024 to a lower value. </p>
|
| 324 |
'''
|
|
@@ -401,6 +454,7 @@ with gr.Blocks() as demo:
|
|
| 401 |
step=8,
|
| 402 |
value=1024,
|
| 403 |
)
|
|
|
|
| 404 |
with gr.Row(), gr.Column():
|
| 405 |
gr.Markdown("## Examples")
|
| 406 |
gr.Markdown("changing the minedge could lead to different style similarity.")
|
|
@@ -430,13 +484,14 @@ with gr.Blocks() as demo:
|
|
| 430 |
outputs=[result, seed, content_prompt, style_prompt,prompt],
|
| 431 |
fn=infer,
|
| 432 |
cache_examples=False
|
| 433 |
-
)
|
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
# gr.Examples(examples=examples, inputs=[prompt], outputs=[result, seed], fn=infer, cache_examples=False)
|
|
|
|
| 440 |
|
| 441 |
gr.on(
|
| 442 |
triggers=[run_button.click],
|
|
@@ -460,7 +515,8 @@ with gr.Blocks() as demo:
|
|
| 460 |
|
| 461 |
|
| 462 |
if __name__ == "__main__":
|
| 463 |
-
demo.launch(server_name='0.0.0.0'
|
|
|
|
| 464 |
'''
|
| 465 |
['./qwenstyleref/pulpfiction_2.jpg','./qwenstyleref/styleref=6_style_ref.png',default_prompt,123,False,1.0,4,1024,[]],
|
| 466 |
['./qwenstyleref/styleref=0_content_ref.png','./qwenstyleref/110.png',default_prompt,123,False,1.0,4,1024,[]],
|
|
|
|
| 1 |
+
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
from typing import Iterable
|
| 4 |
import gradio as gr
|
| 5 |
+
from gradio.themes.base import Base
|
| 6 |
+
from gradio.themes.utils import colors, fonts, sizes
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
|
| 10 |
import numpy as np
|
| 11 |
import random
|
| 12 |
import torch
|
|
|
|
| 23 |
|
| 24 |
from huggingface_hub import hf_hub_download
|
| 25 |
|
| 26 |
+
class Seafoam(Base):
|
| 27 |
+
def __init__(
|
| 28 |
+
self,
|
| 29 |
+
*,
|
| 30 |
+
primary_hue: colors.Color | str = colors.emerald,
|
| 31 |
+
secondary_hue: colors.Color | str = colors.blue,
|
| 32 |
+
neutral_hue: colors.Color | str = colors.gray,
|
| 33 |
+
spacing_size: sizes.Size | str = sizes.spacing_md,
|
| 34 |
+
radius_size: sizes.Size | str = sizes.radius_md,
|
| 35 |
+
text_size: sizes.Size | str = sizes.text_lg,
|
| 36 |
+
font: fonts.Font
|
| 37 |
+
| str
|
| 38 |
+
| Iterable[fonts.Font | str] = (
|
| 39 |
+
fonts.GoogleFont("Quicksand"),
|
| 40 |
+
"ui-sans-serif",
|
| 41 |
+
"sans-serif",
|
| 42 |
+
),
|
| 43 |
+
font_mono: fonts.Font
|
| 44 |
+
| str
|
| 45 |
+
| Iterable[fonts.Font | str] = (
|
| 46 |
+
fonts.GoogleFont("IBM Plex Mono"),
|
| 47 |
+
"ui-monospace",
|
| 48 |
+
"monospace",
|
| 49 |
+
),
|
| 50 |
+
):
|
| 51 |
+
super().__init__(
|
| 52 |
+
primary_hue=primary_hue,
|
| 53 |
+
secondary_hue=secondary_hue,
|
| 54 |
+
neutral_hue=neutral_hue,
|
| 55 |
+
spacing_size=spacing_size,
|
| 56 |
+
radius_size=radius_size,
|
| 57 |
+
text_size=text_size,
|
| 58 |
+
font=font,
|
| 59 |
+
font_mono=font_mono,
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
+
seafoam = Seafoam()
|
| 63 |
+
CSS = """
|
| 64 |
+
.fillable { max-width: 960px !important; }
|
| 65 |
+
"""
|
| 66 |
+
|
| 67 |
+
|
| 68 |
def update_textbox(selected_items):
|
| 69 |
# Join the selected list of strings into a comma-separated string
|
| 70 |
return ", ".join(selected_items)
|
|
|
|
| 365 |
</div>
|
| 366 |
|
| 367 |
|
| 368 |
+
<p style="font-size: 1rem; margin-bottom: 1.5rem;">Paper: <a href='https://witcherofresearch.github.io/TeleStyleV2' target='_blank'>PromptRouter: Routing Different Image Customization Tasks via Simple Prompt</a> | Codes: <a href='https://github.com/witcherofresearch/PromptRoute' target='_blank'>GitHub</a>
|
| 369 |
</p>
|
| 370 |
<p style="font-size: 1rem; margin-bottom: 1.5rem;">Please light a star for the <a href='https://github.com/Tele-AI/TeleStyleV2' target='_blank'>Code</a> if you find the demo useful, thank you.</p>
|
| 371 |
+
|
| 372 |
+
<p style="font-size: 1rem; margin-bottom: 1.5rem;">In this demo, we question whether there exists any conflicts when learning multi-ref subject-driven image generation and content-preserving style transfer given content ref and style ref with a unified model. The conclusion is no and our PromptRoute's solution is simple: we attach "Compose the pictures" for multi-ref subject generation, and "Style Transfer the style of Figure 2 to Figure 1, and keep the content and characteristics of Figure 1." for content-preserving style transfer during training and inference. Such simple prompts distinguish the tasks and eliminate the confusion. </p>
|
| 373 |
+
|
| 374 |
+
<p style="font-size: 1rem; margin-bottom: 1.5rem;">Caution: If you choose infer with content/style prompt, pls do not forget to clean the prompt box when you run a new inference. The results of multi-ref subject generation are all 16:9 in this demo. </p>
|
| 375 |
|
| 376 |
<p style="font-size: 1rem; margin-bottom: 1.5rem;">If you encounter an Error with this demo, the most possible reason is ZeroGPU out-of-memory and the solution is to decrease the Min Edge of the generated image from 1024 to a lower value. </p>
|
| 377 |
'''
|
|
|
|
| 454 |
step=8,
|
| 455 |
value=1024,
|
| 456 |
)
|
| 457 |
+
"""
|
| 458 |
with gr.Row(), gr.Column():
|
| 459 |
gr.Markdown("## Examples")
|
| 460 |
gr.Markdown("changing the minedge could lead to different style similarity.")
|
|
|
|
| 484 |
outputs=[result, seed, content_prompt, style_prompt,prompt],
|
| 485 |
fn=infer,
|
| 486 |
cache_examples=False
|
| 487 |
+
)
|
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
# gr.Examples(examples=examples, inputs=[prompt], outputs=[result, seed], fn=infer, cache_examples=False)
|
| 494 |
+
"""
|
| 495 |
|
| 496 |
gr.on(
|
| 497 |
triggers=[run_button.click],
|
|
|
|
| 515 |
|
| 516 |
|
| 517 |
if __name__ == "__main__":
|
| 518 |
+
demo.launch(server_name='0.0.0.0',theme=seafoam,
|
| 519 |
+
css=CSS,)
|
| 520 |
'''
|
| 521 |
['./qwenstyleref/pulpfiction_2.jpg','./qwenstyleref/styleref=6_style_ref.png',default_prompt,123,False,1.0,4,1024,[]],
|
| 522 |
['./qwenstyleref/styleref=0_content_ref.png','./qwenstyleref/110.png',default_prompt,123,False,1.0,4,1024,[]],
|