MCPcopy Create free account
hub / github.com/ToTheBeginning/PuLID / _totensor

Function _totensor

pulid/utils.py:97–105  ·  view source on GitHub ↗
(img, bgr2rgb, float32)

Source from the content-addressed store, hash-verified

95 """
96
97 def _totensor(img, bgr2rgb, float32):
98 if img.shape[2] == 3 and bgr2rgb:
99 if img.dtype == 'float64':
100 img = img.astype('float32')
101 img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
102 img = torch.from_numpy(img.transpose(2, 0, 1))
103 if float32:
104 img = img.float()
105 return img
106
107 if isinstance(imgs, list):
108 return [_totensor(img, bgr2rgb, float32) for img in imgs]

Callers 1

img2tensorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected