| 4 | |
| 5 | |
| 6 | class AddMiDaS(object): |
| 7 | def __init__(self, model_type): |
| 8 | super().__init__() |
| 9 | self.transform = load_midas_transform(model_type) |
| 10 | |
| 11 | def pt2np(self, x): |
| 12 | x = ((x + 1.0) * .5).detach().cpu().numpy() |
| 13 | return x |
| 14 | |
| 15 | def np2pt(self, x): |
| 16 | x = torch.from_numpy(x) * 2 - 1. |
| 17 | return x |
| 18 | |
| 19 | def __call__(self, sample): |
| 20 | # sample['jpg'] is tensor hwc in [-1, 1] at this point |
| 21 | x = self.pt2np(sample['jpg']) |
| 22 | x = self.transform({"image": x})["image"] |
| 23 | sample['midas_in'] = x |
| 24 | return sample |
nothing calls this directly
no outgoing calls
no test coverage detected