|
|
|
|
|
import gradio as gr |
|
|
from regenerate import on_upload_image, handle_generate_button |
|
|
with gr.Blocks() as demo: |
|
|
|
|
|
|
|
|
gr.Markdown( |
|
|
""" |
|
|
# Interior Design AI: Regenerate Mode |
|
|
Upload an image, select objects to regenerate, and provide prompts. |
|
|
""" |
|
|
) |
|
|
|
|
|
with gr.Row(): |
|
|
with gr.Column(): |
|
|
input_image_component = gr.Image( |
|
|
type="pil", |
|
|
label="Upload an image of your room (PNG/JPG)", |
|
|
sources=["upload"], |
|
|
height=300, |
|
|
interactive=True |
|
|
) |
|
|
|
|
|
|
|
|
gr.Markdown("---") |
|
|
gr.Markdown("### Prompts & Seed") |
|
|
positive_prompt_textbox = gr.Textbox( |
|
|
label="Enter prompt", |
|
|
placeholder="a photograph of a room, interior design, 4k, high resolution", |
|
|
interactive=False |
|
|
) |
|
|
|
|
|
|
|
|
gr.Markdown("---") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
regenerate_objects_checkboxes = gr.CheckboxGroup( |
|
|
label="Choose which concepts you want to regenerate in the image", |
|
|
choices=[], |
|
|
interactive=False |
|
|
) |
|
|
|
|
|
|
|
|
generate_button = gr.Button("Generate Output", interactive=False) |
|
|
|
|
|
with gr.Column(): |
|
|
output_image_display = gr.Image(type="pil", label="Output Image", height=400) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
input_image_component.upload( |
|
|
fn=on_upload_image, |
|
|
inputs=[input_image_component], |
|
|
outputs=[ |
|
|
input_image_component, |
|
|
regenerate_objects_checkboxes, |
|
|
positive_prompt_textbox, |
|
|
generate_button |
|
|
] |
|
|
) |
|
|
|
|
|
generate_button.click( |
|
|
fn=handle_generate_button, |
|
|
inputs=[ |
|
|
positive_prompt_textbox, |
|
|
regenerate_objects_checkboxes, |
|
|
], |
|
|
outputs=[output_image_display] |
|
|
) |
|
|
|
|
|
demo.launch(debug=True) |