lucasb-eyer / pydensecrf

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

Set Weights for the Pairwise Potential Kernel #8

Closed KlaymenGC closed 8 years ago

KlaymenGC commented 8 years ago

Hello,

Thanks for this awesome wrapper! I'm quite new here, is there a way to set the weights for the pairwise potential kernel as mentioned in the paper?

lucasb-eyer commented 8 years ago

I'm not sure as I've never (knowingly) done this myself. Could you tell me how you'd do this in the original C++ code? It should be similar here.

KlaymenGC commented 8 years ago

@lucasb-eyer sorry I haven't looked into the C++ code yet... have just read the paper. There does have a Matlab wrapper which can set weights for the kernels: https://github.com/johannesu/meanfield-matlab/blob/master/Densecrf.m

lucasb-eyer commented 8 years ago

Thanks for the link. We can see that the weight ends up as PottsCompatibility instance in the C++ code. We do wrap this, you can see the code creating the object and as you may note, you can pass it either a number for PottsCompatibility, or a vector or a matrix for other compatibilities. This is being called from addPairwiseEnergy here, so you can see that it is the third parameter.

To sum it up and answer your question: simply pass the weight as a number as the compat parameter to any of the addPairwise{Energy,Gaussian,Bilateral} functions.

Edit: if this works for you, please let me know and close the issue.

KlaymenGC commented 8 years ago

@lucasb-eyer yep, I just noticed that in their code as well :) Thanks for your help!

lucasb-eyer commented 7 years ago

Hi @KlaymenGC. It seems we were wrong here and the compatibility stuff is about label-compatibilities (duh) and not the weights of the kernels, which is what I think you originally asked about. I have since clarified this in the README in this commit.