(self, img_arr: np.ndarray, amask_arr: np.ndarray)
| 9 | self.std = torch.tensor([0.229, 0.224, 0.225]).view((1, 3, 1, 1)).cuda() |
| 10 | |
| 11 | def process(self, img_arr: np.ndarray, amask_arr: np.ndarray): |
| 12 | # Deal with the image patch |
| 13 | img_tensor = torch.tensor(img_arr).cuda().float().permute((2,0,1)).unsqueeze(dim=0) |
| 14 | img_tensor_norm = ((img_tensor / 255.0) - self.mean) / self.std # (1,3,H,W) |
| 15 | # Deal with the attention mask |
| 16 | amask_tensor = torch.from_numpy(amask_arr).to(torch.bool).cuda().unsqueeze(dim=0) # (1,H,W) |
| 17 | return NestedTensor(img_tensor_norm, amask_tensor) |
| 18 | |
| 19 | |
| 20 | class PreprocessorX(object): |
no test coverage detected