lucasb-eyer / pydensecrf

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

Questions on the library #118

Open QuanticDisaster opened 2 years ago

QuanticDisaster commented 2 years ago

Hello @lucasb-eyer

I would like to thank you for this quite complete and easy to use implementation of the original paper

I am posting this issue to ask some questions about this library. Has there been advances on the learning part of the library ? I was interested in it and eventually adapting if I manage to get past the cython code which I'm not familiar with

At the moment, I am toying a bit with the library, my goal being to apply it on 3D points clouds. I managed to use the generic non 2D case for it, which also raised some interrogations on my part.

First, I see this is not possible to add a standard deviation parameter to a DenseCRF object when adding pairwiseenergy. However, from the formula formula

it seems that we can circumvent this by dividing directly the features before setting a pairwise energy this way, is that right ?

d = dcrf.DenseCRF(100, 5)  # npoints, nlabels

std = 8
feats = np.array(...)  # Get the pairwise features from somewhere.
print(feats.shape)     # -> (7, 100) = (feature dimensionality, npoints)
print(feats.dtype)     # -> dtype('float32')

dcrf.addPairwiseEnergy(feats / 8)

Moreover, it seems you don't apply the 2* factor on the pairwise energy in the 2D case. while it is just a constant factor, is it intended ? I don't see traces of any power being applied either. Here is the corresponding code in DenseCRF2D::addPairwiseGaussian:

https://github.com/lucasb-eyer/pydensecrf/blob/0d53acbcf5123d4c88040fe68fbb9805fc5b2fb9/pydensecrf/densecrf/src/densecrf.cpp

With respect to the compatibility parameter, I noted that using a constant as a value for compat and an identity matrix with the same constant gives different results. Could you confirm that a PottsCompatibility and a identity MatrixCompatibility should bring the same results ? The problem seem to come from a sign, one consider the entry should be negative, the other one positive. Putting a compatibility value such as PottsCompatibility = - MatrixCompatibility indeed gives the same result

I would be glad to exchange with you more in depth if you are still active on the library. Thanks