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

Bad shape for unary energy (Need (2, 1053979828), got (39677, 26564)) #100

Open
pratik-segmind opened this issue Nov 26, 2019 · 2 comments

Comments

@pratik-segmind
Copy link

pratik-segmind commented Nov 26, 2019

My Code:

def mask_smoothen(img, mask, nclasses):

	mask = mask.astype(np.float32) #mask.astype(np.uint8)
	image = img
	height, width, channels = image.shape

	d = dcrf.DenseCRF2D(height, width, nclasses)

	labels = mask.T
	
	U = unary_from_softmax(labels)
	U = np.ascontiguousarray(U)	
	print(U.dtype, U.shape)

	d.setUnaryEnergy(U)

	d.addPairwiseBilateral(sxy=80, srgb=13, rgbim=image, compat=10)

	Q = d.inference(5)

	fine_mask = np.argmax(Q, axis=0).reshape(height, width)

	return fine_mask

I get the error "Bad shape for unary energy (Need (2, 1053979828), got (39677, 26564))"

My image and masks are large: 39677 x 26564

Can some one help me understand what is happening here.

@andres-fr
Copy link

The readme says that you need to flatten it to the shape (NUM_CLASSES, H*W). Hope that helps!

@huixiancheng
Copy link

resize you pic maybe

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

3 participants