MCPcopy Create free account
hub / github.com/apple/ml-4m / get_query_points

Method get_query_points

fourm/data/modality_transforms.py:1239–1253  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1237 self.point_order = point_order
1238
1239 def get_query_points(self):
1240 if self.point_order == 'grid':
1241 # Create and cache grid query points
1242 if not hasattr(self, 'grid_query_points'):
1243 y, x = np.meshgrid(np.linspace(0, self.H, self.points_per_h + 2)[1:-1], np.linspace(0, self.W, self.points_per_w + 2)[1:-1])
1244 grid = np.stack((x, y), axis=2).astype(np.int32)
1245 self.grid_query_points = grid.reshape(-1, 2)
1246 return self.grid_query_points
1247 elif self.point_order == 'random':
1248 # Randomly sample query points
1249 y = np.random.randint(0, self.H, self.points_per_h)
1250 x = np.random.randint(0, self.W, self.points_per_w)
1251 return np.concatenate((x[:,None], y[:,None]), axis=1)
1252 else:
1253 raise ValueError(f"Query point order mode {self.point_order} is not supported.")
1254
1255 def get_target_tokens(self, sample, query_points):
1256 instances_coords = [coords[0] for coords in sample['points']]

Callers 1

postprocessMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected