|
地板
楼主 |
发表于 2019-4-12 16:50:12
|
只看该作者
你们给出的demo中仍然只有两个输出节点,而且没有基于caffe模型的,如下,第三个节点数据使用的是文本文件静态导入的prior box,我不太清楚这样做的原因?
# Create RKNN object
rknn = RKNN()
# Config for Model Input PreProcess
rknn.config(channel_mean_value='128 128 128 128', reorder_channel='0 1 2')
# Load TensorFlow Model
print('--> Loading model')
rknn.load_tensorflow(tf_pb='./ssd_mobilenet_v1_coco_2017_11_17.pb',
inputs=['FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_0/BatchNorm/batchnorm/mul_1'],
outputs=['concat', 'concat_1'],
input_size_list=[[INPUT_SIZE, INPUT_SIZE, 3]])
print('done')
# Build Model
print('--> Building model')
rknn.build(do_quantization=True, dataset='./dataset.txt')
print('done')
# Export RKNN Model
rknn.export_rknn('./ssd_mobilenet_v1_coco.rknn')
# Direct Load RKNN Model
# rknn.load_rknn('./ssd_mobilenet_v1_coco.rknn')
# Set inputs
orig_img = cv2.imread('./road.bmp')
img = cv2.cvtColor(orig_img, cv2.COLOR_BGR2RGB)
img = cv2.resize(img, (INPUT_SIZE, INPUT_SIZE), interpolation=cv2.INTER_CUBIC)
# init runtime environment
print('--> Init runtime environment')
ret = rknn.init_runtime()
if ret != 0:
print('Init runtime environment failed')
exit(ret)
print('done')
# Inference
print('--> Running model')
outputs = rknn.inference(inputs=[img])
print('done')
print('inference result: ', outputs)
predictions = outputs[1].reshape((1, NUM_RESULTS, 4))
outputClasses = outputs[0].reshape((1, NUM_RESULTS, NUM_CLASSES))
box_priors = load_box_priors() |
|