roomGPT / app_hough.py
RamAnanth1's picture
Update app_hough.py
27daeb5
# This file is adapted from https://github.com/lllyasviel/ControlNet/blob/f4748e3630d8141d7765e2bd9b1e348f47847707/gradio_hough2image.py
# The original license file is LICENSE.ControlNet in this repo.
import gradio as gr
def create_demo(process, max_images=12, default_num_images=3):
with gr.Blocks() as demo:
with gr.Row():
gr.Markdown('### Use a photo of your room and reimagine it with different styles with the power of ControlNet')
with gr.Row():
with gr.Column():
input_image = gr.Image(source='upload', type='numpy')
prompt = gr.Textbox(label='Prompt')
run_button = gr.Button(label='Run')
with gr.Accordion('Advanced options', open=False):
num_samples = gr.Slider(label='Images',
minimum=1,
maximum=max_images,
value=default_num_images,
step=1)
image_resolution = gr.Slider(label='Image Resolution',
minimum=256,
maximum=512,
value=512,
step=256)
detect_resolution = gr.Slider(label='Hough Resolution',
minimum=128,
maximum=512,
value=512,
step=1)
mlsd_value_threshold = gr.Slider(
label='Hough value threshold (MLSD)',
minimum=0.01,
maximum=2.0,
value=0.1,
step=0.01)
mlsd_distance_threshold = gr.Slider(
label='Hough distance threshold (MLSD)',
minimum=0.01,
maximum=20.0,
value=0.1,
step=0.01)
num_steps = gr.Slider(label='Steps',
minimum=1,
maximum=100,
value=20,
step=1)
guidance_scale = gr.Slider(label='Guidance Scale',
minimum=0.1,
maximum=30.0,
value=9.0,
step=0.1)
seed = gr.Slider(label='Seed',
minimum=-1,
maximum=2147483647,
step=1,
randomize=True)
a_prompt = gr.Textbox(
label='Added Prompt',
value='best quality, extremely detailed, photo from Pinterest, interior, cinematic photo, ultra-detailed, ultra-realistic, award-winning')
n_prompt = gr.Textbox(
label='Negative Prompt',
value=
'lowres, cropped, worst quality, low quality'
)
with gr.Column():
result = gr.Gallery(label='Output',
show_label=False,
elem_id='gallery').style(grid=2,
height='auto')
inputs = [
input_image,
prompt,
a_prompt,
n_prompt,
num_samples,
image_resolution,
detect_resolution,
num_steps,
guidance_scale,
seed,
mlsd_value_threshold,
mlsd_distance_threshold,
]
prompt.submit(fn=process, inputs=inputs, outputs=result)
run_button.click(fn=process,
inputs=inputs,
outputs=result,
api_name='hough')
ex = gr.Examples(examples = [
["room.jpg",
"a room for gaming, with gaming chairs, gaming consoles and gaming computers",
"best quality, extremely detailed, photo from Pinterest, interior, cinematic photo, ultra-detailed, ultra-realistic, award-winning",
"lowres, cropped, worst quality, low quality",
2,
512,
512,
20,
9.0,
132794,
0.1,
0.1,
]],
inputs = inputs, outputs = result, fn = process, cache_examples = True)
return demo