Spaces:
Running
on
Zero
Running
on
Zero
Update app_3.py
Browse files
app_3.py
CHANGED
@@ -613,6 +613,13 @@ def extract_foreground(image):
|
|
613 |
logging.info(f"RGBA shape: {rgba.shape}, dtype: {rgba.dtype}")
|
614 |
return result, gr.update(visible=True), gr.update(visible=True)
|
615 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
616 |
@torch.inference_mode()
|
617 |
def process_bg(input_fg, input_bg, prompt, image_width, image_height, num_samples, seed, steps, a_prompt, n_prompt, cfg, highres_scale, highres_denoise, bg_source):
|
618 |
clear_memory()
|
@@ -923,6 +930,7 @@ def compress_image(image):
|
|
923 |
|
924 |
def use_orientation(selected_image:gr.SelectData):
|
925 |
return selected_image.value['image']['path']
|
|
|
926 |
|
927 |
@spaces.GPU(duration=60)
|
928 |
@torch.inference_mode
|
@@ -1188,9 +1196,9 @@ with block:
|
|
1188 |
angles_fg = gr.Image(type="pil", label="Converted Foreground", height=480, visible=False)
|
1189 |
|
1190 |
with gr.Row():
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
label="Result",
|
1195 |
show_label=False,
|
1196 |
columns=[3],
|
@@ -1201,8 +1209,12 @@ with block:
|
|
1201 |
)
|
1202 |
|
1203 |
if orientation_result:
|
1204 |
-
selected = gr.Number(visible=
|
1205 |
-
orientation_result.select(
|
|
|
|
|
|
|
|
|
1206 |
|
1207 |
# output_bg = gr.Image(type="numpy", label="Preprocessed Foreground", height=480)
|
1208 |
with gr.Group():
|
|
|
613 |
logging.info(f"RGBA shape: {rgba.shape}, dtype: {rgba.dtype}")
|
614 |
return result, gr.update(visible=True), gr.update(visible=True)
|
615 |
|
616 |
+
def update_extracted_fg_height(selected_image: gr.SelectData):
|
617 |
+
if selected_image:
|
618 |
+
# Get the height of the selected image
|
619 |
+
height = selected_image.value['image']['shape'][0] # Assuming the image is in numpy format
|
620 |
+
return gr.update(height=height) # Update the height of extracted_fg
|
621 |
+
return gr.update(height=480) # Default height if no image is selected
|
622 |
+
|
623 |
@torch.inference_mode()
|
624 |
def process_bg(input_fg, input_bg, prompt, image_width, image_height, num_samples, seed, steps, a_prompt, n_prompt, cfg, highres_scale, highres_denoise, bg_source):
|
625 |
clear_memory()
|
|
|
930 |
|
931 |
def use_orientation(selected_image:gr.SelectData):
|
932 |
return selected_image.value['image']['path']
|
933 |
+
|
934 |
|
935 |
@spaces.GPU(duration=60)
|
936 |
@torch.inference_mode
|
|
|
1196 |
angles_fg = gr.Image(type="pil", label="Converted Foreground", height=480, visible=False)
|
1197 |
|
1198 |
with gr.Row():
|
1199 |
+
with gr.Group():
|
1200 |
+
run_button = gr.Button("Generate alternative angles")
|
1201 |
+
orientation_result = gr.Gallery(
|
1202 |
label="Result",
|
1203 |
show_label=False,
|
1204 |
columns=[3],
|
|
|
1209 |
)
|
1210 |
|
1211 |
if orientation_result:
|
1212 |
+
#selected = gr.Number(visible=False)
|
1213 |
+
orientation_result.select(
|
1214 |
+
update_extracted_fg_height, # Function to call on selection
|
1215 |
+
inputs=None, # No inputs needed
|
1216 |
+
outputs=extracted_fg # Output to update the extracted_fg component
|
1217 |
+
).then(use_orientation, inputs=None, outputs=extracted_fg)
|
1218 |
|
1219 |
# output_bg = gr.Image(type="numpy", label="Preprocessed Foreground", height=480)
|
1220 |
with gr.Group():
|