Prepare sample for usage as network input.
| 209 | |
| 210 | |
| 211 | class 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 |
no outgoing calls
no test coverage detected