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

Questions on CRF model edge #25

Closed chen1474147 closed 7 years ago

chen1474147 commented 7 years ago

Hi, thank you very much for code. But I have some questions when I use this code.

My task is to cluster some points, not image. Here some points are connected but some are not. Say, I have 100 points. So I build a crf model by code below(in your demo).

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

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)

My question is, here how could I set the point connectivity? For example, point 1 is connected with point 2, but not point 3. Can I set the edge? If I can't, does this mean that all the points are connected?

Looking forward to your reply. Thank you!

lucasb-eyer commented 7 years ago

I have never done this, but the whole point (pun intended) of denseCRF is to densely connect all points with all.

I have just spent some time going through the code and the paper, and I don't think there's a way to do this. If you re-read sections 3 and 4 of the paper, you'll see that nowhere is there a term where you could specify individual edge weights. Possibly, you could hack around this in some way by defining some specific kind of features and full kernel precision-matrix. That'd be a horrible hack and I'm not sure it'd work at all, though.

What you want sounds like a more specific type of CRF, not a DenseCRF.

lucasb-eyer commented 7 years ago

Closing. If there's more to discuss, feel free to re-open.