Spaces:
Running
Running
Update app_with_diffusers.py
Browse files- app_with_diffusers.py +4 -3
app_with_diffusers.py
CHANGED
@@ -39,13 +39,13 @@ pipe.aggregator.load_state_dict(pretrained_state_dict)
|
|
39 |
pipe.to(device='cuda', dtype=torch.float16)
|
40 |
pipe.aggregator.to(device='cuda', dtype=torch.float16)
|
41 |
|
42 |
-
def infer(input_image):
|
43 |
# load a broken image
|
44 |
low_quality_image = Image.open(input_image).convert("RGB")
|
45 |
|
46 |
# InstantIR restoration
|
47 |
image = pipe(
|
48 |
-
prompt=
|
49 |
image=low_quality_image,
|
50 |
previewer_scheduler=lcm_scheduler,
|
51 |
).images[0]
|
@@ -59,11 +59,12 @@ with gr.Blocks() as demo:
|
|
59 |
with gr.Row():
|
60 |
with gr.Column():
|
61 |
lq_img = gr.Image(label="Low-quality image", type="filepath")
|
|
|
62 |
submit_btn = gr.Button("InstantIR magic!")
|
63 |
output_img = gr.Image(label="InstantIR restored")
|
64 |
submit_btn.click(
|
65 |
fn=infer,
|
66 |
-
inputs=[lq_img],
|
67 |
outputs=[output_img]
|
68 |
)
|
69 |
demo.launch(show_error=True)
|
|
|
39 |
pipe.to(device='cuda', dtype=torch.float16)
|
40 |
pipe.aggregator.to(device='cuda', dtype=torch.float16)
|
41 |
|
42 |
+
def infer(prompt, input_image):
|
43 |
# load a broken image
|
44 |
low_quality_image = Image.open(input_image).convert("RGB")
|
45 |
|
46 |
# InstantIR restoration
|
47 |
image = pipe(
|
48 |
+
prompt=prompt,
|
49 |
image=low_quality_image,
|
50 |
previewer_scheduler=lcm_scheduler,
|
51 |
).images[0]
|
|
|
59 |
with gr.Row():
|
60 |
with gr.Column():
|
61 |
lq_img = gr.Image(label="Low-quality image", type="filepath")
|
62 |
+
prompt = gr.Textbox(label="Prompt", value="")
|
63 |
submit_btn = gr.Button("InstantIR magic!")
|
64 |
output_img = gr.Image(label="InstantIR restored")
|
65 |
submit_btn.click(
|
66 |
fn=infer,
|
67 |
+
inputs=[prompt, lq_img],
|
68 |
outputs=[output_img]
|
69 |
)
|
70 |
demo.launch(show_error=True)
|