1 Star 0 Fork 0

Yang123321/r329_aipu_simulator

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
quant_predict.py 1.16 KB
一键复制 编辑 原始数据 按行查看 历史
Yang123321 提交于 2021-07-13 11:47 . init
from PIL import Image
import cv2
from matplotlib import pyplot as plt
import matplotlib.patches as patches
import numpy as np
import os
import imagenet_classes as class_name
current_dir = os.getcwd()
label_offset = 1
outputfile = current_dir + '/output_mobilenet_v2.bin'
npyoutput = np.fromfile(outputfile, dtype=np.uint8)
outputclass = npyoutput.argmax()
head5p = npyoutput.argsort()[-5:][::-1]
labelfile = current_dir + '/output_ref.bin'
npylabel = np.fromfile(labelfile, dtype=np.int8)
labelclass = npylabel.argmax()
head5t = npylabel.argsort()[-5:][::-1]
print("predict first 5 label:")
for i in head5p:
print(" index %4d, prob %3d, name: %s"%(i, npyoutput[i], class_name.class_names[i-label_offset]))
print("true first 5 label:")
for i in head5t:
print(" index %4d, prob %3d, name: %s"%(i, npylabel[i], class_name.class_names[i-label_offset]))
# Show input picture
print('Detect picture save to result.jpeg')
input_path = './model/input.bin'
npyinput = np.fromfile(input_path, dtype=np.int8)
image = np.clip(np.round(npyinput)+128, 0, 255).astype(np.uint8)
image = np.reshape(image, (224, 224, 3))
im = Image.fromarray(image)
im.save('result.jpeg')
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Yang123321/r329_aipu_simulator.git
git@gitee.com:Yang123321/r329_aipu_simulator.git
Yang123321
r329_aipu_simulator
r329_aipu_simulator
master

搜索帮助