MCPcopy Create free account
hub / github.com/AgentMaker/PaddleQuickInference / PrepareForNet

Class PrepareForNet

examples/MiDaS/transforms.py:162–184  ·  view source on GitHub ↗

Prepare sample for usage as network input.

Source from the content-addressed store, hash-verified

160
161
162class PrepareForNet(object):
163 """Prepare sample for usage as network input.
164 """
165 def __init__(self):
166 pass
167
168 def __call__(self, sample):
169 image = np.transpose(sample["image"], (2, 0, 1))
170 sample["image"] = np.ascontiguousarray(image).astype(np.float32)
171
172 if "mask" in sample:
173 sample["mask"] = sample["mask"].astype(np.float32)
174 sample["mask"] = np.ascontiguousarray(sample["mask"])
175
176 if "disparity" in sample:
177 disparity = sample["disparity"].astype(np.float32)
178 sample["disparity"] = np.ascontiguousarray(disparity)
179
180 if "depth" in sample:
181 depth = sample["depth"].astype(np.float32)
182 sample["depth"] = np.ascontiguousarray(depth)
183
184 return sample

Callers 1

preprocessFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected