重现步骤
经过训练,获取yolo11模型,使用在测试图片中,识别准确率可以达到0.9以上,置信度也高,但转换为kmodle之后,在开发板上对相同图片进行测试,置信度只有0.5多。且yolo11,640*640下,只要有识别到,置信度一直都是0.503418。320*320下,
YOLO原模型识别与kmodel识别对比
kmodel识别图像代码
from libs.YOLO import YOLO11
from libs.Utils import *
import os,sys,gc
import ulab.numpy as np
import image
if __name__=="__main__":
# 这里仅为示例,自定义场景请修改为您自己的测试图片、模型路径、标签名称、模型输入大小
img_path="/data/271.jpg"
kmodel_path="/data/best3.kmodel"
labels = ['Crane','Jeep','Car','Bus']
model_input_size=[640,640]
confidence_threshold = 0.5
nms_threshold=0.45
img,img_ori=read_image(img_path)
rgb888p_size=[img.shape[2],img.shape[1]]
# 初始化YOLO11实例
yolo=YOLO11(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()
res=yolo.run(img)
print(res,img_ori)
yolo.draw_result(res,img_ori)
yolo.deinit()
gc.collect()