MCPcopy
hub / github.com/vladmandic/sdnext / cat

Method cat

modules/control/proc/segment_anything/utils/amg.py:59–70  ·  view source on GitHub ↗
(self, new_stats: "MaskData")

Source from the content-addressed store, hash-verified

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

Callers 15

_generate_masksMethod · 0.95
_process_cropMethod · 0.95
resize_hiresFunction · 0.80
__call__Method · 0.80
pad_to_same_lengthFunction · 0.80
prompt_callbackFunction · 0.80

Calls 1

itemsMethod · 0.80

Tested by

no test coverage detected