lucasb-eyer / pydensecrf

Python wrapper to Philipp Krähenbühl's dense (fully connected) CRFs with gaussian edge potentials.
MIT License
1.94k stars 413 forks source link

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

Closed rw1993 closed 6 years ago

rw1993 commented 6 years ago

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 commented 6 years ago

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

lucasb-eyer commented 6 years ago

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.