Convert Keras model to Intel Movidius NCS graph file, using NCSDK 2.x.
Official Web Page: developer.movidius.com
Intel® Movidius™ Neural Compute SDK(NCSDK 2.x): github
keras2graph process turn used TensorFlow backend Keras models to NCS graph.
Converts Keras model and weights to Intel Movidius technology internal compiled format.
Keras Model -> TensorFlow Session -> TensorFlow Meta File -> NCS Graph
Important: You need to install NCSDK 2.x.
keras2graph.py [-h] [--output_graph OUTPUT_GRAPH] [--take_tf_files]
[--shaves SHAVES]
[--do_profile] [--verbose]
model_path model_in model_out weights_path
This command creates and saves graph file as <OUTPUT_GRAPH>, default is './graph'.
model_path: Model location. Json file. Data Type: Stringmodel_in: Name of model's input layer. Data Type: Stringmodel_out: Name of model's output layer. Data Type: Stringweights_path: Model weights files location. Data Type: Stringoutput_graph: Location of output Intel Movidius technology internal compiled format graph. Data Type: Stringtake_tf_files: If you don't want to delete created TensorFlow model files(meta file inside), selectFalse. Data Type: Boolshaves: The number of available SHAVEs depends on your neural compute device. Data Type: Intdo_profile: Run mvNCProfile before mvNCCompile. Data Type: Boolverbose: Show model details. Data Type: Bool
python3 keras2graph.py keras_model/model_CNN_1.json conv2d_1_input activation_5/Softmax keras_model/weights-best_CNN_1.h5 -o keras_model/CNN.graph --shaves=12 --do_profile
Use pred_cpu.py for prediction on CPU, and use pred_movidius.py for prediction on Intel Movidius.
for Intel Movidius:
python3 pred_movidius.py keras_model/CNN.graph ./img 64
for CPU:
python3 pred_cpu.py keras_model/model_CNN_1.json keras_model/weights-best_CNN_1.h5 ./img 64
- Install necessary modules with
sudo pip3 install -r requirements.txtcommand.