Spaces:
Runtime error
Runtime error
Update gradio_demo.py
Browse files- gradio_demo.py +12 -9
gradio_demo.py
CHANGED
@@ -791,6 +791,15 @@ def get_depth(image):
|
|
791 |
|
792 |
from PIL import Image
|
793 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
794 |
def compress_image(image):
|
795 |
# Convert Gradio image (numpy array) to PIL Image
|
796 |
img = Image.fromarray(image)
|
@@ -1006,7 +1015,8 @@ with block:
|
|
1006 |
ips = [input_fg, prompt, image_width, image_height, num_samples, seed, steps, a_prompt, n_prompt, cfg, highres_scale, highres_denoise, lowres_denoise, bg_source]
|
1007 |
relight_button.click(fn=process_relight, inputs=ips, outputs=[extracted_fg, result_gallery], show_progress=True)
|
1008 |
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)
|
1009 |
-
example_quick_subjects.click(lambda x: x[0], inputs=example_quick_subjects, outputs=prompt, show_progress=False, queue=False
|
|
|
1010 |
extract_button.click(
|
1011 |
fn=extract_foreground,
|
1012 |
inputs=[input_fg],
|
@@ -1131,14 +1141,7 @@ with block:
|
|
1131 |
with gr.Column():
|
1132 |
result_gallery = gr.Image(height=832, label='Outputs')
|
1133 |
|
1134 |
-
|
1135 |
-
if image is None:
|
1136 |
-
return None, gr.update(visible=True), gr.update(visible=True)
|
1137 |
-
result, rgba = run_rmbg(image)
|
1138 |
-
mask_mover.set_extracted_fg(rgba)
|
1139 |
-
|
1140 |
-
return result, gr.update(visible=True), gr.update(visible=True)
|
1141 |
-
|
1142 |
|
1143 |
original_bg = None
|
1144 |
|
|
|
791 |
|
792 |
from PIL import Image
|
793 |
|
794 |
+
def extract_foreground(image):
|
795 |
+
if image is None:
|
796 |
+
return None, gr.update(visible=True), gr.update(visible=True)
|
797 |
+
result, rgba = run_rmbg(image)
|
798 |
+
mask_mover.set_extracted_fg(rgba)
|
799 |
+
|
800 |
+
return result, gr.update(visible=True), gr.update(visible=True)
|
801 |
+
|
802 |
+
|
803 |
def compress_image(image):
|
804 |
# Convert Gradio image (numpy array) to PIL Image
|
805 |
img = Image.fromarray(image)
|
|
|
1015 |
ips = [input_fg, prompt, image_width, image_height, num_samples, seed, steps, a_prompt, n_prompt, cfg, highres_scale, highres_denoise, lowres_denoise, bg_source]
|
1016 |
relight_button.click(fn=process_relight, inputs=ips, outputs=[extracted_fg, result_gallery], show_progress=True)
|
1017 |
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)
|
1018 |
+
example_quick_subjects.click(lambda x: x[0], inputs=example_quick_subjects, outputs=prompt, show_progress=False, queue=False
|
1019 |
+
|
1020 |
extract_button.click(
|
1021 |
fn=extract_foreground,
|
1022 |
inputs=[input_fg],
|
|
|
1141 |
with gr.Column():
|
1142 |
result_gallery = gr.Image(height=832, label='Outputs')
|
1143 |
|
1144 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1145 |
|
1146 |
original_bg = None
|
1147 |
|