lch01 commited on
Commit
0c61197
·
1 Parent(s): dad59d0

fix output of inference

Browse files
Files changed (1) hide show
  1. app.py +26 -2
app.py CHANGED
@@ -85,11 +85,35 @@ def run_model(target_dir, model) -> dict:
85
 
86
  with torch.no_grad():
87
  with torch.cuda.amp.autocast(dtype=dtype):
88
- predictions = model.inference(frames)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
 
90
  # Convert pose encoding to extrinsic and intrinsic matrices
91
  print("Converting pose encoding to extrinsic and intrinsic matrices...")
92
- extrinsic, intrinsic = pose_encoding_to_extri_intri(predictions["pose_enc"], images.shape[-2:])
93
  predictions["extrinsic"] = extrinsic
94
  predictions["intrinsic"] = intrinsic
95
 
 
85
 
86
  with torch.no_grad():
87
  with torch.cuda.amp.autocast(dtype=dtype):
88
+ output = model.inference(frames)
89
+
90
+ predictions = {}
91
+
92
+ all_pts3d = []
93
+ all_conf = []
94
+ all_depth = []
95
+ all_depth_conf = []
96
+ all_camera_pose = []
97
+
98
+ for res in output.ress:
99
+ all_pts3d.append(res['pts3d_in_other_view'])
100
+ all_conf.append(res['conf'])
101
+ all_depth.append(res['depth'])
102
+ all_depth_conf.append(res['depth_conf'])
103
+ all_camera_pose.append(res['camera_pose'])
104
+
105
+ predictions["world_points"] = torch.stack(all_pts3d, dim=0) # (S, H, W, 3)
106
+ predictions["world_points_conf"] = torch.stack(all_conf, dim=0) # (S, H, W)
107
+ predictions["depth"] = torch.stack(all_depth, dim=0) # (S, H, W, 1)
108
+ predictions["depth_conf"] = torch.stack(all_depth_conf, dim=0) # (S, H, W)
109
+ predictions["pose_enc"] = torch.stack(all_camera_pose, dim=0) # (S, 9)
110
+
111
+ predictions["images"] = images.unsqueeze(0) # (1, S, 3, H, W)
112
+
113
 
114
  # Convert pose encoding to extrinsic and intrinsic matrices
115
  print("Converting pose encoding to extrinsic and intrinsic matrices...")
116
+ extrinsic, intrinsic = pose_encoding_to_extri_intri(predictions["camera_pose"], images.shape[-2:])
117
  predictions["extrinsic"] = extrinsic
118
  predictions["intrinsic"] = intrinsic
119