Spaces:
Runtime error
Runtime error
Update merged_app2.py
Browse files- merged_app2.py +12 -10
merged_app2.py
CHANGED
@@ -1054,7 +1054,8 @@ def use_orientation(selected_image:gr.SelectData):
|
|
1054 |
|
1055 |
|
1056 |
def generate_description(object_description,image, detail="high", max_tokens=250):
|
1057 |
-
|
|
|
1058 |
|
1059 |
if image is not None:
|
1060 |
try:
|
@@ -1799,7 +1800,7 @@ with gr.Blocks() as app:
|
|
1799 |
# run_on_click=True, examples_per_page=1024
|
1800 |
# )
|
1801 |
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]
|
1802 |
-
relight_button.click(fn=process_relight, inputs=ips, outputs=[result_gallery])
|
1803 |
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)
|
1804 |
example_quick_subjects.click(lambda x: x[0], inputs=example_quick_subjects, outputs=prompt, show_progress=False, queue=False)
|
1805 |
|
@@ -1849,7 +1850,7 @@ with gr.Blocks() as app:
|
|
1849 |
inputs=[dummy_image_for_outputs, width_slider, height_slider, overlap_percentage, num_inference_steps,
|
1850 |
resize_option, custom_resize_percentage, prompt_fill, alignment_dropdown,
|
1851 |
overlap_left, overlap_right, overlap_top, overlap_bottom],
|
1852 |
-
outputs=[fill_result])
|
1853 |
# ).then(
|
1854 |
# fn=lambda: gr.update(visible=True),
|
1855 |
# inputs=None,
|
@@ -1865,7 +1866,7 @@ with gr.Blocks() as app:
|
|
1865 |
inputs=[dummy_image_for_outputs, width_slider, height_slider, overlap_percentage, num_inference_steps,
|
1866 |
resize_option, custom_resize_percentage, prompt_fill, alignment_dropdown,
|
1867 |
overlap_left, overlap_right, overlap_top, overlap_bottom],
|
1868 |
-
outputs=[fill_result])
|
1869 |
|
1870 |
def convert_to_pil(image):
|
1871 |
try:
|
@@ -1888,19 +1889,20 @@ with gr.Blocks() as app:
|
|
1888 |
extracted_fg, # Already processed RGBA image
|
1889 |
],
|
1890 |
outputs=[orientation_result],
|
1891 |
-
)
|
1892 |
|
1893 |
find_objects_button.click(
|
1894 |
fn=process_image,
|
1895 |
inputs=[input_fg, text_prompt],
|
1896 |
outputs=[extracted_objects, extracted_fg]
|
1897 |
-
)
|
1898 |
|
1899 |
extract_button.click(
|
1900 |
fn=extract_foreground,
|
1901 |
inputs=[input_fg],
|
1902 |
outputs=[extracted_fg, x_slider, y_slider]
|
1903 |
-
)
|
|
|
1904 |
with gr.Tab("Style Transfer"):
|
1905 |
gr.Markdown("## Apply the style of an image to another one")
|
1906 |
with gr.Row():
|
@@ -1950,7 +1952,7 @@ with gr.Blocks() as app:
|
|
1950 |
def send_img(img_result):
|
1951 |
return img_result
|
1952 |
|
1953 |
-
transfer_btn.click(send_img, [output_image], [input_fg])
|
1954 |
|
1955 |
# describe_button.click(describe_image, [image_to_describe], [description_text])
|
1956 |
|
@@ -1958,13 +1960,13 @@ with gr.Blocks() as app:
|
|
1958 |
fn=generate_description,
|
1959 |
inputs=[text_to_describe,image_to_describe],
|
1960 |
outputs=description_text
|
1961 |
-
)
|
1962 |
|
1963 |
generate_btn.click(
|
1964 |
fn=generate_image,
|
1965 |
inputs=[prompt_input, structure_image, style_image, depth_strength, style_strength],
|
1966 |
outputs=[output_image]
|
1967 |
-
)
|
1968 |
|
1969 |
if __name__ == "__main__":
|
1970 |
app.launch(share=True)
|
|
|
1054 |
|
1055 |
|
1056 |
def generate_description(object_description,image, detail="high", max_tokens=250):
|
1057 |
+
openai_api_key = os.getenv["OPENAI_API_KEY"]
|
1058 |
+
client = OpenAI(api_key=openai_api_key)
|
1059 |
|
1060 |
if image is not None:
|
1061 |
try:
|
|
|
1800 |
# run_on_click=True, examples_per_page=1024
|
1801 |
# )
|
1802 |
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]
|
1803 |
+
relight_button.click(fn=process_relight, inputs=ips, outputs=[result_gallery]).then(clear_memory, inputs=[], outputs=[])
|
1804 |
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)
|
1805 |
example_quick_subjects.click(lambda x: x[0], inputs=example_quick_subjects, outputs=prompt, show_progress=False, queue=False)
|
1806 |
|
|
|
1850 |
inputs=[dummy_image_for_outputs, width_slider, height_slider, overlap_percentage, num_inference_steps,
|
1851 |
resize_option, custom_resize_percentage, prompt_fill, alignment_dropdown,
|
1852 |
overlap_left, overlap_right, overlap_top, overlap_bottom],
|
1853 |
+
outputs=[fill_result]).then(clear_memory, inputs=[], outputs=[])
|
1854 |
# ).then(
|
1855 |
# fn=lambda: gr.update(visible=True),
|
1856 |
# inputs=None,
|
|
|
1866 |
inputs=[dummy_image_for_outputs, width_slider, height_slider, overlap_percentage, num_inference_steps,
|
1867 |
resize_option, custom_resize_percentage, prompt_fill, alignment_dropdown,
|
1868 |
overlap_left, overlap_right, overlap_top, overlap_bottom],
|
1869 |
+
outputs=[fill_result]).then(clear_memory, inputs=[], outputs=[])
|
1870 |
|
1871 |
def convert_to_pil(image):
|
1872 |
try:
|
|
|
1889 |
extracted_fg, # Already processed RGBA image
|
1890 |
],
|
1891 |
outputs=[orientation_result],
|
1892 |
+
).then(clear_memory, inputs=[], outputs=[])
|
1893 |
|
1894 |
find_objects_button.click(
|
1895 |
fn=process_image,
|
1896 |
inputs=[input_fg, text_prompt],
|
1897 |
outputs=[extracted_objects, extracted_fg]
|
1898 |
+
).then(clear_memory, inputs=[], outputs=[])
|
1899 |
|
1900 |
extract_button.click(
|
1901 |
fn=extract_foreground,
|
1902 |
inputs=[input_fg],
|
1903 |
outputs=[extracted_fg, x_slider, y_slider]
|
1904 |
+
).then(clear_memory, inputs=[], outputs=[])
|
1905 |
+
|
1906 |
with gr.Tab("Style Transfer"):
|
1907 |
gr.Markdown("## Apply the style of an image to another one")
|
1908 |
with gr.Row():
|
|
|
1952 |
def send_img(img_result):
|
1953 |
return img_result
|
1954 |
|
1955 |
+
transfer_btn.click(send_img, [output_image], [input_fg]).then(clear_memory, inputs=[], outputs=[])
|
1956 |
|
1957 |
# describe_button.click(describe_image, [image_to_describe], [description_text])
|
1958 |
|
|
|
1960 |
fn=generate_description,
|
1961 |
inputs=[text_to_describe,image_to_describe],
|
1962 |
outputs=description_text
|
1963 |
+
).then(clear_memory, inputs=[], outputs=[])
|
1964 |
|
1965 |
generate_btn.click(
|
1966 |
fn=generate_image,
|
1967 |
inputs=[prompt_input, structure_image, style_image, depth_strength, style_strength],
|
1968 |
outputs=[output_image]
|
1969 |
+
).then(clear_memory, inputs=[], outputs=[])
|
1970 |
|
1971 |
if __name__ == "__main__":
|
1972 |
app.launch(share=True)
|