MCPcopy Index your code
hub / github.com/thygate/stable-diffusion-webui-depthmap-script / PrepareForNet

Class PrepareForNet

dmidas/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 4

load_modelFunction · 0.90
estimatemidasFunction · 0.90
estimatedepthanythingFunction · 0.90
estimatemidasBoostFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected