MultiViewGenerator#
- class MultiViewGenerator(global_view_num=2, global_view_scale=(0.4, 1.0), local_view_num=4, local_view_scale=(0.1, 0.4), global_shared_transform=None, global_transform=None, local_transform=None, max_size=65536, center_height_scale=(0, 1), shared_global_view=False, center_sampling='random', center_sampling_kwargs=None, view_keys=('coord', 'origin_coord', 'color', 'normal'), anchor_bias_ratio=0.6, anchor_radius_scale=1.5, anchor_keys=('endpoints', 'branches_track', 'branches_shower', 'bragg'))[source]#
Bases:
objectGenerate multiple global and local crops for DINO/iBOT-style SSL.
Crops a major global view around a randomly chosen center (restricted in height by
center_height_scale), then additional global views and several local views, each a nearest-kneighborhood whose size is a random fraction of the cloud (perglobal_view_scale/local_view_scale). Local centers are pushed to cover the major view and, whendata_dict["anchors"]is available, a fraction (anchor_bias_ratio) of local crops are centered on anchors. Readsdata_dict["coord"]and the keys inview_keys(and optionalanchors); writes concatenatedglobal_<key>/local_<key>arrays withglobal_offset/local_offsetboundaries. Registered asMultiViewGenerator— use this string as thetypein atransform=[...]config list.- Parameters:
global_view_num (int) – Number of global views (including the major one). Defaults to
2.global_view_scale (tuple) –
(min, max)fraction of points per global crop. Defaults to(0.4, 1.0).local_view_num (int) – Number of local views. Defaults to
4.local_view_scale (tuple) –
(min, max)fraction of points per local crop. Defaults to(0.1, 0.4).global_shared_transform (list, optional) – Transform config applied once to the whole sample before any cropping. Defaults to
None.global_transform (list, optional) – Transform config applied to each global view. Defaults to
None.local_transform (list, optional) – Transform config applied to each local view. Defaults to
None.max_size (int) – Upper bound on the points considered per view. Defaults to
65536.center_height_scale (tuple) –
(min, max)fractional z-band restricting where the major-view center is sampled. Defaults to(0, 1).shared_global_view (bool) – If
True, the extra global views are copies of the major view rather than freshly cropped. Defaults toFalse.center_sampling (str) – Center-selection strategy,
"random"or"cnms"(coverage non-max suppression). Defaults to"random".center_sampling_kwargs (dict, optional) – Extra kwargs for
cnmswhencenter_sampling="cnms". Defaults toNone.view_keys (tuple) – Keys cropped into each view; must include
"coord". Defaults to("coord", "origin_coord", "color", "normal").anchor_bias_ratio (float) – Fraction of local views centered on anchors (when anchors are present). Defaults to
0.6.anchor_radius_scale (float) – Radius scale for anchor-centered local crops (size scales roughly cubically with it). Defaults to
1.5.anchor_keys (tuple) – Anchor sub-keys pooled as candidate centers;
ledis always excluded. Defaults to("endpoints", "branches_track", "branches_shower", "bragg").
Example
>>> import numpy as np >>> np.random.seed(0) >>> data = {"coord": np.random.rand(200, 3).astype("f4"), ... "color": np.random.rand(200, 3).astype("f4"), ... "index_valid_keys": ["coord", "color"]} >>> out = MultiViewGenerator(global_view_num=2, local_view_num=4, ... view_keys=("coord", "color"))(data) >>> out["global_coord"].shape, out["global_offset"] # 2 global crops concatenated ((356, 3), array([170, 356])) >>> out["local_coord"].shape, out["local_offset"] # 4 local crops concatenated ((223, 3), array([ 66, 134, 155, 223])) # exact sizes vary with the RNG; offsets mark per-view boundaries