MCPcopy Create free account
hub / github.com/InternRobotics/G2VLM / get_pose_rank_ids

Method get_pose_rank_ids

data/recon_dataset.py:377–419  ·  view source on GitHub ↗
(self, total_ids, extrinsics, expand_ratio=None, upper_bound=None)

Source from the content-addressed store, hash-verified

375 return result_ids
376
377 def get_pose_rank_ids(self, total_ids, extrinsics, expand_ratio=None, upper_bound=None):
378
379 num_views = len(extrinsics)
380 ranking, dists = compute_ranking(extrinsics, lambda_t=1.0, normalize=True, batched=True)
381 # reference_view = random.sample(range(num_views), 1)[0]
382 reference_view = np.random.randint(0, num_views)
383 refview_ranking = ranking[reference_view]
384
385 start_idx = 0
386
387 # Determine the actual expand_range
388 if upper_bound is None:
389 # Use ratio to determine range
390 expand_range = int(total_ids * expand_ratio * 2)
391 else:
392 expand_range = min(upper_bound, int(total_ids * expand_ratio * 2))
393 high_bound = min(num_views, start_idx + expand_range)
394
395 # Create the valid range of indices
396 valid_ranking_ids = np.arange(start_idx, high_bound)
397 valid_range = refview_ranking[valid_ranking_ids]
398
399 # Sample 'total_ids - 1' items, because we already have the start_idx
400 sampled_ids = np.random.choice(
401 valid_range,
402 size=(total_ids - 1),
403 replace=True, # we accept the situation that some sampled ids are the same
404 )
405
406 # start_randk_element = refview_ranking[start_idx]
407 # return np.insert(sampled_ids, 0, start_randk_element)
408
409 # # for nvs, farthest views must be at the start and end of the sequence
410 # sampled_rankings = [np.where(refview_ranking == id_val)[0][0] for id_val in sampled_ids]
411 # farthest_rank_idx = np.argmax(sampled_rankings) # Find the element with smallest ranking (highest rank)
412
413 # farthest_rank_element = sampled_ids[farthest_rank_idx]
414 # sampled_ids = np.delete(sampled_ids, farthest_rank_idx)
415 # sampled_ids = np.append(sampled_ids, farthest_rank_element)
416
417 start_randk_element = refview_ranking[start_idx]
418 result_ids = np.insert(sampled_ids, 0, start_randk_element)
419 return result_ids
420
421
422

Callers

nothing calls this directly

Calls 1

compute_rankingFunction · 0.70

Tested by

no test coverage detected