Python and Matlab bindings for Damascene, Global Probabilty of Boundary on GPU
So I'm still playing around with constrained parametric min-cuts for object segmentation. A major bottleneck of this algorithm is gPb, the global probability of boundary operator from Malik's group.
Luckily, there already is a CUDA implementation of gPb out there: Damascene.
Damascene provides a command line interface to apply gPb to ppm images.
Since I wanted to include it directly with cpmc, I wrote some mex-wrappers for Damascene. And since I would love to see more algorithms done in Python instead of Matlab, I wrote some Python wrappers, too.
You can find both, together with the current version of damascene here.
You need a working CUDA setup and the acm library to compile it.
Set your paths in common.mk and just "make" it.
For the matlab wrappers, you also need to adjust the matlab path in "bindings/Makefile" and "make gpb_mex" in that directory.
For the python wrappers, you have to compile damascene with "make shared=1". Then you can simply call gpu_gpb.py inside the bindings directory.
If you only have the students' version of Matlab, like me, you can use the file "common_32.mk" instead of common.mk to cross-compile damascene. You will probably have to adjust some paths in there, too.
I'd like to thank Bryan Catanzaro for making Damascene public. It's really a great tool!
Luckily, there already is a CUDA implementation of gPb out there: Damascene.
Damascene provides a command line interface to apply gPb to ppm images.
Since I wanted to include it directly with cpmc, I wrote some mex-wrappers for Damascene. And since I would love to see more algorithms done in Python instead of Matlab, I wrote some Python wrappers, too.
You can find both, together with the current version of damascene here.
You need a working CUDA setup and the acm library to compile it.
Set your paths in common.mk and just "make" it.
For the matlab wrappers, you also need to adjust the matlab path in "bindings/Makefile" and "make gpb_mex" in that directory.
For the python wrappers, you have to compile damascene with "make shared=1". Then you can simply call gpu_gpb.py inside the bindings directory.
If you only have the students' version of Matlab, like me, you can use the file "common_32.mk" instead of common.mk to cross-compile damascene. You will probably have to adjust some paths in there, too.
I'd like to thank Bryan Catanzaro for making Damascene public. It's really a great tool!
Hi,
ReplyDeleteThanks a lot for the useful work and sharing it with the community
Before going to matlab wrappers, i just wanted to run damascene in C++. After successful compilation, I've got this runtime error:
"Assertion failed: screenedEigVals.size() >= p_nEigNum"
Do you happen having faced this error?
Could you help me solve this problem?
Thanks in advance
Best regards
Hi.
ReplyDeleteNope, I never ran into this problem. What command line arguments did you use? Did you try the default parameters?
Cheers,
Andy
I did not find any default parameters nor a sample ppm image. I just used some images of mine and played with the parameters values but still having the same error.
ReplyDeleteCould you please send me an image and corresponding parameters that work
Thanks
There is a file called "polynesia.ppm" in the "damascene" subfolder.
ReplyDeleteJust call damascene with this file and no other arguments
like this (my damascene executable is in some release folder at that point)
"./damascene ../../../damascene/polynesia.ppm "
Thanks for the hint. But this is what i've got
ReplyDeleteUsing cuda device 0: Quadro FX 3800
Processing: polynesia.ppm, output in polynesiaPb.pgm and polynesia.pb
Eig 9 Tol 0.001000 Texton 1Image found: 321 x 481 pixels
Available 874888704 bytes on GPU
>+< rgbUtoGrayF | 0.088000 | ms
Convolving
Beginning kmeans
Changes: 150510
Changes: 75038
Changes: 49962
Changes: 36991
Changes: 30317
Changes: 24616
Changes: 20667
Changes: 17589
Changes: 15044
Changes: 12782
Changes: 10673
Changes: 8873
Changes: 7254
Changes: 5789
Changes: 4663
15 iterations until termination
Kmeans completed
>+< texton | 235.102005 | ms
>+< rgbUtoLab3F | 0.181000 | ms
>+< normalizeLab | 0.004000 | ms
>+< mirrorImage | 1.537000 | ms
Beginning Local cues computation
>+< Bgsmooth: | 45.691002 | ms
>+< Bg: | 276.975006 | ms
>+< Cgsmooth: | 101.719002 | ms
>+< Cga: | 315.234985 | ms
>+< Cgsmooth: | 101.391998 | ms
>+< Cgb: | 317.585999 | ms
>+< Tgsmooth: | 97.671997 | ms
>+< Tg: | 254.839996 | ms
Completed Local cues
localcues time: 1.198925 seconds
>+< localcues | 1198.927979 | ms
>+< combine | 0.374000 | ms
Max time: 0.000117 seconds
Oriented Max time: 0.001017 seconds
Solve time: 0.001145 seconds
>+< nonmaxsupression | 3.273000 | ms
Intervening contour completed
>+< intervene | 37.535000 | ms
Available 804051968 bytes on GPU
Can fit 1158 iterations on GPU
lanczos iteration: 0
lanczos iteration: 100
lanczos iteration: 200
lanczos iteration: 300
lanczos iteration: 400
Screened Eigenvalues:
nan nan 0.000000e+00
damascene: lanczos.cu:360: void CullumDevice(int, float*, float*, double*, double*, int, float*, float*, int, float*, double*, char, char, double, double, int, int, double, int, double*, int*, int*, double*, int*, int*): Assertion `screenedEigVals.size() >= p_nEigNum' failed.
Abandon
Weird.
ReplyDeleteSeems to be some numerical problem. Which version of damascene are you using? I'm using 0.1.4. Can you try another GPU?
Maybe try the CUDA memtest tool: http://sourceforge.net/projects/cudagpumemtest/
I used the source files provided by your package (0.1.4) and finally it works! :))
ReplyDeleteIt's weird that in the damascene page (http://www.cs.berkeley.edu/~catanzar/Damascene/),the version provided is 0.1 and not the 0.1.4.
I wonder where have you downloaded the 0.1.4 version?
Thanks a lot anyway for helping me :)
There is another place to download it. Follow the link at "favourite code" at the right.
ReplyDeleteI notice they have 0.1.5 now.
Since you had so much trouble with the older version, maybe you should tell them to update their links.
Cheers,
Andy
There was a minor fix in 0.1.5, which I included in my matlab and python bindings. If you want, you can get them here:
ReplyDeletehttps://github.com/amueller/damascene-python-and-matlab-bindings
I just sent an e-mail to Damascene author
ReplyDelete