could not broadcast input array from shape (400,500,3) into shape (400,500)
tz11 opened this issue · 0 comments
I want to segment an RGB image with two classes.And I have resized the image shape as (400,500,3). Here is my code
demo:
data_provider = ImageDataProvider("X:/XX/*.tif")
net = unet.Unet(channels=3, n_class=2, layers=3, features_root=16)
BaseDataProvider:
channels = 3
n_class = 2
def _process_labels(self, label):
if self.n_class == 2:
nx = label.shape[1]
ny = label.shape[0]
labels = np.zeros((ny, nx, self.n_class), dtype=np.float32)
labels[..., 1] = label
labels[..., 0] = ~label
return labels
return label
ImageDataProvider:
def init(...):
self.channels = 1 if len(img.shape) == 2 else img.shape[-1]
self.n_class = 2
Error:
labels[..., 1] = label
ValueError: could not broadcast input array from shape (400,500,3) into shape (400,500)
THANKS!