aca2024 commited on
Commit
e28f1ec
·
1 Parent(s): d63efaf
Files changed (1) hide show
  1. app.py +23 -20
app.py CHANGED
@@ -197,27 +197,30 @@ def reconstruct(video_path, conf_thresh, kf_every,
197
  fps = len(batch) / (end - start)
198
  print(f'Finished reconstruction for {demo_name}, FPS: {fps:.2f}')
199
 
200
- # Process results
201
- pcds = []
202
- for j, view in enumerate(batch):
203
- image = view['img'].permute(0, 2, 3, 1).cpu().numpy()[0]
204
- image = (image + 1) / 2
205
- pts = preds[j]['pts3d' if j==0 else 'pts3d_in_other_view'].detach().cpu().numpy()[0]
206
- pts_normal = pts2normal(preds[j]['pts3d' if j==0 else 'pts3d_in_other_view'][0]).cpu().numpy()
207
- conf = preds[j]['conf'][0].cpu().data.numpy()
208
- conf_sig = (conf - 1) / conf
209
- if remove_background:
210
- mask = generate_mask(image)
211
- else:
212
- mask = np.ones_like(conf)
 
 
 
213
 
214
- combined_mask = (conf_sig > conf_thresh) & (mask > 0.5)
215
-
216
- pcd = o3d.geometry.PointCloud()
217
- pcd.points = o3d.utility.Vector3dVector(pts[combined_mask])
218
- pcd.colors = o3d.utility.Vector3dVector(image[combined_mask])
219
- pcd.normals = o3d.utility.Vector3dVector(pts_normal[combined_mask])
220
- pcds.append(pcd)
221
 
222
  print(f'Finished Process results {demo_name}')
223
 
 
197
  fps = len(batch) / (end - start)
198
  print(f'Finished reconstruction for {demo_name}, FPS: {fps:.2f}')
199
 
200
+ try:
201
+ # Process results
202
+ pcds = []
203
+ for j, view in enumerate(batch):
204
+ image = view['img'].permute(0, 2, 3, 1).cpu().numpy()[0]
205
+ image = (image + 1) / 2
206
+ pts = preds[j]['pts3d' if j==0 else 'pts3d_in_other_view'].detach().cpu().numpy()[0]
207
+ pts_normal = pts2normal(preds[j]['pts3d' if j==0 else 'pts3d_in_other_view'][0]).cpu().numpy()
208
+ conf = preds[j]['conf'][0].cpu().data.numpy()
209
+ conf_sig = (conf - 1) / conf
210
+ if remove_background:
211
+ mask = generate_mask(image)
212
+ else:
213
+ mask = np.ones_like(conf)
214
+
215
+ combined_mask = (conf_sig > conf_thresh) & (mask > 0.5)
216
 
217
+ pcd = o3d.geometry.PointCloud()
218
+ pcd.points = o3d.utility.Vector3dVector(pts[combined_mask])
219
+ pcd.colors = o3d.utility.Vector3dVector(image[combined_mask])
220
+ pcd.normals = o3d.utility.Vector3dVector(pts_normal[combined_mask])
221
+ pcds.append(pcd)
222
+ except Exception as e:
223
+ print(repr(e))
224
 
225
  print(f'Finished Process results {demo_name}')
226