Spaces:
Runtime error
Runtime error
Update merged_app2.py
Browse files- merged_app2.py +37 -27
merged_app2.py
CHANGED
@@ -448,7 +448,7 @@ def enable_efficient_attention():
|
|
448 |
def clear_memory():
|
449 |
if torch.cuda.is_available():
|
450 |
torch.cuda.empty_cache()
|
451 |
-
torch.cuda.synchronize()
|
452 |
|
453 |
# Enable efficient attention
|
454 |
enable_efficient_attention()
|
@@ -1631,7 +1631,7 @@ with gr.Blocks() as app:
|
|
1631 |
input_fg = gr.Image(type="pil", label="Image", height=480)
|
1632 |
with gr.Row():
|
1633 |
with gr.Group():
|
1634 |
-
find_objects_button = gr.Button(value="
|
1635 |
text_prompt = gr.Textbox(
|
1636 |
label="Text Prompt",
|
1637 |
placeholder="Enter object classes separated by periods (e.g. 'car . person .'), leave empty to get all objects",
|
@@ -1645,24 +1645,24 @@ with gr.Blocks() as app:
|
|
1645 |
|
1646 |
|
1647 |
|
1648 |
-
|
1649 |
-
|
1650 |
-
|
1651 |
-
|
1652 |
-
|
1653 |
-
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
-
|
1659 |
-
|
1660 |
-
|
1661 |
if orientation_result:
|
1662 |
orientation_result.select(use_orientation, inputs=None, outputs=extracted_fg)
|
1663 |
|
1664 |
dummy_image_for_outputs = gr.Image(visible=False, label='Result', type='pil')
|
1665 |
-
dummy_image_for_prompt_augmentation = gr.Image(type="pil", label="Dummy image", height=
|
1666 |
|
1667 |
|
1668 |
with gr.Column():
|
@@ -1676,10 +1676,10 @@ with gr.Blocks() as app:
|
|
1676 |
with gr.Group():
|
1677 |
gr.Markdown("Outpaint")
|
1678 |
with gr.Row():
|
1679 |
-
|
1680 |
-
|
1681 |
-
|
1682 |
-
|
1683 |
target_ratio = gr.Radio(
|
1684 |
label="Image Ratio",
|
1685 |
choices=["9:16", "16:9", "1:1", "Custom"],
|
@@ -1750,15 +1750,18 @@ with gr.Blocks() as app:
|
|
1750 |
with gr.Column():
|
1751 |
prompt = gr.Textbox(label="Prompt")
|
1752 |
with gr.Column():
|
1753 |
-
augment_prompt = gr.Button(value='+')
|
|
|
|
|
|
|
|
|
|
|
1754 |
bg_source = gr.Radio(choices=[e.value for e in list(BGSource)[2:]],
|
1755 |
value=BGSource.LEFT.value,
|
1756 |
label="Lighting Preference (Initial Latent)", type='value')
|
1757 |
|
1758 |
example_quick_subjects = gr.Dataset(samples=quick_subjects, label='Subject Quick List', samples_per_page=1000, components=[prompt])
|
1759 |
example_quick_prompts = gr.Dataset(samples=quick_prompts, label='Lighting Quick List', samples_per_page=1000, components=[prompt])
|
1760 |
-
with gr.Row():
|
1761 |
-
relight_button = gr.Button(value="Relight")
|
1762 |
|
1763 |
with gr.Group(visible=False):
|
1764 |
with gr.Row():
|
@@ -1771,7 +1774,6 @@ with gr.Blocks() as app:
|
|
1771 |
|
1772 |
with gr.Accordion("Advanced options", open=False):
|
1773 |
steps = gr.Slider(label="Steps", minimum=1, maximum=100, value=15, step=1)
|
1774 |
-
cfg = gr.Slider(label="CFG Scale", minimum=1.0, maximum=32.0, value=2, step=0.01, visible=False)
|
1775 |
lowres_denoise = gr.Slider(label="Lowres Denoise (for initial latent)", minimum=0.1, maximum=1.0, value=0.9, step=0.01)
|
1776 |
highres_scale = gr.Slider(label="Highres Scale", minimum=1.0, maximum=3.0, value=1.5, step=0.01)
|
1777 |
highres_denoise = gr.Slider(label="Highres Denoise", minimum=0.1, maximum=1.0, value=0.5, step=0.01)
|
@@ -1803,7 +1805,11 @@ with gr.Blocks() as app:
|
|
1803 |
# outputs=[result_gallery, output_bg],
|
1804 |
# run_on_click=True, examples_per_page=1024
|
1805 |
# )
|
1806 |
-
|
|
|
|
|
|
|
|
|
1807 |
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]
|
1808 |
|
1809 |
relight_button.click(fn=process_relight, inputs=ips, outputs=[result_gallery]).then(clear_memory, inputs=[], outputs=[])
|
@@ -1854,7 +1860,7 @@ with gr.Blocks() as app:
|
|
1854 |
).then(
|
1855 |
fn=inpaint,
|
1856 |
inputs=[dummy_image_for_outputs, width_slider, height_slider, overlap_percentage, num_inference_steps,
|
1857 |
-
resize_option, custom_resize_percentage,
|
1858 |
overlap_left, overlap_right, overlap_top, overlap_bottom],
|
1859 |
outputs=[fill_result])#.then(clear_memory, inputs=[], outputs=[])
|
1860 |
# ).then(
|
@@ -1946,17 +1952,21 @@ with gr.Blocks() as app:
|
|
1946 |
with gr.Row():
|
1947 |
with gr.Group():
|
1948 |
with gr.Column():
|
1949 |
-
describe_button = gr.Button(
|
1950 |
text_to_describe = gr.Textbox(value="Describe object or scene")
|
1951 |
description_text = gr.Textbox(
|
1952 |
label="Output",
|
1953 |
placeholder="",
|
1954 |
value=""
|
1955 |
)
|
|
|
1956 |
|
1957 |
|
1958 |
def send_img(img_result):
|
1959 |
return img_result
|
|
|
|
|
|
|
1960 |
|
1961 |
transfer_btn.click(send_img, [output_image], [input_fg]).then(clear_memory, inputs=[], outputs=[])
|
1962 |
|
|
|
448 |
def clear_memory():
|
449 |
if torch.cuda.is_available():
|
450 |
torch.cuda.empty_cache()
|
451 |
+
#torch.cuda.synchronize()
|
452 |
|
453 |
# Enable efficient attention
|
454 |
enable_efficient_attention()
|
|
|
1631 |
input_fg = gr.Image(type="pil", label="Image", height=480)
|
1632 |
with gr.Row():
|
1633 |
with gr.Group():
|
1634 |
+
find_objects_button = gr.Button(value="Segment Object from text")
|
1635 |
text_prompt = gr.Textbox(
|
1636 |
label="Text Prompt",
|
1637 |
placeholder="Enter object classes separated by periods (e.g. 'car . person .'), leave empty to get all objects",
|
|
|
1645 |
|
1646 |
|
1647 |
|
1648 |
+
with gr.Accordion(label="Alternative Angles", open=False) as alternative_angles:
|
1649 |
+
with gr.Group():
|
1650 |
+
run_button = gr.Button("Generate alternative angles")
|
1651 |
+
orientation_result = gr.Gallery(
|
1652 |
+
label="Result",
|
1653 |
+
show_label=False,
|
1654 |
+
columns=[3],
|
1655 |
+
rows=[2],
|
1656 |
+
object_fit="fill",
|
1657 |
+
height="auto",
|
1658 |
+
allow_preview=False,
|
1659 |
+
)
|
1660 |
+
|
1661 |
if orientation_result:
|
1662 |
orientation_result.select(use_orientation, inputs=None, outputs=extracted_fg)
|
1663 |
|
1664 |
dummy_image_for_outputs = gr.Image(visible=False, label='Result', type='pil')
|
1665 |
+
dummy_image_for_prompt_augmentation = gr.Image(type="pil", label="Dummy image", height=48, visible=False)
|
1666 |
|
1667 |
|
1668 |
with gr.Column():
|
|
|
1676 |
with gr.Group():
|
1677 |
gr.Markdown("Outpaint")
|
1678 |
with gr.Row():
|
1679 |
+
with gr.Column(scale=2):
|
1680 |
+
prompt_fill = gr.Textbox(label="Prompt (Optional)")
|
1681 |
+
with gr.Column(scale=1):
|
1682 |
+
fill_button = gr.Button("Generate")
|
1683 |
target_ratio = gr.Radio(
|
1684 |
label="Image Ratio",
|
1685 |
choices=["9:16", "16:9", "1:1", "Custom"],
|
|
|
1750 |
with gr.Column():
|
1751 |
prompt = gr.Textbox(label="Prompt")
|
1752 |
with gr.Column():
|
1753 |
+
augment_prompt = gr.Button(value='Improve Prompt (+)')
|
1754 |
+
|
1755 |
+
relight_button = gr.Button(value="Relight")
|
1756 |
+
|
1757 |
+
cfg = gr.Slider(label="Fidelity", minimum=0.1, maximum=5.0, value=2, step=0.01, visible=True)
|
1758 |
+
|
1759 |
bg_source = gr.Radio(choices=[e.value for e in list(BGSource)[2:]],
|
1760 |
value=BGSource.LEFT.value,
|
1761 |
label="Lighting Preference (Initial Latent)", type='value')
|
1762 |
|
1763 |
example_quick_subjects = gr.Dataset(samples=quick_subjects, label='Subject Quick List', samples_per_page=1000, components=[prompt])
|
1764 |
example_quick_prompts = gr.Dataset(samples=quick_prompts, label='Lighting Quick List', samples_per_page=1000, components=[prompt])
|
|
|
|
|
1765 |
|
1766 |
with gr.Group(visible=False):
|
1767 |
with gr.Row():
|
|
|
1774 |
|
1775 |
with gr.Accordion("Advanced options", open=False):
|
1776 |
steps = gr.Slider(label="Steps", minimum=1, maximum=100, value=15, step=1)
|
|
|
1777 |
lowres_denoise = gr.Slider(label="Lowres Denoise (for initial latent)", minimum=0.1, maximum=1.0, value=0.9, step=0.01)
|
1778 |
highres_scale = gr.Slider(label="Highres Scale", minimum=1.0, maximum=3.0, value=1.5, step=0.01)
|
1779 |
highres_denoise = gr.Slider(label="Highres Denoise", minimum=0.1, maximum=1.0, value=0.5, step=0.01)
|
|
|
1805 |
# outputs=[result_gallery, output_bg],
|
1806 |
# run_on_click=True, examples_per_page=1024
|
1807 |
# )
|
1808 |
+
|
1809 |
+
def move_prompt(prompt):
|
1810 |
+
return prompt
|
1811 |
+
|
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]).then(clear_memory, inputs=[], outputs=[])
|
|
|
1860 |
).then(
|
1861 |
fn=inpaint,
|
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])#.then(clear_memory, inputs=[], outputs=[])
|
1866 |
# ).then(
|
|
|
1952 |
with gr.Row():
|
1953 |
with gr.Group():
|
1954 |
with gr.Column():
|
1955 |
+
describe_button = gr.Button(label="Describe Image", visible=False)
|
1956 |
text_to_describe = gr.Textbox(value="Describe object or scene")
|
1957 |
description_text = gr.Textbox(
|
1958 |
label="Output",
|
1959 |
placeholder="",
|
1960 |
value=""
|
1961 |
)
|
1962 |
+
send_to_relight = gr.Button(label="Send to Relight")
|
1963 |
|
1964 |
|
1965 |
def send_img(img_result):
|
1966 |
return img_result
|
1967 |
+
|
1968 |
+
|
1969 |
+
send_to_relight.click(move_prompt, [description_text], [prompt]).then(move_prompt, [description_text], [prompt_fill])
|
1970 |
|
1971 |
transfer_btn.click(send_img, [output_image], [input_fg]).then(clear_memory, inputs=[], outputs=[])
|
1972 |
|