Spaces:
Runtime error
Runtime error
Update merged_files3.py
Browse files- merged_files3.py +28 -16
merged_files3.py
CHANGED
@@ -153,6 +153,11 @@ def download_models():
|
|
153 |
ensure_directories()
|
154 |
download_models()
|
155 |
|
|
|
|
|
|
|
|
|
|
|
156 |
|
157 |
hf_hub_download(repo_id="black-forest-labs/FLUX.1-Redux-dev", filename="flux1-redux-dev.safetensors", local_dir="models/style_models")
|
158 |
hf_hub_download(repo_id="black-forest-labs/FLUX.1-Depth-dev", filename="flux1-depth-dev.safetensors", local_dir="models/diffusion_models")
|
@@ -1698,10 +1703,10 @@ with gr.Blocks() as app:
|
|
1698 |
with gr.Group():
|
1699 |
gr.Markdown("Outpaint")
|
1700 |
with gr.Row():
|
1701 |
-
with gr.Column(scale=2):
|
1702 |
-
|
1703 |
-
with gr.Column(scale=1):
|
1704 |
-
|
1705 |
target_ratio = gr.Radio(
|
1706 |
label="Image Ratio",
|
1707 |
choices=["9:16", "16:9", "1:1", "Custom"],
|
@@ -1777,7 +1782,11 @@ with gr.Blocks() as app:
|
|
1777 |
example_quick_subjects = gr.Dataset(samples=quick_subjects, label='Subject Quick List', samples_per_page=1000, components=[prompt])
|
1778 |
example_quick_prompts = gr.Dataset(samples=quick_prompts, label='Lighting Quick List', samples_per_page=1000, components=[prompt])
|
1779 |
with gr.Row():
|
1780 |
-
|
|
|
|
|
|
|
|
|
1781 |
|
1782 |
with gr.Group(visible=False):
|
1783 |
with gr.Row():
|
@@ -1822,6 +1831,9 @@ with gr.Blocks() as app:
|
|
1822 |
# outputs=[result_gallery, output_bg],
|
1823 |
# run_on_click=True, examples_per_page=1024
|
1824 |
# )
|
|
|
|
|
|
|
1825 |
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]
|
1826 |
relight_button.click(fn=process_relight, inputs=ips, outputs=[result_gallery]).then(clear_memory, inputs=[], outputs=[])
|
1827 |
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)
|
@@ -1871,7 +1883,7 @@ with gr.Blocks() as app:
|
|
1871 |
).then(
|
1872 |
fn=inpaint,
|
1873 |
inputs=[dummy_image_for_outputs, width_slider, height_slider, overlap_percentage, num_inference_steps,
|
1874 |
-
resize_option, custom_resize_percentage,
|
1875 |
overlap_left, overlap_right, overlap_top, overlap_bottom],
|
1876 |
outputs=[fill_result]).then(clear_memory, inputs=[], outputs=[])
|
1877 |
# ).then(
|
@@ -1880,16 +1892,16 @@ with gr.Blocks() as app:
|
|
1880 |
# outputs=use_as_input_button,
|
1881 |
# )
|
1882 |
|
1883 |
-
prompt_fill.submit(
|
1884 |
-
|
1885 |
-
|
1886 |
-
|
1887 |
-
).then(
|
1888 |
-
|
1889 |
-
|
1890 |
-
|
1891 |
-
|
1892 |
-
|
1893 |
|
1894 |
def convert_to_pil(image):
|
1895 |
try:
|
|
|
153 |
ensure_directories()
|
154 |
download_models()
|
155 |
|
156 |
+
def clear_memory():
|
157 |
+
if torch.cuda.is_available():
|
158 |
+
torch.cuda.empty_cache()
|
159 |
+
torch.cuda.synchronize()
|
160 |
+
|
161 |
|
162 |
hf_hub_download(repo_id="black-forest-labs/FLUX.1-Redux-dev", filename="flux1-redux-dev.safetensors", local_dir="models/style_models")
|
163 |
hf_hub_download(repo_id="black-forest-labs/FLUX.1-Depth-dev", filename="flux1-depth-dev.safetensors", local_dir="models/diffusion_models")
|
|
|
1703 |
with gr.Group():
|
1704 |
gr.Markdown("Outpaint")
|
1705 |
with gr.Row():
|
1706 |
+
# with gr.Column(scale=2):
|
1707 |
+
# prompt_fill = gr.Textbox(label="Prompt (Optional)")
|
1708 |
+
# with gr.Column(scale=1):
|
1709 |
+
fill_button = gr.Button("Generate")
|
1710 |
target_ratio = gr.Radio(
|
1711 |
label="Image Ratio",
|
1712 |
choices=["9:16", "16:9", "1:1", "Custom"],
|
|
|
1782 |
example_quick_subjects = gr.Dataset(samples=quick_subjects, label='Subject Quick List', samples_per_page=1000, components=[prompt])
|
1783 |
example_quick_prompts = gr.Dataset(samples=quick_prompts, label='Lighting Quick List', samples_per_page=1000, components=[prompt])
|
1784 |
with gr.Row():
|
1785 |
+
with gr.Column(scale=4):
|
1786 |
+
relight_button = gr.Button(value="Relight")
|
1787 |
+
with gr.Column(scale=1):
|
1788 |
+
augment_prompt = gr.Button(value='+')
|
1789 |
+
|
1790 |
|
1791 |
with gr.Group(visible=False):
|
1792 |
with gr.Row():
|
|
|
1831 |
# outputs=[result_gallery, output_bg],
|
1832 |
# run_on_click=True, examples_per_page=1024
|
1833 |
# )
|
1834 |
+
|
1835 |
+
augment_prompt.click(generate_description, inputs=[prompt], outputs=[prompt])
|
1836 |
+
|
1837 |
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]
|
1838 |
relight_button.click(fn=process_relight, inputs=ips, outputs=[result_gallery]).then(clear_memory, inputs=[], outputs=[])
|
1839 |
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)
|
|
|
1883 |
).then(
|
1884 |
fn=inpaint,
|
1885 |
inputs=[dummy_image_for_outputs, width_slider, height_slider, overlap_percentage, num_inference_steps,
|
1886 |
+
resize_option, custom_resize_percentage, prompt, alignment_dropdown,
|
1887 |
overlap_left, overlap_right, overlap_top, overlap_bottom],
|
1888 |
outputs=[fill_result]).then(clear_memory, inputs=[], outputs=[])
|
1889 |
# ).then(
|
|
|
1892 |
# outputs=use_as_input_button,
|
1893 |
# )
|
1894 |
|
1895 |
+
# prompt_fill.submit(
|
1896 |
+
# fn=clear_result,
|
1897 |
+
# inputs=None,
|
1898 |
+
# outputs=fill_result,
|
1899 |
+
# ).then(
|
1900 |
+
# fn=inpaint,
|
1901 |
+
# inputs=[dummy_image_for_outputs, width_slider, height_slider, overlap_percentage, num_inference_steps,
|
1902 |
+
# resize_option, custom_resize_percentage, prompt_fill, alignment_dropdown,
|
1903 |
+
# overlap_left, overlap_right, overlap_top, overlap_bottom],
|
1904 |
+
# outputs=[fill_result]).then(clear_memory, inputs=[], outputs=[])
|
1905 |
|
1906 |
def convert_to_pil(image):
|
1907 |
try:
|