Spaces:
Runtime error
Runtime error
Update app_merged.py
Browse files- app_merged.py +10 -7
app_merged.py
CHANGED
@@ -71,6 +71,9 @@ import spaces
|
|
71 |
from huggingface_hub import hf_hub_download
|
72 |
|
73 |
|
|
|
|
|
|
|
74 |
|
75 |
|
76 |
client = httpx.Client(timeout=httpx.Timeout(10.0)) # Set timeout to 10 seconds
|
@@ -456,7 +459,7 @@ def enable_efficient_attention():
|
|
456 |
def clear_memory():
|
457 |
if torch.cuda.is_available():
|
458 |
torch.cuda.empty_cache()
|
459 |
-
torch.cuda.synchronize()
|
460 |
|
461 |
# Enable efficient attention
|
462 |
enable_efficient_attention()
|
@@ -1808,9 +1811,9 @@ with gr.Blocks() as app:
|
|
1808 |
# outputs=[result_gallery, output_bg],
|
1809 |
# run_on_click=True, examples_per_page=1024
|
1810 |
# )
|
1811 |
-
augment_prompt.click(generate_description, inputs=[prompt, extracted_fg], outputs=[prompt])
|
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 |
-
relight_button.click(fn=process_relight, inputs=ips, outputs=[result_gallery])
|
1814 |
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)
|
1815 |
example_quick_subjects.click(lambda x: x[0], inputs=example_quick_subjects, outputs=prompt, show_progress=False, queue=False)
|
1816 |
|
@@ -1860,7 +1863,7 @@ with gr.Blocks() as app:
|
|
1860 |
inputs=[dummy_image_for_outputs, width_slider, height_slider, overlap_percentage, num_inference_steps,
|
1861 |
resize_option, custom_resize_percentage, prompt_fill, alignment_dropdown,
|
1862 |
overlap_left, overlap_right, overlap_top, overlap_bottom],
|
1863 |
-
outputs=[fill_result])
|
1864 |
# ).then(
|
1865 |
# fn=lambda: gr.update(visible=True),
|
1866 |
# inputs=None,
|
@@ -1876,7 +1879,7 @@ with gr.Blocks() as app:
|
|
1876 |
inputs=[dummy_image_for_outputs, width_slider, height_slider, overlap_percentage, num_inference_steps,
|
1877 |
resize_option, custom_resize_percentage, prompt_fill, alignment_dropdown,
|
1878 |
overlap_left, overlap_right, overlap_top, overlap_bottom],
|
1879 |
-
outputs=[fill_result])
|
1880 |
|
1881 |
|
1882 |
def convert_to_pil(image):
|
@@ -1943,14 +1946,14 @@ with gr.Blocks() as app:
|
|
1943 |
def send_img(img_result):
|
1944 |
return img_result
|
1945 |
|
1946 |
-
transfer_btn.click(send_img, [output_image], [input_fg])
|
1947 |
|
1948 |
|
1949 |
generate_btn.click(
|
1950 |
fn=generate_image,
|
1951 |
inputs=[prompt_input, structure_image, style_image, depth_strength, style_strength],
|
1952 |
outputs=[output_image]
|
1953 |
-
)
|
1954 |
|
1955 |
if __name__ == "__main__":
|
1956 |
app.queue(default_concurrency_limit=3)
|
|
|
71 |
from huggingface_hub import hf_hub_download
|
72 |
|
73 |
|
74 |
+
MAX_IMAGE_WIDTH = 2048
|
75 |
+
IMAGE_FORMAT = "JPEG"
|
76 |
+
|
77 |
|
78 |
|
79 |
client = httpx.Client(timeout=httpx.Timeout(10.0)) # Set timeout to 10 seconds
|
|
|
459 |
def clear_memory():
|
460 |
if torch.cuda.is_available():
|
461 |
torch.cuda.empty_cache()
|
462 |
+
#torch.cuda.synchronize()
|
463 |
|
464 |
# Enable efficient attention
|
465 |
enable_efficient_attention()
|
|
|
1811 |
# outputs=[result_gallery, output_bg],
|
1812 |
# run_on_click=True, examples_per_page=1024
|
1813 |
# )
|
1814 |
+
augment_prompt.click(generate_description, inputs=[prompt, extracted_fg], outputs=[prompt]).then(clear_memory, inputs=[], outputs=[])
|
1815 |
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]
|
1816 |
+
relight_button.click(fn=process_relight, inputs=ips, outputs=[result_gallery]).then(clear_memory, inputs=[], outputs=[])
|
1817 |
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)
|
1818 |
example_quick_subjects.click(lambda x: x[0], inputs=example_quick_subjects, outputs=prompt, show_progress=False, queue=False)
|
1819 |
|
|
|
1863 |
inputs=[dummy_image_for_outputs, width_slider, height_slider, overlap_percentage, num_inference_steps,
|
1864 |
resize_option, custom_resize_percentage, prompt_fill, alignment_dropdown,
|
1865 |
overlap_left, overlap_right, overlap_top, overlap_bottom],
|
1866 |
+
outputs=[fill_result]).then(clear_memory, inputs=[], outputs=[])
|
1867 |
# ).then(
|
1868 |
# fn=lambda: gr.update(visible=True),
|
1869 |
# inputs=None,
|
|
|
1879 |
inputs=[dummy_image_for_outputs, width_slider, height_slider, overlap_percentage, num_inference_steps,
|
1880 |
resize_option, custom_resize_percentage, prompt_fill, alignment_dropdown,
|
1881 |
overlap_left, overlap_right, overlap_top, overlap_bottom],
|
1882 |
+
outputs=[fill_result]).then(clear_memory, inputs=[], outputs=[])
|
1883 |
|
1884 |
|
1885 |
def convert_to_pil(image):
|
|
|
1946 |
def send_img(img_result):
|
1947 |
return img_result
|
1948 |
|
1949 |
+
transfer_btn.click(send_img, [output_image], [input_fg]).then(clear_memory, inputs=[], outputs=[])
|
1950 |
|
1951 |
|
1952 |
generate_btn.click(
|
1953 |
fn=generate_image,
|
1954 |
inputs=[prompt_input, structure_image, style_image, depth_strength, style_strength],
|
1955 |
outputs=[output_image]
|
1956 |
+
).then(clear_memory, inputs=[], outputs=[]).then(clear_memory, inputs=[], outputs=[])
|
1957 |
|
1958 |
if __name__ == "__main__":
|
1959 |
app.queue(default_concurrency_limit=3)
|