Requiring the `reshape` on the unary is an API wart that I'd like to fix, but
Requiring the `reshape` on the unary is an API wart that I'd like to fix, but
don't know how to without introducing an explicit dependency on numpy.
don't know how to without introducing an explicit dependency on numpy.
**Note** that the `nlabels` dimension is the first here before the reshape;
you may need to move it there before reshaping if that's not already the case,
like so:
```python
print(U.shape)# -> (480, 640, 5)
U=U.transpose(2,0,1).reshape((5,-1))
```
### Getting a Unary
### Getting a Unary
There's two common ways of getting unary potentials:
There's two common ways of getting unary potentials:
...
@@ -251,6 +260,15 @@ This is a pretty [co](https://github.com/lucasb-eyer/pydensecrf/issues/52)mm[on]
...
@@ -251,6 +260,15 @@ This is a pretty [co](https://github.com/lucasb-eyer/pydensecrf/issues/52)mm[on]
It means exactly what it says: you are passing a `double` but it wants a `float`.
It means exactly what it says: you are passing a `double` but it wants a `float`.
Solve it by, for example, calling `d.setUnaryEnergy(U.astype(np.float32))` instead of just `d.setUnaryEnergy(U)`, or using `float32` in your code in the first place.
Solve it by, for example, calling `d.setUnaryEnergy(U.astype(np.float32))` instead of just `d.setUnaryEnergy(U)`, or using `float32` in your code in the first place.
My results are all pixelated like [MS Paint's airbrush tool](http://lmgtfy.com/?q=MS+Paint+Airbrush+tool)!