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

single_channel
Clea Parcerisas 1 year ago
parent 95e2c2424a
commit 82b97d5d4c

@ -249,7 +249,7 @@ class LoadImages:
else: else:
# Read image # Read image
self.count += 1 self.count += 1
im0 = cv2.imread(path) # BGR im0 = cv2.imread(path, cv2.IMREAD_GRAYSCALE) # BGR
if im0 is None: if im0 is None:
raise FileNotFoundError(f'Image Not Found {path}') raise FileNotFoundError(f'Image Not Found {path}')
s = f'image {self.count}/{self.nf} {path}: ' s = f'image {self.count}/{self.nf} {path}: '

@ -122,7 +122,8 @@ class BasePredictor:
not_tensor = not isinstance(im, torch.Tensor) not_tensor = not isinstance(im, torch.Tensor)
if not_tensor: if not_tensor:
im = np.stack(self.pre_transform(im)) 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 = np.ascontiguousarray(im) # contiguous
im = torch.from_numpy(im) im = torch.from_numpy(im)

Loading…
Cancel
Save