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

ValueError: Buffer dtype mismatch, expected 'float' but got 'double' #52

Closed
rw1993 opened this issue Dec 21, 2017 · 2 comments
Closed

Comments

@rw1993
Copy link

rw1993 commented Dec 21, 2017

Try below code and get ValueError.

import numpy as np
import pydensecrf.densecrf as dcrf
d = dcrf.DenseCRF(80, 2)
U = np.random.random(size=(2, 80))
d.setUnaryEnergy(U)
Traceback (most recent call last):
File "", line 1, in
d.setUnaryEnergy(U)
File "pydensecrf/densecrf.pyx", line 80, in pydensecrf.densecrf.DenseCRF.setUn
aryEnergy (pydensecrf/densecrf.cpp:3370)
ValueError: Buffer dtype mismatch, expected 'float' but got 'double'

@Nandayang
Copy link

@rw1993 Hi, i m facing the same problem. Do you solve this ?

@lucasb-eyer
Copy link
Owner

People had this error before (#49) and it's a user error. I think the error is pretty clear: you should pass a float, but you're passing a double. Fix by doing U = U.astype(np.float32). I'll add a note to the FAQ in the README.

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