How to train HoG manually in Python? [closed]

asked 2016-06-24 10:50:13 -0500

Yasen gravatar image

updated 2017-01-22 06:55:56 -0500

Hi guys, I'm trying to train my SVM detector and set it on the SVM in detectMultiscale-method implementation of HoG. I want to do it with the Inria person data set in order to achieve maybe the same results, as the guys, who invented the method. Unfortunately I don't have an idea what I'm doing wrong, but I dont detect any people on my test-picture (basically it is a one big picture containing some of the learned images). Below I'm posting my code, but if you have an elegant solution please feel free to share. Thanks.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Yasen
close date 2017-01-22 06:55:16.325692

Comments

imho, you have to use opencv's SVM to train it, not the one from sklearn.

also have a look here, the svmdetector is just a float array from the support vector(s), with -rho added at the end

berak gravatar imageberak ( 2016-06-24 11:11:30 -0500 )edit

Thanks for the responce. I have tried the solution, proposed in ( http://answers.opencv.org/question/56...), but I also dont get any detections. It uses only OpenCV for thraining the detector

Yasen gravatar imageYasen ( 2016-06-24 11:45:06 -0500 )edit

I have used the OpenCV methods and set the type of the SVM to EPS_SVR. That worked for me.

Yasen gravatar imageYasen ( 2016-07-01 03:30:42 -0500 )edit

Yasen, Can u please post ur solution to the problem. I have got similar problem. or, mail me at daraamerone@gmail.com

aamer gravatar imageaamer ( 2016-11-07 11:43:41 -0500 )edit

@ameer, it just does not work, like you want it. noone will mail you

do you understand, that you need to put in some own effort here?

berak gravatar imageberak ( 2016-11-07 12:37:41 -0500 )edit

@berak, yea i am trying to get it done by myself, but i am not able to. if Yasen wishes, he can. right?

aamer gravatar imageaamer ( 2016-11-07 13:18:24 -0500 )edit

the following line is not clear for me svm_classificator = np.array(my_svm().coef_)

where from do you take the my_svm() ?

michael gravatar imagemichael ( 2017-01-22 02:53:56 -0500 )edit

folks, you should use this c++ tool to train an HOG detector, not python.

also, mixing scikit's svm data with opencv's probably will not work.

berak gravatar imageberak ( 2017-01-22 03:15:24 -0500 )edit

berak is right. The c++ tool is perfect for training the classifier. "Translating" the code into python (and only cv2 methods) is not much of an effort, but it gives you the same results, so its not worth it.I removed the code in order not to confuse other users.

Yasen gravatar imageYasen ( 2017-01-22 06:54:49 -0500 )edit

I'm bit ashame, but some people (including me) are not so comfortable with C++, that's why I'm interested in "python" version of HoG...

michael gravatar imagemichael ( 2017-01-22 15:05:14 -0500 )edit