MCPcopy
hub / github.com/yangchris11/samurai / cat

Method cat

sam2/sam2/utils/amg.py:61–72  ·  view source on GitHub ↗
(self, new_stats: "MaskData")

Source from the content-addressed store, hash-verified

59 raise TypeError(f"MaskData key {k} has an unsupported type {type(v)}.")
60
61 def cat(self, new_stats: "MaskData") -> None:
62 for k, v in new_stats.items():
63 if k not in self._stats or self._stats[k] is None:
64 self._stats[k] = deepcopy(v)
65 elif isinstance(v, torch.Tensor):
66 self._stats[k] = torch.cat([self._stats[k], v], dim=0)
67 elif isinstance(v, np.ndarray):
68 self._stats[k] = np.concatenate([self._stats[k], v], axis=0)
69 elif isinstance(v, list):
70 self._stats[k] = self._stats[k] + deepcopy(v)
71 else:
72 raise TypeError(f"MaskData key {k} has an unsupported type {type(v)}.")
73
74 def to_numpy(self) -> None:
75 for k, v in self._stats.items():

Callers 15

_generate_masksMethod · 0.95
_process_cropMethod · 0.95
refine_with_m2mMethod · 0.80
_predictMethod · 0.80
add_new_points_or_boxMethod · 0.80
get_1d_sine_peFunction · 0.80
encode_boxesMethod · 0.80
encode_pointsMethod · 0.80
forwardMethod · 0.80
_pe_encodingMethod · 0.80

Calls 1

itemsMethod · 0.80

Tested by

no test coverage detected