MCPcopy Create free account
hub / github.com/BadCafeCode/masquerade-nodes-comfyui / tensor2batch

Function tensor2batch

MaskNodes.py:72–83  ·  view source on GitHub ↗
(t: torch.Tensor, bs: torch.Size)

Source from the content-addressed store, hash-verified

70 return t
71
72def tensor2batch(t: torch.Tensor, bs: torch.Size) -> torch.Tensor:
73 if len(t.size()) < len(bs):
74 t = t.unsqueeze(3)
75 if t.size()[0] < bs[0]:
76 t.repeat(bs[0], 1, 1, 1)
77 dim = bs[3]
78 if dim == 1:
79 return tensor2mask(t)
80 elif dim == 3:
81 return tensor2rgb(t)
82 elif dim == 4:
83 return tensor2rgba(t)
84
85def tensors2common(t1: torch.Tensor, t2: torch.Tensor) -> (torch.Tensor, torch.Tensor):
86 t1s = t1.size()

Callers 3

tensors2commonFunction · 0.85
mixMethod · 0.85
mixMethod · 0.85

Calls 3

tensor2maskFunction · 0.85
tensor2rgbFunction · 0.85
tensor2rgbaFunction · 0.85

Tested by

no test coverage detected