Spaces:
Running
on
Zero
Running
on
Zero
lemonaddie
commited on
Update app_recon.py
Browse files- app_recon.py +7 -7
app_recon.py
CHANGED
@@ -105,7 +105,6 @@ def sam_init():
|
|
105 |
|
106 |
sam_predictor = sam_init()
|
107 |
|
108 |
-
@spaces.GPU
|
109 |
def sam_segment(predictor, input_image, *bbox_coords):
|
110 |
bbox = np.array(bbox_coords)
|
111 |
image = np.asarray(input_image)
|
@@ -194,10 +193,12 @@ def seg_foreground(image_file):
|
|
194 |
return masked_image, mask
|
195 |
|
196 |
@spaces.GPU
|
197 |
-
def reconstruction(
|
198 |
|
199 |
torch.cuda.empty_cache()
|
200 |
|
|
|
|
|
201 |
mask = mask[:, :, 0] > 0.5
|
202 |
depth_np = np.load(files[0])
|
203 |
normal_np = np.load(files[1])
|
@@ -221,7 +222,7 @@ def reconstruction(mask, files):
|
|
221 |
|
222 |
torch.cuda.empty_cache()
|
223 |
|
224 |
-
return obj_path, [ply_path]
|
225 |
|
226 |
def run_demo():
|
227 |
|
@@ -340,10 +341,9 @@ def run_demo():
|
|
340 |
domain],
|
341 |
outputs=[depth, normal, files]
|
342 |
)
|
343 |
-
recon_btn.click(fn=
|
344 |
-
|
345 |
-
|
346 |
-
outputs=[reconstructed_3d, reconstructed_file]
|
347 |
)
|
348 |
demo.queue().launch(share=True, max_threads=80)
|
349 |
|
|
|
105 |
|
106 |
sam_predictor = sam_init()
|
107 |
|
|
|
108 |
def sam_segment(predictor, input_image, *bbox_coords):
|
109 |
bbox = np.array(bbox_coords)
|
110 |
image = np.asarray(input_image)
|
|
|
193 |
return masked_image, mask
|
194 |
|
195 |
@spaces.GPU
|
196 |
+
def reconstruction(image_file, files):
|
197 |
|
198 |
torch.cuda.empty_cache()
|
199 |
|
200 |
+
masked_image, mask = seg_foreground(image_file)
|
201 |
+
|
202 |
mask = mask[:, :, 0] > 0.5
|
203 |
depth_np = np.load(files[0])
|
204 |
normal_np = np.load(files[1])
|
|
|
222 |
|
223 |
torch.cuda.empty_cache()
|
224 |
|
225 |
+
return obj_path, [ply_path], masked_image
|
226 |
|
227 |
def run_demo():
|
228 |
|
|
|
341 |
domain],
|
342 |
outputs=[depth, normal, files]
|
343 |
)
|
344 |
+
recon_btn.click(fn=reconstruction,
|
345 |
+
inputs=[input_image, mask, files],
|
346 |
+
outputs=[reconstructed_3d, reconstructed_file, masked_image]
|
|
|
347 |
)
|
348 |
demo.queue().launch(share=True, max_threads=80)
|
349 |
|