MCPcopy Index your code
hub / github.com/apple/ml-pointersect / sample_random_patches

Method sample_random_patches

pointersect/inference/structures.py:2344–2447  ·  view source on GitHub ↗

Generate rays to form patches on the corresponding images. Args: num_patches_per_q: number of patches from each q patch_width_px: number of pixels in the patch in width patch_width_pitch_scale: (*b,

(
            self,
            num_patches_per_q: int,
            patch_width_px: int,
            patch_width_pitch_scale: T.Union[float, torch.Tensor] = 1.,  # (*b,)
            patch_height_px: int = None,  # (*b,)
            patch_height_pitch_scale: T.Union[float, torch.Tensor] = None,  # (*b,)
            int_only: bool = True,
            mode: str = 'bilinear',
            padding_mode: str = 'zeros',
            required_attributes: T.List[str] = None,
    )

Source from the content-addressed store, hash-verified

2342 return point_cloud
2343
2344 def sample_random_patches(
2345 self,
2346 num_patches_per_q: int,
2347 patch_width_px: int,
2348 patch_width_pitch_scale: T.Union[float, torch.Tensor] = 1., # (*b,)
2349 patch_height_px: int = None, # (*b,)
2350 patch_height_pitch_scale: T.Union[float, torch.Tensor] = None, # (*b,)
2351 int_only: bool = True,
2352 mode: str = 'bilinear',
2353 padding_mode: str = 'zeros',
2354 required_attributes: T.List[str] = None,
2355 ) -> T.Dict[str, T.Any]:
2356 """
2357 Generate rays to form patches on the corresponding images.
2358
2359 Args:
2360 num_patches_per_q:
2361 number of patches from each q
2362 patch_width_px:
2363 number of pixels in the patch in width
2364 patch_width_pitch_scale:
2365 (*b,) the pitch of the patch (new_pitch / old_pitch)
2366 patch_height_px:
2367 if None, the same as `patch_width_px`
2368 patch_height_pitch_scale:
2369 if None, the same as `patch_width_pitch_scale`
2370 int_only:
2371 whether the center is always at an integer index
2372 mode:
2373 mode used by grid_sample
2374 padding_mode:
2375 padding mode used by grid_sample. "zeros", "border", "reflection"
2376 required_attributes:
2377 list of str containing the field wanted. If None: all possible fields
2378
2379 Returns:
2380 ray:
2381 (b, q, num_patches_per_q, hp, wp)
2382 uv:
2383 (b, q, num_patches_per_q, hp, wp, 2) [0, w], [0, h]
2384 rgb:
2385 (b, q, num_patches_per_q, hp, wp, 3)
2386 depth:
2387 (b, q, num_patches_per_q, hp, wp) or None, same coord as the original depth
2388 normal_w:
2389 (b, q, num_patches_per_q, hp, wp, 3) or None, same coord as the original surface normal
2390 hit_map:
2391 (b, q, num_patches_per_q, hp, wp) or None, float, [0, 1], 0: not valid, 1: valid
2392 feature:
2393 (b, q, num_patches_per_q, hp, wp, f) or None
2394
2395 Note:
2396 part of the patches may go out of bound. The padding_mode determines the behavior
2397 """
2398 b, q, h, w, _3 = self.rgb.shape
2399
2400 # sample random patch and get uv and rays
2401 ray_uv_dict = self.camera.generate_random_patch_rays(

Callers

nothing calls this directly

Calls 3

sizeMethod · 0.80
reshapeMethod · 0.45

Tested by

no test coverage detected