|
5#
楼主 |
发表于 2020-6-12 13:44:42
|
只看该作者
#coding:utf-8
import numpy as np
import cv2
from rknn.api import RKNN
import math
def sigd(x):
return 1/(1 +math.exp(-x))
img = cv2.imread('bike.jpg')
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
img = cv2.resize(img, (512,512), interpolation=cv2.INTER_CUBIC)
rknn = RKNN()
#rknn.config(channel_mean_value='0 0 0 0.003902', reorder_channel='2 1 0')
ret = rknn.load_rknn(path='bike.rknn')
if ret!=0:
print('load rknn fail')
print('--> Init runtime ')
ret = rknn.init_runtime()
if ret != 0:
print('Init runtime fail')
exit()
import time
start_time=time.time()
print('--> Running model ')
outputs = rknn.inference(inputs=[img])
end_time=time.time()
end_time=end_time-start_time
raw_res=outputs[0]
print(raw_res.shape,type(raw_res[0]),raw_res.size) |
|