DaHoC / trainHOG

Example program showing how to train your custom HOG detector using openCV
221 stars 111 forks source link

Training SVM #4

Open ghost opened 9 years ago

ghost commented 9 years ago

I am struggling the last days trying to find way to train svm with my own data. My issue is how to change properly svm kernel. I found in your code svmlight.h with svm parameters. When I am trying to change learn_parm->kernel_type from LInear to RBF I am getting errors (core dumped).

DaHoC commented 9 years ago

I think for RBF kernel, some additional parameters (specific to RBF, such as gaussian sizes, etc.) have to be set, but I do not know which ones (HOG usually uses a linear kernel). You could try to determine the relevant parameters and parameter values by using svmlight as separate program with the input files my program creates. The errors are thrown by the SVMlight library, may be the SVMlight people are able to help you with this issue.

ghost commented 9 years ago

Jan thanks for the time. It seems that if I use the executable provided from the svmlight site for training it works fine. On 15/10/2014 12:30 μμ, Jan wrote:

I think for RBF kernel, some additional parameters (specific to RBF, such as gaussian sizes, etc.) have to be set, but I do not know which ones (HOG usually uses a linear kernel). You could try to determine the relevant parameters and parameter values by using svmlight as separate program with the input files my program creates.

— Reply to this email directly or view it on GitHub https://github.com/DaHoC/trainHOG/issues/4#issuecomment-59180122.

Issabel08 commented 9 years ago

hello, trying to run this software to execute and test, after creating the "trainhog" I get no run file, after "Build by Issuing" and not to do ..

DaHoC commented 9 years ago

Hi Issabel08, in order to be able to help you, you need to provide more information, such as the operating system (Linux? Windows? ...) and IDE (Eclipse? Netbeans? None? ...) used. Do you get an error? If so, what is the error message? Does it occur during compile-time or run-time? Many IDEs generate the executables into sub-directories such as build/debug/x86/trainhog. Also note that the actual training step may take some time depending on the number of training samples, but you should see the output of the running program during this stage nonetheless.

Issabel08 commented 9 years ago

Hi DaHoC... Thank you for answer. I use Ubuntu and i be able to compile the code with commands in a Linux shell: g++ pkg-config --cflags opencv -c -g -MMD -MP -MF main.o.d -o main.o main.cpp gcc -c -g pkg-config --cflags opencv -MMD -MP -MF svmlight/svm_learn.o.d -o svmlight/svm_learn.o svmlight/svm_learn.c gcc -c -g pkg-config --cflags opencv -MMD -MP -MF svmlight/svm_hideo.o.d -o svmlight/svm_hideo.o svmlight/svm_hideo.c gcc -c -g pkg-config --cflags opencv -MMD -MP -MF svmlight/svm_common.o.d -o svmlight/svm_common.o svmlight/svm_common.c g++ pkg-config --cflags opencv -o trainhog main.o svmlight/svm_learn.o svmlight/svm_hideo.o svmlight/svm_common.o `pkg-config --libs

Now, i am dummy on all this, during the compilation i dont cant see the output of the running program, and i dont have any error, i dont undestand how to use the file result (trainhog), i cant call it with . , tell me "denied permission" or "dont file found", or maybe i have to use the "trainhog" file into {{{hog.setSVMDetector(trainhog)}}}

My file structure: trainHOG-master/ -neg/ files.png (download from http://pascal.inrialpes.fr/data/human/) -pos/ files.ppm (download from http://pascal.inrialpes.fr/data/human/) -svmlight/ files: svm_learn, svm_common, svmhideo,kernel, svmlight -sidefiles/ -genfiles/ -libsvm/ file libsvm -main.cpp -main.o -main.o.d -Readme.md -trainhog (437,5 kB)

DaHoC commented 9 years ago

Hi, the compile commands look fine to me, and it seems to me that the output file (trainhog) is being generated? If so, you can try to call it using ./trainhog from the same directory. In case of "permission denied" errors, did you try setting the execution permission to the file before calling, e.g. $> sudo chmod u+x trainhog ? Best regards, Jan

Issabel08 commented 9 years ago

Thank you Jan, I just do it all again, its working !!! Thank you very much.. :)

SachinTS commented 9 years ago

Hey people , I am trying to use this library on windows (64 bit) with visual studio 2010. Please tell me how do I install. I tried including this folder https://github.com/LihO/SVMLightClassifier/tree/master/src And I get this error : 1>------ Build started: Project: openCV, Configuration: Debug Win32 ------ 1> svm.cpp 1>c:\users\xxx\desktop\svmlightclassifier-master\src\svmlightlib.h(19): warning C4091: 'extern ' : ignored on left of 'SVMLight::SVMTrainer' when no variable is declared 1>c:\users\xxx\desktop\svmlightclassifier-master\src\svmlightlib.h(26): warning C4091: 'extern ' : ignored on left of 'SVMLight::SVMClassifier' when no variable is declared 1>svm.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification 1>svm.obj : error LNK2019: unresolved external symbol "public: void __thiscall SVMLight::SVMTrainer::trainAndSaveModel(class std::basic_string<char,struct std::char_traits,class std::allocator > const &)" (?trainAndSaveModel@SVMTrainer@SVMLight@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main 1>svm.obj : error LNK2019: unresolved external symbol "public: void thiscall SVMLight::SVMTrainer::writeFeatureVectorToFile(class std::vector<float,class std::allocator > const &,bool)" (?writeFeatureVectorToFile@SVMTrainer@SVMLight@@QAEXABV?$vector@MV?$allocator@M@std@@@std@@_N@Z) referenced in function _main 1>svm.obj : error LNK2019: unresolved external symbol "public: thiscall SVMLight::SVMTrainer::SVMTrainer(class std::basic_string<char,struct std::char_traits,class std::allocator > const &)" (??0SVMTrainer@SVMLight@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main 1>D:\xxx\openCV\Debug\openCV.exe : fatal error LNK1120: 3 unresolved externals ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

mbrraghu commented 9 years ago

hi,

i am using MS visual studio, for coding object detection. i have downloaded the SVMLIGHT code, but i dont know how to use it in the program, it is showing many errors, even though i include svmlight.h in the project. it is showing some linker errors while debugging. please help me

amlandas78 commented 9 years ago

Hi, I was trying to implement it using VS2010. The build is successful. But when it finishes finding the samples in the pos and neg folder, it breaks and shows a error msg: First-chance exception at 0x532237ff (msvcr100d.dll) in xxxxx.exe: 0xC0000005: Access violation reading location 0xcccccccc. Unhandled exception at 0x532237ff (msvcr100d.dll) in xxxxx.exe: 0xC0000005: Access violation reading location 0xcccccccc. The program '[8844] xxxxx.exe: Native' has exited with code 0 (0x0).

amlandas78 commented 9 years ago

Hi, I am getting error in make_debug and make_release mak files, while building the targets. I am using ubuntu 15.04 and eclipse IDE. Can anyone help me with that?

misszhongy commented 8 years ago

Hi, Have you checked your .so...such libs? I once had the question and I add them to my project so it can link to the libs necessary.

DaHoC commented 8 years ago

Hi Franklica, this is actually a bug in my code, thank you, I will fix it when I have some time. Try replacing: printf("Resulting vector size %lu\n", singleDetectorVector.size()); with printf("Resulting vector size %zu\n", singleDetectorVector.size());

Best regards, Jan Hendriks

On Thu, Dec 31, 2015 at 6:09 PM, Franklica notifications@github.com wrote:

Hi Jan.. I was using trainHOG for train my custom Animal detection in Android Studio and got a data features.dat.But I know, I must to generate a single detecting feature vector (v1 | b) from the trained support vectors.I look your sample code here

vector descriptorVector; vector descriptorVectorIndices; //Generate a single detecting feature vector (v1 | b) from the trained support vectors, for use e.g. with the HOG algorithm TRAINHOG_SVM_TO_TRAIN::getInstance()->getSingleDetectingVector(descriptorVector, descriptorVectorIndices); //And save the precious to file system saveDescriptorVectorToFile(descriptorVector, descriptorVectorIndices, descriptorVectorFile);

// Set our custom detecting vector hog.setSVMDetector(descriptorVector);

But, I get a following error :

Warning:warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'std::vector::size_type {aka unsigned int}' [-Wformat=] printf("Resulting vector size %lu\n", singleDetectorVector.size());

what do you think ?

— Reply to this email directly or view it on GitHub https://github.com/DaHoC/trainHOG/issues/4#issuecomment-168223855.

Franklica commented 8 years ago

printf("Resulting vector size %lu\n", singleDetectorVector.size()); in svmlight.h code not from trainHOG main.cpp

SteffNeu commented 8 years ago

Hey, I tried to use the train_HOG, but I couldn't find the svm_common.h, svm_learn.h and the kernel.h that were supposed to go with the header. So of course the programm wouldn't work. I opened the main and integrated the svmlight.h new because the proogramm woudldn't do it itself. Am I doing anything wrong? I am quite new to programming.

Thanks for help in advance.

Also I couldn't build the files in CMake for VS 2015, any tips on that would be appreciated aswell.

amlandas78 commented 8 years ago

I think you should try with the older versions of svmlight where these files are available. or might be you can try the opencv svm train function to train the hog features.

On Tue, Jun 28, 2016 at 5:37 PM, SteffNeu notifications@github.com wrote:

Hey, I tried to use the train_HOG, but I couldn't find the svm_common.h, svm_learn.h and the kernel.h that were supposed to go with the header. So of course the programm wouldn't work. I opened the main and integrated the svmlight.h new because the proogramm woudldn't do it itself. Am I doing anything wrong? I am quite new to programming.

Thanks for help in advance.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/DaHoC/trainHOG/issues/4#issuecomment-229030068, or mute the thread https://github.com/notifications/unsubscribe/AKJMKKSQGXt3gcYdt_fob-qR5Tz2qgH_ks5qQQ6DgaJpZM4Cu34F .

SteffNeu commented 8 years ago

Hey @amlandas78,

thanks for the advice. Do you by any chance have an idea where I can find a link to the older version od the svmlight?

Thanks in advance.

amlandas78 commented 8 years ago

Sorry, I dont have any idea regarding this. Have you tried the opencv svm train functions? Sorry for the late reply.

On Sat, Jul 2, 2016 at 3:25 PM, SteffNeu notifications@github.com wrote:

Hey @amlandas78 https://github.com/amlandas78,

thanks for the advice. Do you by any chance have an idea where I can find a link to the older version od the svmlight?

Thanks in advance.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/DaHoC/trainHOG/issues/4#issuecomment-230093826, or mute the thread https://github.com/notifications/unsubscribe/AKJMKFfmIYBDCm58OjafU6CpuCQaS3kCks5qRjWmgaJpZM4Cu34F .

With Regards,

Amlan Jyoti Das, Dept. of ECE, Gauhati University, Guwahati-781014, Assam, India.

E-mail ID: amlandas78@gmail.com Contact no: +918753888656 / +918822213753