本帖最后由 tof3d 于 2019-3-6 10:49 编辑
转换
rknn.config(channel_mean_value='0 0 0 255', reorder_channel='0 1 2')
ret = rknn.load_caffe(model='..C_deploy_new.prototxt', proto='caffe', blobs='../C_new.caffemodel')
if ret != 0:
print('Load mobilenet_v2 failed! Ret = {}'.format(ret))
exit(ret)
print('done')
# Build model
print('--> Building model')
print('--> Building model')
rknn.build(do_quantization=False)
print('done')
测试
img = cv2.imread('./ec1.jpg')
#img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
#img=cv2.resize(img,(128,128))
img2 = cv2.imread('./ec2.jpg')
#img2 = cv2.cvtColor(img2, cv2.COLOR_BGR2RGB)
img2 = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY)
img=cv2.resize(img,(128,128))
img2=cv2.resize(img2,(128,128))
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])
outputs = rknn.inference(inputs=[img]) |