基于tensorflow的模型转化为百度MDL模型

最近尝试将基于tensorflow的facenet模型转化成百度开MDL模型,有如下总结:

先看一下大体处理步骤:
int main(int argc, char **args) {
    try {
        if (argc <= 2) {
            throw string("input parameter no error, an example is : ...  ");
        }
        const char *_tfpb = args[1];
        //g_proto  -- tensorflow::GraphDef  类型
        bool _success1 = read_proto_from_pb(_tfpb, &g_proto);
        if (!_success1) {
            throw string("read_proto_from_text failed");
        }
        //TODO:  g_ios_gpu 相关
        //分析输入的pb文件,存储需要的信息
        tensorflow::GraphDef g_proto_split;
        setup_splits(g_proto,  &g_proto_split );
        //读取原始输入的shape
        read_input_shape (g_shape_map);
        //node_types 是一个记录了转换后所有节点类型的set
        g_node_count = g_proto_split.node_size();
        for ( int i  = 0 ; i < g_proto_split.node_size() ; i ++ ) {
             node_types.insert( g_proto_split.node(i).op());
        }
       
        const char *mdl_json = "tfmodel.min.json";
#ifdef NEED_QUANTI
        const char *mdl_data = "tfdata.min.bin";
#else
        const char *mdl_data = "tfdata.bin";
#endif
       
        //输出 json和bin文件  这些json bin文件是构成mdl网络的输入条件
        dump_json(mdl_json);
        dump_with_quantification(mdl_data);
    }
    catch (const string &msg) {
        cout << msg << endl;
    }
}

这些是个人的思路,肯定有错误和不全的地方。且项目由于不可抗原因暂停了,只能当记录和参考。

tf模型训练的直接结果是.meta .data文件,.pb文件是用类似freeze.py转换而来,原
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值