【问题标题】:Training with LIBSVM after extracting high dimensional lbp descriptors using dlib使用 dlib 提取高维 lbp 描述符后使用 LIBSVM 进行训练
【发布时间】:2016-11-05 20:47:13
【问题描述】:

我正在做一个面部表情识别项目,使用 dlib 来获取面部并提取描述符,并使用 libsvm 来训练获得的数据。我在 Visual Studio Community 2015 中使用 c++。到目前为止,我已经提取了高维 LBP 描述符,现在想了解使用 libsvm 获得和训练的特征。我被困在这里,因为我无法理解我的“特征”向量中的数据,也无法将其转换为 libsvm 接受的训练格式。

下面是代码sn-p。在此之前,我想几乎所有事情都是不言自明的。

  std::vector<std::vector<double>> features;//storing features for all images

  std::vector<double> feat;//for a single image

  extract_highdim_face_lbp_descriptors(img, shape, feat); //dlib's function, storing extracted info in 'feat'

  features.push_back(feat);

  //Now all the info for all the images is stored in 'features' vector. I now need to train the data and make a suitable model using libsvm, precisely RBF kernel. 

【问题讨论】:

    标签: c++ libsvm dlib


    【解决方案1】:

    您需要存储为特征、标签来进行学习过程。 LibSVM 使用基于空间的文本格式。这是可以写这种格式的代码convert from CSV

    写作可以是这样的(未经测试):

    ofstream f("data_file");
    for (auto img : images) //each image should be 
    {
        std::vector<double> feat;
        shape = predictor(img);
        extract_highdim_face_lbp_descriptors(img, shape, feat);
        double label = is_neutral ? -1.0 : +1.0;
        f << label;
        for (int i = 0; i < feat.size(); ++i)
           if (feat[i] != 0.0)
               f<< " " << i << ":" << feat[i];
        f << endl;
    }
    

    如果你使用 Dlib - 你不需要 LibSVM - 你可以使用 Dlib 进行训练,here is an example of SVM training with dlib

    【讨论】:

      猜你喜欢
      • 2011-12-14
      • 2011-01-25
      • 2017-10-19
      • 2012-02-21
      • 2013-04-16
      • 2013-06-14
      • 2014-06-30
      • 2016-09-20
      • 2016-05-03
      相关资源
      最近更新 更多