NNVMError: ValueError: not enough values to unpack (expected 4, got 0)


#1

import tvm
import tvm.relay as relay
from tvm.contrib.download import download_testdata
import keras
import numpy as np
import nnvm
import nnvm.compiler

weights_url = ‘’.join([‘https://github.com/fchollet/deep-learning-models/releases/’,
‘download/v0.6/mobilenet_1_0_128_tf.h5’])
weights_file = ‘mobilenet_weights.h5’
weights_path = download_testdata(weights_url, weights_file, module=‘keras’)
keras_mobilenet = keras.applications.mobilenet.MobileNet(include_top=True,weights=‘imagenet’,
input_shape=(224, 224, 3), classes=1000)
keras_mobilenet.load_weights(weights_path)

from PIL import Image
from matplotlib import pyplot as plt
from keras.applications.mobilenet import preprocess_input
img_url = ‘https://github.com/dmlc/mxnet.js/blob/master/data/cat.png?raw=true
img_path = download_testdata(img_url, ‘cat.png’, module=‘data’)
img = Image.open(img_path).resize((224, 224))
data = np.array(img)[np.newaxis, :].astype(‘float32’)
data = preprocess_input(data).transpose([0, 3, 1, 2])
print(‘input_1’, data.shape)
plt.imshow(img)
plt.show()

target = ‘llvm’
ctx = tvm.cpu()

Compile with nnvm

sym, params = nnvm.frontend.from_keras(keras_mobilenet)
shape_dict = {‘input_1’: data.shape}

print(shape_dict)
with nnvm.compiler.build_config(opt_level=3):
graph, lib, params = nnvm.compiler.build(sym, target, shape_dict, params=params)