Code Monkey home page Code Monkey logo

caffe-tensorflow-tf2-py3's Introduction

Caffe to TensorFlow

Convert Caffe models to TensorFlow 2.x.

Working environment

  • Ubuntu 18.04
  • Tensorflow 2.3
  • Caffe and Pycaffe

Prerequisistes

Install caffe For Ubuntu

apt install caffe-cpu
apt install python3-caffe-cpu
pip3 install --upgrade scikit-image

Usage

Run convert.py to convert an existing Caffe model to TensorFlow.

python3 convert.py <prototxt file> --caffemodel <caffemodel file> --data-output-path <data file in numpy format> --code-output-path <filename to save graph as python class> --phase train --standalone-output-path <path to save savedmodel> --input_node <innode> --output_node <onode1>,<onode2>

Make sure you're using the latest Caffe format (see the notes section for more info).

The output consists of 3 files:

  1. A data file (in NumPy's native format) containing the model's learned parameters.
  2. A Python class that constructs the model's graph.
  3. Tensorflow SavedModel file

Notes

  • Only the new Caffe model format is supported. If you have an old model, use the upgrade_net_proto_text and upgrade_net_proto_binary tools that ship with Caffe to upgrade them first. Also make sure you're using a fairly recent version of Caffe.

  • It appears that Caffe and TensorFlow cannot be concurrently invoked (CUDA conflicts - even with set_mode_cpu). This makes it a two-stage process: first extract the parameters with convert.py, then import it into TensorFlow.

  • Pycaffe is strictly required.

  • Only a subset of Caffe layers and accompanying parameters are currently supported.

  • The border values are handled differently by Caffe and TensorFlow. However, these don't appear to affect things too much.

  • Image rescaling can affect the ILSVRC2012 top 5 accuracy listed above slightly. VGG16 expects isotropic rescaling (anisotropic reduces accuracy to 88.45%) whereas BVLC's implementation of GoogLeNet expects anisotropic (isotropic reduces accuracy to 87.7%).

  • The support class kaffe.tensorflow.Network has no internal dependencies. It can be safely extracted and deployed without the rest of this library.

Credits

  1. https://github.com/ethereon/caffe-tensorflow
  2. https://github.com/dhaase-de/caffe-tensorflow-python3
  3. https://github.com/linkfluence/caffe-tensorflow
  4. https://github.com/davidsandberg/caffe-tensorflow

caffe-tensorflow-tf2-py3's People

Contributors

sambhusuryamohan avatar ethereon avatar kyu-sz avatar raingo avatar g1910 avatar markusnagel avatar leconteur avatar sfujiwara avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.