k230调用图片分类检测,报错如下:

Viewed 34

问题描述


Traceback (most recent call last):
File "", line 28, in
File "/sdcard/libs/YOLO.py", line 22, in init
File "/sdcard/libs/AIBase.py", line 30, in init
EOFError: KPU load model failed from path.

新做的系统镜像,没做其他动作

复现步骤


from libs.YOLO import YOLOv5
import os,sys,gc
import ulab.numpy as np
import image

从本地读入图片,并实现HWC转CHW

def read_img(img_path):
img_data = image.Image(img_path)
img_data_rgb888=img_data.to_rgb888()
img_hwc=img_data_rgb888.to_numpy_ref()
shape=img_hwc.shape
img_tmp = img_hwc.reshape((shape[0] * shape[1], shape[2]))
img_tmp_trans = img_tmp.transpose()
img_res=img_tmp_trans.copy()
img_return=img_res.reshape((shape[2],shape[0],shape[1]))
return img_return,img_data_rgb888

if name=="main":
img_path="/data/1.jpg"
kmodel_path="/data/det.kmodel"
labels = ["a"]
confidence_threshold = 0.5
nms_threshold=0.45
model_input_size=[320,320]
img,img_ori=read_img(img_path)
rgb888p_size=[img.shape[2],img.shape[1]]
# 初始化YOLOv5实例
yolo=YOLOv5(task_type="detect",mode="image",kmodel_path=kmodel_path,labels=labels,rgb888p_size=rgb888p_size,model_input_size=model_input_size,conf_thresh=confidence_threshold,nms_thresh=nms_threshold,max_boxes_num=50,debug_mode=0)
yolo.config_preprocess()
try:
res=yolo.run(img)
yolo.draw_result(res,img_ori)
gc.collect()
except Exception as e:
sys.print_exception(e)
finally:
yolo.deinit()

1 Answers