Spaces:
Runtime error
Runtime error
Update merged_app2.py
Browse files- merged_app2.py +30 -14
merged_app2.py
CHANGED
@@ -348,7 +348,6 @@ def prepare_image_and_mask(image, width, height, overlap_percentage, resize_opti
|
|
348 |
@spaces.GPU(duration=60)
|
349 |
@torch.inference_mode()
|
350 |
def inpaint(image, width, height, overlap_percentage, num_inference_steps, resize_option, custom_resize_percentage, prompt_input, alignment, overlap_left, overlap_right, overlap_top, overlap_bottom, progress=gr.Progress(track_tqdm=True)):
|
351 |
-
clear_memory()
|
352 |
|
353 |
background, mask = prepare_image_and_mask(image, width, height, overlap_percentage, resize_option, custom_resize_percentage, alignment, overlap_left, overlap_right, overlap_top, overlap_bottom)
|
354 |
|
@@ -1812,7 +1811,7 @@ with gr.Blocks() as app:
|
|
1812 |
augment_prompt.click(generate_description, inputs=[prompt, extracted_fg], outputs=[prompt]).then(move_prompt, [prompt], [prompt_fill])
|
1813 |
ips = [extracted_fg, prompt, image_width, image_height, num_samples, seed, steps, a_prompt, n_prompt, cfg, highres_scale, highres_denoise, lowres_denoise, bg_source]
|
1814 |
|
1815 |
-
relight_button.click(fn=process_relight, inputs=ips, outputs=[result_gallery])
|
1816 |
example_quick_prompts.click(lambda x, y: ', '.join(y.split(', ')[:2] + [x[0]]), inputs=[example_quick_prompts, prompt], outputs=prompt, show_progress=False, queue=False)
|
1817 |
example_quick_subjects.click(lambda x: x[0], inputs=example_quick_subjects, outputs=prompt, show_progress=False, queue=False)
|
1818 |
|
@@ -1853,6 +1852,22 @@ with gr.Blocks() as app:
|
|
1853 |
queue=False
|
1854 |
)
|
1855 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1856 |
fill_button.click(
|
1857 |
fn=clear_result,
|
1858 |
inputs=None,
|
@@ -1862,23 +1877,24 @@ with gr.Blocks() as app:
|
|
1862 |
inputs=[dummy_image_for_outputs, width_slider, height_slider, overlap_percentage, num_inference_steps,
|
1863 |
resize_option, custom_resize_percentage, prompt_fill, alignment_dropdown,
|
1864 |
overlap_left, overlap_right, overlap_top, overlap_bottom],
|
1865 |
-
outputs=[fill_result])
|
1866 |
# ).then(
|
1867 |
# fn=lambda: gr.update(visible=True),
|
1868 |
# inputs=None,
|
1869 |
# outputs=use_as_input_button,
|
1870 |
# )
|
1871 |
|
1872 |
-
|
1873 |
-
|
1874 |
-
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
1878 |
-
|
1879 |
-
|
1880 |
-
|
1881 |
-
|
|
|
1882 |
|
1883 |
def convert_to_pil(image):
|
1884 |
try:
|
@@ -1985,5 +2001,5 @@ with gr.Blocks() as app:
|
|
1985 |
).then(clear_memory, inputs=[], outputs=[])
|
1986 |
|
1987 |
if __name__ == "__main__":
|
1988 |
-
app.queue()
|
1989 |
app.launch(share=True)
|
|
|
348 |
@spaces.GPU(duration=60)
|
349 |
@torch.inference_mode()
|
350 |
def inpaint(image, width, height, overlap_percentage, num_inference_steps, resize_option, custom_resize_percentage, prompt_input, alignment, overlap_left, overlap_right, overlap_top, overlap_bottom, progress=gr.Progress(track_tqdm=True)):
|
|
|
351 |
|
352 |
background, mask = prepare_image_and_mask(image, width, height, overlap_percentage, resize_option, custom_resize_percentage, alignment, overlap_left, overlap_right, overlap_top, overlap_bottom)
|
353 |
|
|
|
1811 |
augment_prompt.click(generate_description, inputs=[prompt, extracted_fg], outputs=[prompt]).then(move_prompt, [prompt], [prompt_fill])
|
1812 |
ips = [extracted_fg, prompt, image_width, image_height, num_samples, seed, steps, a_prompt, n_prompt, cfg, highres_scale, highres_denoise, lowres_denoise, bg_source]
|
1813 |
|
1814 |
+
relight_button.click(fn=process_relight, inputs=ips, outputs=[result_gallery])#.then(clear_memory, inputs=[], outputs=[])
|
1815 |
example_quick_prompts.click(lambda x, y: ', '.join(y.split(', ')[:2] + [x[0]]), inputs=[example_quick_prompts, prompt], outputs=prompt, show_progress=False, queue=False)
|
1816 |
example_quick_subjects.click(lambda x: x[0], inputs=example_quick_subjects, outputs=prompt, show_progress=False, queue=False)
|
1817 |
|
|
|
1852 |
queue=False
|
1853 |
)
|
1854 |
|
1855 |
+
# fill_button.click(
|
1856 |
+
# fn=clear_result,
|
1857 |
+
# inputs=None,
|
1858 |
+
# outputs=fill_result,
|
1859 |
+
# ).then(
|
1860 |
+
# fn=inpaint,
|
1861 |
+
# inputs=[dummy_image_for_outputs, width_slider, height_slider, overlap_percentage, num_inference_steps,
|
1862 |
+
# resize_option, custom_resize_percentage, prompt_fill, alignment_dropdown,
|
1863 |
+
# overlap_left, overlap_right, overlap_top, overlap_bottom],
|
1864 |
+
# outputs=[fill_result])
|
1865 |
+
# ).then(
|
1866 |
+
# fn=lambda: gr.update(visible=True),
|
1867 |
+
# inputs=None,
|
1868 |
+
# outputs=use_as_input_button,
|
1869 |
+
# )
|
1870 |
+
|
1871 |
fill_button.click(
|
1872 |
fn=clear_result,
|
1873 |
inputs=None,
|
|
|
1877 |
inputs=[dummy_image_for_outputs, width_slider, height_slider, overlap_percentage, num_inference_steps,
|
1878 |
resize_option, custom_resize_percentage, prompt_fill, alignment_dropdown,
|
1879 |
overlap_left, overlap_right, overlap_top, overlap_bottom],
|
1880 |
+
outputs=[fill_result])
|
1881 |
# ).then(
|
1882 |
# fn=lambda: gr.update(visible=True),
|
1883 |
# inputs=None,
|
1884 |
# outputs=use_as_input_button,
|
1885 |
# )
|
1886 |
|
1887 |
+
prompt_fill.submit(
|
1888 |
+
fn=clear_result,
|
1889 |
+
inputs=None,
|
1890 |
+
outputs=fill_result,
|
1891 |
+
).then(
|
1892 |
+
fn=inpaint,
|
1893 |
+
inputs=[dummy_image_for_outputs, width_slider, height_slider, overlap_percentage, num_inference_steps,
|
1894 |
+
resize_option, custom_resize_percentage, prompt_fill, alignment_dropdown,
|
1895 |
+
overlap_left, overlap_right, overlap_top, overlap_bottom],
|
1896 |
+
outputs=[fill_result])
|
1897 |
+
|
1898 |
|
1899 |
def convert_to_pil(image):
|
1900 |
try:
|
|
|
2001 |
).then(clear_memory, inputs=[], outputs=[])
|
2002 |
|
2003 |
if __name__ == "__main__":
|
2004 |
+
app.queue(default_concurrency_limit=3)
|
2005 |
app.launch(share=True)
|