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

buf2matf makes a copy of the feature map #14

Closed swehrwein closed 8 years ago

swehrwein commented 8 years ago

In the experiments I'm currently running, the setup (call to addPairwiseEnergy) takes nearly as long as the inference itself. If the feature map is built transposed relative to the C++ code's convention, then we could simply wrap the raw data in an Eigen::MatrixXf and no copying would be necessary.

I'm planning to change this in my fork, and would be happy to create a PR, but it will break backwards compatibility by changing the interface. Specifically, the features that go into addPairwiseEnergy would need to have shape (npixels, nlabels).

lucasb-eyer commented 8 years ago

I will be happy to have a look at the PR and potentially merge it. I'm not too concerned about breaking backwards compatibility if it's better for the long-term. We're not at 1.0 yet :smile:

swehrwein commented 8 years ago

This turned out to be a false alarm: after further testing it looks like the copy itself isn't the performance bottleneck at all. In the example I'm running, setup takes about 15 seconds, most of which is spent initializing the lattice (splatting the feature vectors into bilateral space). The copy takes about 0.3-0.4 of those 15 seconds.

lucasb-eyer commented 8 years ago

Glad to hear that and thank you for following up with your analysis!