Spaces:
Runtime error
Runtime error
jens
commited on
Commit
·
5a6d6d4
1
Parent(s):
6e74f5b
fixed stream
Browse files
app.py
CHANGED
@@ -36,8 +36,6 @@ with block:
|
|
36 |
masks_annotated_image = gr.AnnotatedImage(label='Segments', height=512)
|
37 |
pcl_figure = gr.Model3D(label="3-D Reconstruction", clear_color=[1.0, 1.0, 1.0, 1.0])
|
38 |
n_samples = gr.Slider(minimum=1e3, maximum=1e6, step=1e3, default=1e3, label='Number of Samples')
|
39 |
-
#gr.Plot(label='3D Reconstruction')
|
40 |
-
#cutout_galary = gr.Gallery(label='Cutouts', object_fit='contain', height=512)
|
41 |
with gr.Row():
|
42 |
with gr.Column(scale=1):
|
43 |
with gr.Row():
|
@@ -51,16 +49,6 @@ with block:
|
|
51 |
components = {point_coords, point_labels, raw_image, masks, cutout_idx, input_image,
|
52 |
point_label_radio, text, reset_btn, sam_sgmt_everything_btn,
|
53 |
sam_decode_btn, depth_reconstruction_btn, masks_annotated_image, n_samples}
|
54 |
-
def on_depth_reconstruction_btn_click(inputs):
|
55 |
-
print("depth reconstruction")
|
56 |
-
image = inputs[input_image]
|
57 |
-
# depth reconstruction
|
58 |
-
#mask = inputs[masks][0][0]
|
59 |
-
path = dpt.generate_obj(image, inputs[n_samples])
|
60 |
-
|
61 |
-
return {pcl_figure: path}
|
62 |
-
|
63 |
-
depth_reconstruction_btn.click(on_depth_reconstruction_btn_click, components, [pcl_figure], queue=False)
|
64 |
|
65 |
# event - init coords
|
66 |
def on_reset_btn_click(raw_image):
|
@@ -73,7 +61,7 @@ with block:
|
|
73 |
sam.encode(input_image)
|
74 |
print("encoding done")
|
75 |
return input_image, point_coords_empty(), point_labels_empty(), None
|
76 |
-
input_image.
|
77 |
|
78 |
# event - set coords
|
79 |
def on_input_image_select(input_image, point_coords, point_labels, point_label_radio, evt: gr.SelectData):
|
@@ -87,7 +75,6 @@ with block:
|
|
87 |
return img, point_coords, point_labels
|
88 |
input_image.select(on_input_image_select, [input_image, point_coords, point_labels, point_label_radio], [input_image, point_coords, point_labels], queue=False)
|
89 |
|
90 |
-
|
91 |
def on_click_sam_dencode_btn(inputs):
|
92 |
print("inferencing")
|
93 |
image = inputs[raw_image]
|
@@ -96,6 +83,13 @@ with block:
|
|
96 |
return {masks_annotated_image: (image, inputs[masks])}
|
97 |
sam_decode_btn.click(on_click_sam_dencode_btn, components, [masks_annotated_image, masks, cutout_idx], queue=True)
|
98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
100 |
if __name__ == '__main__':
|
101 |
block.queue()
|
|
|
36 |
masks_annotated_image = gr.AnnotatedImage(label='Segments', height=512)
|
37 |
pcl_figure = gr.Model3D(label="3-D Reconstruction", clear_color=[1.0, 1.0, 1.0, 1.0])
|
38 |
n_samples = gr.Slider(minimum=1e3, maximum=1e6, step=1e3, default=1e3, label='Number of Samples')
|
|
|
|
|
39 |
with gr.Row():
|
40 |
with gr.Column(scale=1):
|
41 |
with gr.Row():
|
|
|
49 |
components = {point_coords, point_labels, raw_image, masks, cutout_idx, input_image,
|
50 |
point_label_radio, text, reset_btn, sam_sgmt_everything_btn,
|
51 |
sam_decode_btn, depth_reconstruction_btn, masks_annotated_image, n_samples}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
# event - init coords
|
54 |
def on_reset_btn_click(raw_image):
|
|
|
61 |
sam.encode(input_image)
|
62 |
print("encoding done")
|
63 |
return input_image, point_coords_empty(), point_labels_empty(), None
|
64 |
+
input_image.stream(on_input_image_upload, [input_image], [raw_image, point_coords, point_labels], queue=False)
|
65 |
|
66 |
# event - set coords
|
67 |
def on_input_image_select(input_image, point_coords, point_labels, point_label_radio, evt: gr.SelectData):
|
|
|
75 |
return img, point_coords, point_labels
|
76 |
input_image.select(on_input_image_select, [input_image, point_coords, point_labels, point_label_radio], [input_image, point_coords, point_labels], queue=False)
|
77 |
|
|
|
78 |
def on_click_sam_dencode_btn(inputs):
|
79 |
print("inferencing")
|
80 |
image = inputs[raw_image]
|
|
|
83 |
return {masks_annotated_image: (image, inputs[masks])}
|
84 |
sam_decode_btn.click(on_click_sam_dencode_btn, components, [masks_annotated_image, masks, cutout_idx], queue=True)
|
85 |
|
86 |
+
def on_depth_reconstruction_btn_click(inputs):
|
87 |
+
print("depth reconstruction")
|
88 |
+
image = inputs[raw_image]
|
89 |
+
path = dpt.generate_obj(image, inputs[n_samples])
|
90 |
+
return {pcl_figure: path}
|
91 |
+
depth_reconstruction_btn.click(on_depth_reconstruction_btn_click, components, [pcl_figure], queue=False)
|
92 |
+
|
93 |
|
94 |
if __name__ == '__main__':
|
95 |
block.queue()
|