MCPcopy Create free account
hub / github.com/Picsart-AI-Research/Text2Video-Zero / PrepareForNet

Class PrepareForNet

annotator/midas/midas/transforms.py:211–234  ·  view source on GitHub ↗

Prepare sample for usage as network input.

Source from the content-addressed store, hash-verified

209
210
211class PrepareForNet(object):
212 """Prepare sample for usage as network input.
213 """
214
215 def __init__(self):
216 pass
217
218 def __call__(self, sample):
219 image = np.transpose(sample["image"], (2, 0, 1))
220 sample["image"] = np.ascontiguousarray(image).astype(np.float32)
221
222 if "mask" in sample:
223 sample["mask"] = sample["mask"].astype(np.float32)
224 sample["mask"] = np.ascontiguousarray(sample["mask"])
225
226 if "disparity" in sample:
227 disparity = sample["disparity"].astype(np.float32)
228 sample["disparity"] = np.ascontiguousarray(disparity)
229
230 if "depth" in sample:
231 depth = sample["depth"].astype(np.float32)
232 sample["depth"] = np.ascontiguousarray(depth)
233
234 return sample

Callers 2

load_midas_transformFunction · 0.85
load_modelFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected