Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

could not broadcast input array from shape (400,500,3) into shape (400,500) #262

Open
tz11 opened this issue Apr 7, 2019 · 0 comments
Open

Comments

@tz11
Copy link

tz11 commented Apr 7, 2019

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant