参考

https://github.com/Microsoft/MMdnn/blob/master/mmdnn/conversion/tensorflow/README.md#how-to-prepare-your-model-and-conversion-parameters

查看可用模型:

How to prepare your model and conversion parameters

You can refer Slim Model Extractor to extract your own tensorflow model, which is a sample tool to extract both architecture and weights from slim pre-trained models.

$ mmdownload -f tensorflowSupport frameworks: ['inception_v3_frozen', 'resnet_v2_200', 'inception_v1', 'mobilenet_v1_1.0', 'mobilenet_v2_1.0_224', 'resnet_v2_152', 'vgg16', 'mobilenet_v1_1.0_frozen', 'resnet_v1_50', 'resnet_v2_50', 'inception_v3', 'inception_resnet_v2', 'resnet_v1_152', 'inception_v1_frozen', 'vgg19', 'nasnet-a_large']

有几条路:

1. ckpt 转

Checkpoint File Conversion

We will give an example to convert TensorFlow resnet slim model with checkpoint files to caffe.

# Download TensorFlow pre-trained model first
$ mmdownload -f tensorflow -n resnet_v2_152Downloading file [./resnet_v2_152_2017_04_14.tar.gz] from [http://download.tensorflow.org/models/resnet_v2_152_2017_04_14.tar.gz]
100% [......................................................................] 675629399 / 675629399
Model saved in file: ./imagenet_resnet_v2_152.ckpt# Convert the TensorFlow model to Caffe
$ mmconvert -sf tensorflow -in imagenet_resnet_v2_152.ckpt.meta -iw imagenet_resnet_v2_152.ckpt --dstNodeName MMdnn_Output -df caffe -om tf_resnet
.
.
Caffe model files are saved as [tf_resnet.prototxt] and [tf_resnet.caffemodel], generated by [203e03ef187a42f59942737dace8773d.py] and [203e03ef187a42f59942737dace8773d.npy].

-in is used to specify the ".ckpt.meta" file.

-iw is used to specify the ".ckpt" file.

--dstNodeName is used to specify the output node of your model, which can be found in your code or tensorboard graph. We provide a tool vis_meta to help visualize your meta graph.

2. frozen pb 转

We will give an example to convert TensorFlow mobilenet slim model with frozen_pb to caffe

# Download TensorFlow pre-trained model first
$ mmdownload -f tensorflow -n mobilenet_v1_1.0_frozenDownloading file [mobilenet_v1_1.0_224_frozen.tgz] from [https://storage.googleapis.com/download.tensorflow.org/models/mobilenet_v1_1.0_224_frozen.tgz]
progress: 18712.0 KB downloaded, 100%k# Convert the TensorFlow model to Caffe
$ mmconvert -sf tensorflow -iw mobilenet_v1_1.0_224/frozen_graph.pb --inNodeName input --inputShape 224,224,3 --dstNodeName MobilenetV1/Predictions/Softmax -df caffe -om tf_mobilenet
.
.
Caffe model files are saved as [tf_mobilenet.prototxt] and [tf_mobilenet.caffemodel], generated by [e96550a4c55141afa8cd94372b858613.py] and [e96550a4c55141afa8cd94372b858613.npy].

For frozen graph parser, --inNodeName and --inputShape are required, and don't need to set -in.

3. debug 模式一步一步来

Step-by-step conversion for debugging

We will give an example to convert TensorFlow mobilenet slim model with frozen_pb to caffe.

# Convert frozen graph to IR
$ mmtoir -f tensorflow -w mobilenet_v1_1.0_224/frozen_graph.pb --inNodeName input --inputShape 224,224,3 --dstNodeName MobilenetV1/Predictions/Softmax -o mobilenet_v1IR network structure is saved as [mobilenet_v1.json].
IR network structure is saved as [mobilenet_v1.pb].
IR weights are saved as [mobilenet_v1.npy].# Convert IR to Caffe network building code
$ mmtocode -f caffe -n mobilenet_v1.pb -w mobilenet_v1.npy -o tf_mobilenet.py -ow tf_mobilenet.npyParse file [mobilenet_v1.pb] with binary format successfully.
Target network code snippet is saved as [tf_mobilenet.py].
Target weights are saved as [tf_mobilenet.npy].# Use Caffe network building code to generate an original Caffe model
$ mmtomodel -f caffe -in tf_mobilenet.py -iw tf_mobilenet.npy -o tf_mobilenet
.
.
.
Caffe model files are saved as [tf_mobilenet.prototxt] and [tf_mobilenet.caffemodel], generated by [tf_mobilenet.py] and [tf_mobilenet.npy].

The you can use tf_mobilenet.prototxt and tf_mobilenet.caffemodel in Caffe directly.

第三个方法的好处是,如果前两条路出现cuda error,可以用debug模式一步一步来减轻GPU的负担从而解决问题。

常见问题是

DummyData 出现 "'LayerParameter' object has no attribute 'shape'" 在 _to_proto 的时候,

解决办法:caffe在dummydata 进行了更新,我们也需要更新caffe并重新 make pycaffe

mmdnn tensorflow 转 caffe相关推荐

  1. 深度学习框架TensorFlow、Caffe、MXNet、PyTorch如何抉择?6 位大咖现身说法

    2017 年 6 月,EGO 邀请了 6 位行业大咖,聚焦深度学习框架选择与应用实战,进行了近 3 小时的在线探讨.本文根据当天内容精编而成.6位参与人分别是(排名不分先后): 彭垚-七牛人工智能实验 ...

  2. DL框架:主流深度学习框架(TensorFlow/Pytorch/Caffe/Keras/CNTK/MXNet/Theano/PaddlePaddle)简介、多个方向比较、案例应用之详细攻略

    DL框架:主流深度学习框架(TensorFlow/Pytorch/Caffe/Keras/CNTK/MXNet/Theano/PaddlePaddle)简介.多个方向比较.案例应用之详细攻略 目录 深 ...

  3. TensorFlow 、Caffe等9大人工智能框架对比介绍

    TensorFlow .Caffe等9大人工智能框架对比介绍. Tensor Flow https://www.tensorflow.org Tensor Flow来自谷歌家族,是一个强大的开源框架, ...

  4. Ubuntu16.04 安装 CUDA、CUDNN、OpenCV 并用 Anaconda 配置 Tensorflow 和 Caffe 详细过程

    Ubuntu16.04 安装 CUDA.CUDNN.OpenCV 并用 Anaconda 配置 Tensorflow 和 Caffe 详细过程 1.配置环境 Ubuntu16.04 64-bit系统 ...

  5. Tensorflow,pytorch,Caffe,MXNet,PaddlePaddle,THeano算法框架哪家强?

    深度学习平台介绍 这里将详细介绍目前应用最广泛的7种深度学习平台(包括 Tensorflow. Caffe. Pytorch.MXNet.CNTK. Paddlepaddle.Darknet)的基本原 ...

  6. 深度学习框架(如:Pytorch、Tensorflow、Caffe...)

    文章目录 一.深度学习框架由来 二.各个深度学习框架 2.1.TensorFlow(Google) 2.2.Theano(蒙特利尔大学) 2.3.Torch(NYU/Facebook) 2.4.PyT ...

  7. TensorFlow和Caffe、MXNet、Keras等其他深度学习框架的对比

    2019独角兽企业重金招聘Python工程师标准>>> TensorFlow和Caffe.MXNet.Keras等其他深度学习框架的对比 博客分类: 深度学习 Google 近日发布 ...

  8. 飞桨上线万能转换小工具,教你玩转TensorFlow、Caffe等模型迁移

    百度推出飞桨(PaddlePaddle)后,不少开发者开始转向国内的深度学习框架.但是从代码的转移谈何容易,之前的工作重写一遍不太现实,成千上万行代码的手工转换等于是在做一次二次开发. 现在,有个好消 ...

  9. Tensorflow和Caffe 简介

    TensorFlow TensorFlow 是相对高阶的机器学习库,用户可以方便地用它设计神经网络结构,而不必为了追求高效率的实现亲自写 C++或 CUDA 代码.它和 Theano 一样都支持自动求 ...

最新文章

  1. 使用inno setup打包程序完整脚本(.net框架检测,重复安装检测)
  2. SuperMap iClient for Leaflet入门学习
  3. html导航条置顶,jquery导航菜单栏固定悬浮顶部实现效果
  4. 一站式服务!图片+代码-构建移动版旅游网站页面
  5. Mozilla工程师观点:开源不赚钱,因为它不是为赚钱而设计的
  6. 批量设置 style
  7. 本月 Windows Mobile 文章推荐
  8. UVA 12904 Load Balancing 暴力
  9. Go embed 简明教程
  10. Android 系统(269)---native保活5.0以上方案推演过程以及代码详述
  11. 【专栏精选】Unity中的HTTP网络通信
  12. grafana和zabbix的端口映射
  13. LoadRunner 中的 Unique Number 参数类型小结
  14. 【渝粤教育】国家开放大学2019年春季 2727税收基础 参考试题
  15. sans webcast
  16. 利用workbench建立的响应面模型质量很差,该如何解决?求指点
  17. 设计模式-行为型软件设计模式(六)
  18. Netron可视化网络结构
  19. java 指纹匹配算法_java指纹识别的精确算法——SIFT算法 | 学步园
  20. python存csv中文乱码问题

热门文章

  1. 一套完整的导视设计案例_色彩导视艺术:乌克兰基辅语言学校导视设计案例
  2. mysql申请审核系统_Mysql审核工具archery
  3. 合流超几何函数_【初中数学大招流】从平面几何到解析几何
  4. python中return和printf的区别_Python格式化输出:%s和format()用法比较
  5. 查看操作系统版本linux_LINUX操作系统常用操作收录(二):查看文件内容命令小结...
  6. 2个网页跳来跳去_好人网页同步器,使用教程
  7. 通过这个方法竟然可以看到声音传播的速度!?
  8. 嫁给我好吗?| 今日最佳
  9. 逻辑回归算法背后的数学
  10. dbeaver 数据转化 mapping_Python机器学习实例:数据竞赛-足球运动员身价估计