Spaces:
Running
on
Zero
Running
on
Zero
tokenid
commited on
Commit
·
146da98
1
Parent(s):
917fe92
fix plot stuck
Browse files- app.py +4 -4
- src/pose_estimation.py +15 -16
app.py
CHANGED
|
@@ -151,7 +151,7 @@ def run_pose_exploration_a(cam_vis, image1, image2):
|
|
| 151 |
matcher_ckpt_path=_matcher_ckpt_path_
|
| 152 |
)
|
| 153 |
|
| 154 |
-
fig =
|
| 155 |
|
| 156 |
return elevs, elev_ranges, fig
|
| 157 |
|
|
@@ -170,8 +170,8 @@ def run_pose_exploration_b(cam_vis, image1, image2, elevs, elev_ranges, probe_bs
|
|
| 170 |
result_poses, aux_data = estimate_poses(
|
| 171 |
_model_, images,
|
| 172 |
seed_cand_num=8,
|
| 173 |
-
|
| 174 |
-
|
| 175 |
probe_ts_range=[0.2, 0.21],
|
| 176 |
ts_range=[0.2, 0.21],
|
| 177 |
probe_bsz=probe_bsz,
|
|
@@ -392,4 +392,4 @@ def run_demo():
|
|
| 392 |
|
| 393 |
if __name__ == '__main__':
|
| 394 |
|
| 395 |
-
run_demo()
|
|
|
|
| 151 |
matcher_ckpt_path=_matcher_ckpt_path_
|
| 152 |
)
|
| 153 |
|
| 154 |
+
fig = None
|
| 155 |
|
| 156 |
return elevs, elev_ranges, fig
|
| 157 |
|
|
|
|
| 170 |
result_poses, aux_data = estimate_poses(
|
| 171 |
_model_, images,
|
| 172 |
seed_cand_num=8,
|
| 173 |
+
explore_type='triangular',
|
| 174 |
+
refine_type='triangular',
|
| 175 |
probe_ts_range=[0.2, 0.21],
|
| 176 |
ts_range=[0.2, 0.21],
|
| 177 |
probe_bsz=probe_bsz,
|
|
|
|
| 392 |
|
| 393 |
if __name__ == '__main__':
|
| 394 |
|
| 395 |
+
run_demo()
|
src/pose_estimation.py
CHANGED
|
@@ -97,8 +97,8 @@ def estimate_elevs(model, images, est_type=None, matcher_ckpt_path=None):
|
|
| 97 |
def estimate_poses(
|
| 98 |
model, images,
|
| 99 |
seed_cand_num=8,
|
| 100 |
-
|
| 101 |
-
|
| 102 |
probe_ts_range=[0.02, 0.98], ts_range=[0.02, 0.98],
|
| 103 |
probe_bsz=16,
|
| 104 |
adjust_factor=10.,
|
|
@@ -120,16 +120,15 @@ def estimate_poses(
|
|
| 120 |
elev_ranges = {i: None for i in range(num)}
|
| 121 |
|
| 122 |
if num <= 2:
|
| 123 |
-
|
| 124 |
|
| 125 |
cands = {}
|
| 126 |
losses = {}
|
| 127 |
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
print('Initialization: Probe', datetime.now())
|
| 132 |
|
|
|
|
| 133 |
|
| 134 |
images = [ img.permute(0, 2, 3, 1) for img in images ]
|
| 135 |
|
|
@@ -170,13 +169,13 @@ def estimate_poses(
|
|
| 170 |
print(cand)
|
| 171 |
|
| 172 |
cands[i] = [ cand[:2] for cand in adjusted_cands ]
|
| 173 |
-
losses[i] = [loss if (
|
| 174 |
|
| 175 |
-
|
| 176 |
|
| 177 |
print('Selection', datetime.now())
|
| 178 |
|
| 179 |
-
if
|
| 180 |
|
| 181 |
for i in range(1, num):
|
| 182 |
|
|
@@ -219,15 +218,15 @@ def estimate_poses(
|
|
| 219 |
print(cands[i][u], losses[i][u])
|
| 220 |
print(i, 'SELECT', min_rank, losses[i][min_rank])
|
| 221 |
|
| 222 |
-
|
| 223 |
|
| 224 |
print('Refinement', datetime.now())
|
| 225 |
|
| 226 |
combinations = None
|
| 227 |
-
if
|
| 228 |
combinations = [ (0, i) for i in range(1, num) ] + [ (i, 0) for i in range(1, num) ]
|
| 229 |
|
| 230 |
-
elif
|
| 231 |
combinations = []
|
| 232 |
for i in range(0, num):
|
| 233 |
for j in range(i+1, num):
|
|
@@ -242,7 +241,7 @@ def estimate_poses(
|
|
| 242 |
refine_factor,
|
| 243 |
bsz=refine_bsz,
|
| 244 |
n_iter=(num-1)*refine_iters,
|
| 245 |
-
init_poses=
|
| 246 |
ts_range=ts_range,
|
| 247 |
combinations=combinations,
|
| 248 |
avg_last_n=20,
|
|
@@ -252,8 +251,8 @@ def estimate_poses(
|
|
| 252 |
print('Done', datetime.now())
|
| 253 |
|
| 254 |
aux_data = {
|
| 255 |
-
'
|
| 256 |
-
'
|
| 257 |
'elev': elevs
|
| 258 |
}
|
| 259 |
|
|
|
|
| 97 |
def estimate_poses(
|
| 98 |
model, images,
|
| 99 |
seed_cand_num=8,
|
| 100 |
+
explore_type='pairwise',
|
| 101 |
+
refine_type='pairwise',
|
| 102 |
probe_ts_range=[0.02, 0.98], ts_range=[0.02, 0.98],
|
| 103 |
probe_bsz=16,
|
| 104 |
adjust_factor=10.,
|
|
|
|
| 120 |
elev_ranges = {i: None for i in range(num)}
|
| 121 |
|
| 122 |
if num <= 2:
|
| 123 |
+
explore_type = 'pairwise'
|
| 124 |
|
| 125 |
cands = {}
|
| 126 |
losses = {}
|
| 127 |
|
| 128 |
+
ep_poses = {i: None for i in range(num)}
|
| 129 |
+
pairwise_ep_poses = {i: None for i in range(num)}
|
|
|
|
|
|
|
| 130 |
|
| 131 |
+
print('Start', datetime.now())
|
| 132 |
|
| 133 |
images = [ img.permute(0, 2, 3, 1) for img in images ]
|
| 134 |
|
|
|
|
| 169 |
print(cand)
|
| 170 |
|
| 171 |
cands[i] = [ cand[:2] for cand in adjusted_cands ]
|
| 172 |
+
losses[i] = [loss if (explore_type == 'pairwise') else 0.0 for loss, _ in cands[i]]
|
| 173 |
|
| 174 |
+
pairwise_ep_poses[i] = min(cands[i])[1]
|
| 175 |
|
| 176 |
print('Selection', datetime.now())
|
| 177 |
|
| 178 |
+
if explore_type == 'triangular':
|
| 179 |
|
| 180 |
for i in range(1, num):
|
| 181 |
|
|
|
|
| 218 |
print(cands[i][u], losses[i][u])
|
| 219 |
print(i, 'SELECT', min_rank, losses[i][min_rank])
|
| 220 |
|
| 221 |
+
ep_poses[i] = cands[i][min_rank][1]
|
| 222 |
|
| 223 |
print('Refinement', datetime.now())
|
| 224 |
|
| 225 |
combinations = None
|
| 226 |
+
if refine_type == 'pairwise':
|
| 227 |
combinations = [ (0, i) for i in range(1, num) ] + [ (i, 0) for i in range(1, num) ]
|
| 228 |
|
| 229 |
+
elif refine_type == 'triangular':
|
| 230 |
combinations = []
|
| 231 |
for i in range(0, num):
|
| 232 |
for j in range(i+1, num):
|
|
|
|
| 241 |
refine_factor,
|
| 242 |
bsz=refine_bsz,
|
| 243 |
n_iter=(num-1)*refine_iters,
|
| 244 |
+
init_poses=ep_poses,
|
| 245 |
ts_range=ts_range,
|
| 246 |
combinations=combinations,
|
| 247 |
avg_last_n=20,
|
|
|
|
| 251 |
print('Done', datetime.now())
|
| 252 |
|
| 253 |
aux_data = {
|
| 254 |
+
'tri_ep_sph': ep_poses,
|
| 255 |
+
'pw_ep_sph': pairwise_ep_poses,
|
| 256 |
'elev': elevs
|
| 257 |
}
|
| 258 |
|