Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.
6404 Discussions

Conversion from Tensorflow model to Intel Movidius Graph error

idata
Employee
813 Views

Hello! I've got problem with conversion of tensorflow model to movidius graph. Initially model was designed in keras then I convert it to tensorflow and finally to movidius graph. I' ve got following error:

 

[Error 5] Toolkit Error: Stage Details Not Supported: IsVariableInitialized

 

Here is the code for conversion:

 

import nn import os square_width = 16 square_height = 16 classes_num = 9 model = nn.alexnet_model((square_width, square_height, 3)) model.load_weights('weights.h5') with open("model.json", "w") as file: file.write(model.to_json()) from keras.models import model_from_json from keras import backend as K import tensorflow as tf model_file = "model.json" weights_file = "weights.h5" with open(model_file, "r") as file: config = file.read() K.set_learning_phase(0) model = model_from_json(config) model.load_weights(weights_file) saver = tf.train.Saver() sess = K.get_session() saver.save(sess, "./TF_Model/tf_model") fw = tf.summary.FileWriter('logs', sess.graph) fw.close() os.system('mvNCCompile ./TF_Model/tf_model.meta -in=conv2d_1_input -on=activation_7/Softmax') # get Movidius graph

 

That's how I define the model:

 

def alexnet_model(img_shape=(256, 256, 3), n_classes=9, l2_reg=0.,weights=None): ### taken from https://github.com/eweill/keras-deepcv/blob/master/models/classification/alexnet.py ### # Initialize model alexnet = Sequential() # Layer 1 alexnet.add(Conv2D(96, (11, 11), input_shape=img_shape, padding='same', kernel_regularizer=l2(l2_reg))) alexnet.add(BatchNormalization()) alexnet.add(Activation('relu')) alexnet.add(MaxPooling2D(pool_size=(2, 2))) # Layer 2 alexnet.add(Conv2D(256, (5, 5), padding='same')) alexnet.add(BatchNormalization()) alexnet.add(Activation('relu')) alexnet.add(MaxPooling2D(pool_size=(2, 2))) # Layer 3 alexnet.add(ZeroPadding2D((1, 1))) alexnet.add(Conv2D(512, (3, 3), padding='same')) alexnet.add(BatchNormalization()) alexnet.add(Activation('relu')) alexnet.add(MaxPooling2D(pool_size=(2, 2))) # Layer 4 alexnet.add(ZeroPadding2D((1, 1))) alexnet.add(Conv2D(1024, (3, 3), padding='same')) alexnet.add(BatchNormalization()) alexnet.add(Activation('relu')) # Layer 5 #alexnet.add(ZeroPadding2D((1, 1))) #alexnet.add(Conv2D(1024, (3, 3), padding='same')) #alexnet.add(BatchNormalization()) #alexnet.add(Activation('relu')) #alexnet.add(MaxPooling2D(pool_size=(2, 2))) # Layer 6 alexnet.add(Flatten()) alexnet.add(Dense(3072)) alexnet.add(BatchNormalization()) alexnet.add(Activation('relu')) alexnet.add(Dropout(0.5)) # Layer 7 alexnet.add(Dense(4096)) alexnet.add(BatchNormalization()) alexnet.add(Activation('relu')) alexnet.add(Dropout(0.5)) # Layer 8 alexnet.add(Dense(n_classes)) alexnet.add(BatchNormalization()) alexnet.add(Activation('softmax')) if weights is not None: alexnet.load_weights(weights) return alexnet

 

OS: Ubuntu 16.04

 

Pyhon version: 3.5.2

 

Tensorflow version 1.12.0

 

Keras version: 2.2.0

 

NCSDK version: 1.12.01.01
0 Kudos
0 Replies
Reply