Optimization

Direct Preference Optimization (DPO)原理详解及公式推导 本文讲解Direct Preference Optimization (DPO)原理以及推导过程。 阅读详情

http://answers.opencv.org/question/755/object-detection-slow/#760


Haar features are inherently slow - they make extensive use of floating point operations, which are a bit slow on mobile devices.

A quick solution would be to turn to LBP cascades - all you need is a few lines changed in your code. The performance gain is significant, and the loss in accuracy is minimal. Look for lbpcascades/lbpcascade_frontalface.xml.

If you want to dig deeper into optimzations, here is a generic optimization tip list (cross-posted from SO) Please note that face detection, being one of the most requested features of OpenCV, is already quite optimized, so advancing it further may mean deep knowledge.

Advice for optimization

A. Profile your app. Do it first on your computer, since it is much easier. Use visual studio profiler, and see what functions take the most. Optimize them. Never ever optimize because you think is slow, but because you measure it. Start with the slowest function, optimize it as much as possible, then take the second slower.

B. First, focus on algorithms. A faster algorithm can improve performance with orders of magnitude (100x). A C++ trick will give you maybe 2x performance boost.

Classical techniques:

  • Resize you video frames to be smaller. many times, you can extract the information from a 200x300px image, instead of a 1024x768. The area of the first one is 10 times smaller.

  • Use simpler operations instead of complicated ones. Use integers instead of floats. And never usedouble in a matrix or a for loop that executes thousands of times.

  • Do as little calculation as possible. Can you track an object only in a specific area of the image, instead of processing it all for all the frames? Can you make a rough/approximate detection on a very small image and then refine it on a ROI in the full frame?

C. In for loops, it may make sense to use C style instead of C++. A pointer to data matrix or a float array is much faster than mat.at<i, j=""> or std::vector<>. But change only if it's needed. Usually, a lot of processing (90%) is done in some double for loop. Focus on it. It doesn't make sense to replace vector<> all over the place, ad make your code look like spaghetti.

D. Some OpenCV functions convert data to double, process it, then convert back to the input format. Beware of them, they kill performance on mobile devices. Examples: warping, scaling, type conversions. Also, color space conversions are known to be lazy. Prefer grayscale obtained directly from native YUV.

E. ARM processors have NEON. Learn and use it. It is powerfull!

A small example:

float* a, *b, *c;
// init a and b to 1000001 elements
for(int i=0;i<1000001;i++)
    c[i] = a[i]*b[i];

can be rewritten as follows. It's more verbose, but trust me it's faster.

float* a, *b, *c;
// init a and b to 1000001 elements
float32x4_t _a, _b, _c;
int i;
for(i=0;i<1000001;i+=4)
{  
    a_ = vld1q_f32( &a[i] ); // load 4 floats from a in a NEON register
    b_ = vld1q_f32( &b[i] );
    c_ = vmulq_f32(a_, b_); // perform 4 float multiplies in parrallel
    vst1q_f32( &c[i], c_); // store the four results in c
}
// the vector size is not always multiple of 4 or 8 or 16. 
// Process the remaining elements
for(;i<1000001;i++)
    c[i] = a[i]*b[i];

Purists say you must write in assembler, but for the regular programmer guy that's a bit daunting. I found good results writing with intrinsics, like in the above example.

Also check this blog post and the following posts about NEON.

And, last but not least, I should mention that I had very good success converting the SSE optimizations (this is the NEON counterpart in x86-64 processors) in OpenCV to NEON, like here. This is the image filtering code for uchar matrices (the regular image format). You should't blindly convert instructions one by one, because there are better ways to do it, but take it as an example to start with.

Bayesian Optimization贝叶斯优化(代码详解) `bayesian-optimization是一个基于贝叶斯推理和高斯过程的约束全局优化包,它试图在尽可能少的迭代中找到未知函数的最值。该技术特别适合优化高成本函数。本文对其代码实现进行了解析。 阅读详情

相关推荐

Simulink Design Optimization的参数估计

还是因为最近工作需要用到参数估计一块的内容。。。记录一下学习心得和有用的资料 一、几个命令的更新 1、speload和spetool speload是旧命令,2018b版已经help不到这个命令了,但还能用。新命令改名为spetool。下面是spetool的用法: spetool('modelname') spetool('modelname')opens the Parameter ...

qq_36847641的博客 5283

深度学习中optimization的方法

结合网上的资料与李宏毅老师的课堂教学,总结一下optimization的方法。如果以对训练结果不满意,可以尝试用下述的方法,可以优先考虑方法1-4、方法6 方法1:正则化(Regularization) 正则化是防止神经网络overfitting的一种方法,由于模型的参数太多,所以就容易过拟合(可以想象一下决策树需要剪枝),其原理是在损失函数中增加一个惩罚项来限制过大的权重。通常有3种方法:L1正则化,L2正则化,dropout L1正则化,江湖中也人称Lasso,表示各个参数绝对值之和:它之所以可以防止

gailj 1537

超参数优化之贝叶斯优化(Bayesian Optimization)

文章目录Ⅰ.Grid Search/Random SearchⅡ.Bayesian Optimization Ⅰ.Grid Search/Random Search Grid Search:神经网络训练由许多超参数决定,例如网络深度、学习率、卷积核大小等等。为了找到一个最好的超参数组合,最直观的想法就是Grid Search, 其实也就是穷举搜索。 Random Search:为了提高搜索效率,提出随机搜索。虽然随机搜索得到的结果互相之间差异较大,但是实验证明随机搜索的确比网格搜索效果要好 Ⅱ.

VictoryZhou_的博客 8524

深度学习中的优化问题(Optimization)

1. 深度学习、机器学习、神经网络、CNN。 2. 模型构建中的优化问题。 3. 基于花书、邱锡鹏书、李沐书、其他资料等。

qq_39770163的博客 8029

Intro to Policy Optimization 代码详解

本篇文章是 OpenAI Spinnging Up 中 Part 3: Intro to Policy Optimization 中代码的学习笔记, 原文在 https://spinningup.openai.com/en/latest/spinningup/rl_intro3.html , 代码在 https://github.com/openai/spinningup/blob/master/spinup/examples/pytorch/pg_math/1_simple_pg.py . 先给出代码 i

云玩家 2726

ADS基础教程5 - Optimization

用鼠标点击对应的参数即可,如图所示点击L1的值(L=100nH),点击完成后,会将改值以滑块的形式加入到当前的弹窗中,并且,可以设置参数的当前值(Value)、最大值(Max)、最小值(Min)、调整步长(Step)和Scale。通过上、下调整中间滑块的位置,可以改变当前值。用鼠标点击对应的参数即可,如图所示点击L1的值(L=100nH),点击完成后,会将改值以滑块的形式加入到当前的弹窗中,并且,可以设置参数的当前值(Value)、最大值(Max)、最小值(Min)、调整步长(Step)和Scale。

XZ_ZC的博客 7930

Simulink相关配置: Optimization配置

本文研究Embedded Coder中的Optimization配置,通过一些模型示例和代码直观地比较配置对代码生成的影响。由于配置选项很多,本文会长期更新。 文章目录1 Optimization配置2 Default parameter behavior2.1 描述2.2 模型示例2.3 生成代码2.4 分析与思考 1 Optimization配置 Optimization配置中包含了代码生成的优化选项。在Simulink配置窗口的Code Generation下可以找到Optimization配置。

u013288925的博客 9566

Algebra, Topology, Differential Caculus, and Optimization Theory.pdf

学习计算机科学总共需要多少数学基础?宾夕法尼亚大学计算机和信息科学系教授Jean Gallier用一本1960页书的容量解决了所有的问题。该本书涵盖了计算机科学所需的线性代数、微分和最优化理论等基础知识,包含十分详尽的数学证明,以及这些知识在机器学习、机器人学、计算机视觉等领域的应用。

matlab optimization toolbox 笔记

1 Introduction matlab optimmization 工具箱功能十分强大,这一章节梳理problem based optimization 问题。 Optimization Toolbox™ provides functions for finding parameters that minimize or maximize objectives while satisfying constraints. The toolbox includes solvers for linear p

降低学习速度,提高学习效率的地方 6302

Algebra, Topology, Differential Calculus and Optimization for CS 2017

Algebra, Topology, Differential Calculus, and Optimization Theory for Computer Science and Engineering Jean Gallier and Jocelyn Quaintance Book in Progress, Approx. 1440 pages (2017) http://www.cis.upenn.edu/~jean/gbooks/geomath.html

topology optimization theory,methods,and applications

电子书,经典的结构拓扑优化入门书籍! 电子书,经典的结构拓扑优化入门书籍!!

webpack的optimization配置

webpack的optimization配置 1.minimizer 2.runtimeChunk 3. noEmitOnErrors 4. splitChunks 1. chunks 2. name 3. minChunks 4. minSize,maxSize,maxAsyncRequests(按需加载时候最大的并行请求数),maxInitialRequests(一个入口最大的并行请求数) 5. cacheGroups 这个选项是webpack4新增的,主要是用来自定义一些优化打包策略。 1.mini

aa_mmnn的博客 2492

Optimization Models

伯克利EE127/EE227AT教材,大牛教授Laurent El Ghaoui亲自编写和上课课件基本一一对照

webpack4 optimization总结

optimization总结 minimize 默认为true,效果就是压缩js代码。 minimizer 可以自定义UglifyJsPlugin和一些配置,默认的压缩为uglifyjs-webpack-plugin //比如在构建的时候,希望新增css的压缩 minimizer: mode === "development" ? [] : [ ne...

aaa333qwe的博客 2145

FineReport V11.0安装避坑指南:从下载到激活的完整流程(附百度网盘链接)

本文提供FineReport V11.0从下载、安装到激活的完整避坑指南。详细解析了部署前的环境准备、安装过程中的JVM内存等核心配置、激活流程以及安装后的优化与常见问题排查,旨在帮助用户一次部署成功,确保企业级报表平台的稳定运行。

echo99的专栏 1215

.NET MAUI 第13讲 深入探索 .NET MAUI Essentials:让应用感知设备与环境,打造智能体验

摘要:本文介绍了.NET MAUI Essentials库如何赋能移动应用感知设备环境的能力。文章详细讲解了设备信息获取(DeviceInfo)、网络状态监测(Connectivity)、地理位置服务(Geolocation)、地图集成(Map)以及传感器(Accelerometer等)等核心功能的使用方法,并提供了完整的代码示例。通过一个综合练习,展示了如何构建设备信息仪表板,实时显示设备参数和网络状态,并实现位置获取与地图导航功能。这些跨平台API能显著提升应用智能化和用户体验,同时保持代码简洁高效。

AlphaNil的博客 1099

matlab optimization terminated,求助Optimization terminated. 的问题

小弟按照课本写了的一个这样的程序%利用分支定界法实现整数线性规划%调用格式为[intx,intf]=Intprog(f,A,b,Aeq,beq,lb,up)%f,A,b,Aeq,lb,up与linprog函数中意义相同%intx为目标函数最小值时的变量%intf目标函数的最小值function [x,intf]=Intprog(f,A,b,Aeq,beq,lb,up)x=NaN;intf=NaN;...

weixin_29495679的博客 1206

基于WEKWS模型的语音唤醒关键词识别

本文所使用的模型网络结构继承自论文《Compact Feedforward Sequential Memory Networks for Small-footprint Keyword Spotting》,文中研究了将低秩矩阵分解与传统FSMN相结合的紧凑型前馈顺序记忆网络(cFSMN)用于远场关键字检测任务。

YuZhou的博客 6607

3.webpack的optimization配置

阿达

weixin_43678786的博客 6673

大数据实战:Python与MySQL在足球赔率分析中的高效应用

本文详细介绍了如何利用Python与MySQL进行大数据实战,实现足球赔率的高效分析。通过对比Excel处理的局限性,阐述了数据库在处理百万级数据时的速度优势。文章提供了从环境搭建、使用pymysql连接数据库、利用pandas进行数据清洗与分析,到构建自动化分析系统的完整流程,旨在帮助读者将大数据技术应用于实际业务场景,显著提升数据处理与洞察效率。

weixin_29080843的博客 458

LangGraph 实战教程:搭建一个智能办公多Agent协作平台

只存储必要的信息:不要把所有的原始数据都存储在状态中,比如销售数据可以存储在数据库或向量数据库中,状态中只存储数据的 ID 或摘要。使用类型提示:避免类型错误,提高代码的可维护性。支持增量更新:LangGraph 默认支持状态的增量更新(通过reduce函数),比如messages列表可以通过追加新消息的方式更新,而不是每次都重新创建整个列表。Normal Edge 的定义非常简单,只需要在StateGraph对象(稍后会详细讲解)上调用add_edge# 创建一个 StateGraph 对象。

SuperAGI2025 225
上一篇: Precision and recall From Wiki
下一篇: OpenCV的Filter2D代码解析
carpinter
博客等级 码龄19年 26粉丝 14原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址