Caffe中Flages的安装与使用!

来源:互联网 发布:网络喷子 编辑:程序博客网 时间:2024/04/30 03:20

    调试Caffe的过程,小伙伴们应该都知道,需要通过.bat或.sh,把相关的命令传到Caffe.exe中,那么Caffe的命令传入是怎么实现的呢!下面给大家做一个简单的介绍,Caffe中命令的传入借用了google的开源工具gflags,因google被和谐的原因,在网上找到现在gflags被转到github中https://github.com/gflags/gflags,在里面下载原码!然后通过Cmake进行编译出第三方库(vs2012所使用的.lib与.h文件)。

   百度云gflags-master:http://pan.baidu.com/s/1qYCSUL2  密码:32cg

   百度云CMake:http://pan.baidu.com/s/1slyDJ33  密码:t9t2

    然后利用Cmake进行编译即可生成gflags第三方VS2012所需要的.h和.lib。具体可以考考http://blog.csdn.net/lming_08/article/details/25072899;以下是我编写的gflags测试代码。

#include "iostream"#include "gflags/gflags.h"#pragma comment (lib,"gflags_nothreads_static.lib")#pragma comment (lib,"gflags_static.lib")#pragma comment (lib,"shlwapi.lib")// 定义对 FLAGS_port 的检查函数static bool ValidatePort(const char* name, int32_t value) {if (value > 0 && value < 32768) {return true;}printf("Invalid value for --%s: %d\n", name, (int)value);return false;}DEFINE_string(host, "127.0.0.1", "the server host");DEFINE_int32(port, 12306, "the server port");static const bool port_dummy = gflags::RegisterFlagValidator(&FLAGS_port, &ValidatePort);int main(int argc, char** argv){// 解析命令行参数,一般都放在 main 函数中开始位置gflags::ParseCommandLineFlags(&argc, &argv, true);std::cout << "The server host is: " << FLAGS_host<< ", the server port is: " << FLAGS_port << std::endl;// 使用 SetCommandLineOption 函数对参数进行设置才会调用检查函数gflags::SetCommandLineOption("port", "-2");std::cout << "The server host is: " << FLAGS_host<< ", the server port is: " << FLAGS_port << std::endl;return 0;}

百度云源程序vs2012编译:http://pan.baidu.com/s/1qYatrRm  密码:int1


0 0