|
rknn-toolkit2 的模型转换如下
import numpy as np
import re
import math
import random
import cv2
from rknn.api import RKNN
if __name__ == '__main__':
INPUT_SIZE = 160
rknn = RKNN(verbose=True)
# Config for Model Input PreProcess
#rknn.config(channel_mean_value='0 0 0 1', reorder_channel='0 1 2',target_platform=['rv1126'])
rknn.config(mean_values=[127.5, 127.5, 127.5], std_values=[127.5, 127.5, 127.5])
#rknn.config(channel_mean_value='0 0 0 1', reorder_channel='0 1 2')
print('config done')
# load tensorflow model
print('--> Loading model')
#out = 'InceptionResnetV1/Bottleneck/BatchNorm/batchnorm/add_1'
#out = "InceptionResnetV1/Bottleneck/BatchNorm/cond_1/AssignMovingAvg_1/Switch"
out = "InceptionResnetV1/Bottleneck/BatchNorm/Reshape_1"
#out = "embeddings"
rknn.load_tensorflow(tf_pb='20180402-114759/20180402-114759.pb',
#inputs=['input','phase_train'],
inputs=['input'],
outputs=[out],
input_size_list=[[INPUT_SIZE, INPUT_SIZE, 3]])
#input_size_list=[[INPUT_SIZE, INPUT_SIZE, 3], [1]])
print('done')
# Build Model
print('--> Building model')
ret = rknn.build(do_quantization=True, dataset='./dataset.txt')
#ret = rknn.build(do_quantization=False)
print('done')
# Export RKNN Model
rknn.export_rknn('./facenet_Reshape_1_two.rknn')
rknn.release()
rknn-toolkit的换换如下
import numpy as np
import re
import math
import random
import cv2
from rknn.api import RKNN
if __name__ == '__main__':
INPUT_SIZE = 160
rknn = RKNN(verbose=True)
# Config for Model Input PreProcess
#rknn.config(channel_mean_value='0 0 0 1', reorder_channel='0 1 2',target_platform=['rv1126'])
#rknn.config(mean_values=[127.5, 127.5, 127.5], std_values=[127.5, 127.5, 127.5])
rknn.config(channel_mean_value='0 0 0 1', reorder_channel='0 1 2')
print('config done')
# load tensorflow model
print('--> Loading model')
#out = 'InceptionResnetV1/Bottleneck/BatchNorm/batchnorm/add_1'
#out = "InceptionResnetV1/Bottleneck/BatchNorm/cond_1/AssignMovingAvg_1/Switch"
out = "InceptionResnetV1/Bottleneck/BatchNorm/Reshape_1"
#out = "embeddings"
rknn.load_tensorflow(tf_pb='20180402-114759/20180402-114759.pb',
#inputs=['input','phase_train'],
inputs=['input'],
outputs=[out],
input_size_list=[[INPUT_SIZE, INPUT_SIZE, 3]])
print('done')
# Build Model
print('--> Building model')
#ret = rknn.build(do_quantization=True, dataset='./dataset.txt')
rknn.build(do_quantization=False)
print('done')
# Export RKNN Model
rknn.export_rknn('./facenet_Reshape_1_two.rknn')
rknn.release() |
|