caffe-yolo,C++实现yolo模型目标检测算法

这篇文章的主要目的是想把yolo转到caffe框架上去做检测,训练检测模型用的是github上https://github.com/yeahkun/caffe-yolo 的框架,训练了一个试卷中教师批注分数位置检测的模型,然后在用c++实现预测功能。
环境配置
ubuntu16.04上训练caffe-yolo模型
windows操作系统实现预测功能
编译工具
Visual Studio 2013
参考深度学习框架
这里的作者有介绍详细的模型训练和测试过程,只需要修改适合自己检测模型的参数即可
caffe-yolo模型训练
参考原作者即可,这里省略略。。。
C++实现预测目标位置
项目结构
yolo_predict项目可以建在和caffe同一层级下,在这个项目里同样用到了caffe中实现的层;
1.yolo_predict.cpp

// yolo_predict.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#include "yolo_predict.h"

#include <string>
#include <vector>
#include "head.h"
#include<windows.h>

#include "boost/algorithm/string.hpp"
#include "google/protobuf/text_format.h"
#include <opencv2/opencv.hpp>

#include "caffe/blob.hpp"
#include "caffe/layer.hpp"
#include "caffe/common.hpp"
#include "caffe/net.hpp"
#include "caffe/proto/caffe.pb.h"
#include "caffe/util/db.hpp"
#include "caffe/util/format.hpp"
#include "caffe/util/io.hpp"
#include <stdio.h>
#include <malloc.h>
#include <fstream>
#include <boost/progress.hpp>

#include <boost/math/special_functions/next.hpp>
#include <boost/random.hpp>

#include <limits>

#include "caffe/common.hpp"
#include "caffe/util/math_functions.hpp"
#include "caffe/util/rng.hpp"

/*argv[1]网络的prototxt
argv[2]权重文件(如果编译时候使用的是loadweight,argv[2]对应的是txt文件夹,如果使用的是CopyTrainedLayersFromBinaryProto,argv[2]对应的是caffemodel)
argv[3]图片文件*/
//#include "caffe/util/math_functions.hpp"
using namespace caffe;
using caffe::Blob;
using caffe::Caffe;
using caffe::Datum;
using caffe::Net;
using caffe::Layer;
using std::string;
namespace db = caffe::db;

void loaddata(boost::shared_ptr<Net<float> >& net, std::string image_path);
void getbox(std::vector<float> result, float* pro_obj, int* idx_class, 
  • 0
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值