changed data/loaders and engine/predictor so they accept 1 channel images for predictions

This commit is contained in:
Clea Parcerisas
2023-08-24 14:42:29 +02:00
parent 95e2c2424a
commit 82b97d5d4c
2 changed files with 3 additions and 2 deletions

View File

@ -122,7 +122,8 @@ class BasePredictor:
not_tensor = not isinstance(im, torch.Tensor)
if not_tensor:
im = np.stack(self.pre_transform(im))
im = im[..., ::-1].transpose((0, 3, 1, 2)) # BGR to RGB, BHWC to BCHW, (n, 3, h, w)
im = np.expand_dims(im, -1)
im = im[..., ::].transpose((0, 3, 1, 2)) # BGR to RGB, BHWC to BCHW, (n, 3, h, w)
im = np.ascontiguousarray(im) # contiguous
im = torch.from_numpy(im)