本文介绍了如何加快svm.predict?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个滑动窗口以提取特征并将其输入到CvSVM的预测函数中.但是,我偶然发现svm.predict函数相对较慢.

I'm writing a sliding window to extract features and feed it into CvSVM's predict function.However, what I've stumbled upon is that the svm.predict function is relatively slow.

基本上,窗口以固定的步长在图像比例尺上滑动通过图像.

Basically the window slides thru the image with fixed stride length, on number of image scales.

  • 遍历图像的速度以及每个图像的提取功能窗口大约需要1000毫秒(1秒).
  • 由adaboost训练的弱分类器的包含导致大约1200毫秒(1.2秒)
  • 但是,当我通过功能时(已标记为肯定)通过弱分类器)到svm.predict函数,整体速度减慢到大约16000毫秒(16秒)
  • 尝试先收集所有正"功能,然后再传递给svm.predict利用TBB的线程导致了19000毫秒(19秒)的时间,这可能是由于创建线程所需的开销等造成的.
  • The speed traversing the image plus extracting features for eachwindow takes around 1000 ms (1 sec).
  • Inclusion of weak classifiers trained by adaboost resulted in around1200 ms (1.2 secs)
  • However when I pass the features (which has been marked as positiveby the weak classifiers) to svm.predict function, the overall speedslowed down to around 16000 ms ( 16 secs )
  • Trying to collect all 'positive' features first, before passing tosvm.predict utilizing TBB's threads resulted in 19000 ms ( 19 secs ), probably due to the overhead needed to create the threads, etc.

我的OpenCV构建已编译为包括TBB(线程)和OpenCL(GPU)功能.

My OpenCV build was compiled to include both TBB (threading) and OpenCL (GPU) functions.

有没有人设法加快OpenCV的SVM.predict函数?

Has anyone managed to speed up OpenCV's SVM.predict function ?

我已经在这个问题上停留了一段时间,因为通过我的测试数据来运行此检测算法对于统计数据和阈值调整是令人沮丧的.

I've been stuck in this issue for quite sometime, since it's frustrating to run this detection algorithm thru my test data for statistics and threshold adjustment.

非常感谢您阅读本书!

推荐答案

(上面发布了我的评论以使其正式化的答案)

(Answer posted to formalize my comments, above:)

SVM的预测算法需要O( nSV * f )时间,其中 nSV 是支持向量的数量,而 f 是功能的数量.可以通过更强的正则化训练来减少支持向量的数量,即通过增加超参数 C (可能会以预测准确性为代价).

The prediction algorithm for an SVM takes O(nSV * f) time, where nSV is the number of support vectors and f is the number of features. The number of support vectors can be reduced by training with stronger regularization, i.e. by increasing the hyperparameter C (possibly at a cost in predictive accuracy).

这篇关于如何加快svm.predict?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 07:04