Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -423,6 +423,12 @@ def run(style_reference_image, style_description, subject_prompt, subject_refere
|
|
| 423 |
result = infer(style_reference_image, style_description, subject_prompt)
|
| 424 |
return result
|
| 425 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 426 |
import gradio as gr
|
| 427 |
|
| 428 |
with gr.Blocks() as demo:
|
|
@@ -451,9 +457,11 @@ with gr.Blocks() as demo:
|
|
| 451 |
subject_prompt = gr.Textbox(
|
| 452 |
label = "Subject Prompt"
|
| 453 |
)
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
|
|
|
|
|
|
| 457 |
submit_btn = gr.Button("Submit")
|
| 458 |
|
| 459 |
|
|
@@ -461,7 +469,9 @@ with gr.Blocks() as demo:
|
|
| 461 |
output_image = gr.Image(label="Output Image")
|
| 462 |
gr.Examples(
|
| 463 |
examples = [
|
| 464 |
-
["./data/cyberpunk.png","cyberpunk art style","a car",None,False
|
|
|
|
|
|
|
| 465 |
["./data/melting_gold.png", "melting golden 3D rendering style", "a dog", "./data/dog.jpg", True]
|
| 466 |
],
|
| 467 |
fn=run,
|
|
@@ -470,11 +480,19 @@ with gr.Blocks() as demo:
|
|
| 470 |
cache_examples="lazy"
|
| 471 |
|
| 472 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 473 |
|
| 474 |
submit_btn.click(
|
| 475 |
fn = run,
|
| 476 |
inputs = [style_reference_image, style_description, subject_prompt, subject_reference, use_subject_ref],
|
| 477 |
-
outputs = [output_image]
|
|
|
|
| 478 |
)
|
| 479 |
|
| 480 |
-
demo.launch()
|
|
|
|
| 423 |
result = infer(style_reference_image, style_description, subject_prompt)
|
| 424 |
return result
|
| 425 |
|
| 426 |
+
def show_hide_subject_image_component(use_subject_ref):
|
| 427 |
+
if use_subject_ref is True:
|
| 428 |
+
return gr.update(open=True)
|
| 429 |
+
else:
|
| 430 |
+
return gr.update(open=False)
|
| 431 |
+
|
| 432 |
import gradio as gr
|
| 433 |
|
| 434 |
with gr.Blocks() as demo:
|
|
|
|
| 457 |
subject_prompt = gr.Textbox(
|
| 458 |
label = "Subject Prompt"
|
| 459 |
)
|
| 460 |
+
use_subject_ref = gr.Checkbox(label="Use Subject Image as Reference", value=False)
|
| 461 |
+
|
| 462 |
+
with gr.Accordion("Advanced Settings", open=False) as sub_img_panel:
|
| 463 |
+
subject_reference = gr.Image(label="Subject Reference", type="filepath")
|
| 464 |
+
|
| 465 |
submit_btn = gr.Button("Submit")
|
| 466 |
|
| 467 |
|
|
|
|
| 469 |
output_image = gr.Image(label="Output Image")
|
| 470 |
gr.Examples(
|
| 471 |
examples = [
|
| 472 |
+
["./data/cyberpunk.png", "cyberpunk art style", "a car", None, False],
|
| 473 |
+
["./data/mosaic.png", "mosaic art style", "a lighthouse", None, False],
|
| 474 |
+
["./data/glowing.png", "glowing style", "a dwarf", None, False],
|
| 475 |
["./data/melting_gold.png", "melting golden 3D rendering style", "a dog", "./data/dog.jpg", True]
|
| 476 |
],
|
| 477 |
fn=run,
|
|
|
|
| 480 |
cache_examples="lazy"
|
| 481 |
|
| 482 |
)
|
| 483 |
+
|
| 484 |
+
use_subject_ref.input(
|
| 485 |
+
fn = show_hide_subject_image_component,
|
| 486 |
+
inputs = [use_subject_ref],
|
| 487 |
+
outputs = [sub_img_panel],
|
| 488 |
+
queue = False
|
| 489 |
+
)
|
| 490 |
|
| 491 |
submit_btn.click(
|
| 492 |
fn = run,
|
| 493 |
inputs = [style_reference_image, style_description, subject_prompt, subject_reference, use_subject_ref],
|
| 494 |
+
outputs = [output_image],
|
| 495 |
+
show_api = False
|
| 496 |
)
|
| 497 |
|
| 498 |
+
demo.queue().launch(show_error=True, show_api=False)
|