請問K230通過kmodel如何輸出數據

Viewed 137

重现步骤

  1. 我首先通過yolo11以及自己的數據集進行訓練得到.pt,再轉化爲.kmodel,拷貝進入K230,通過YOLO大作戰裏面的.py進行運行,K230可以輸出識別物品(視訊)的圖像

期待结果和实际结果
2.我希望的是可以從K230輸出得到的視覺訊息,比如:
在00:00到00:15内,範圍内有1個蘋果和2個橘子
在00:16到00:30内,範圍内有0個蘋果和2個橘子(蘋果被拿走)
在00:31到00:45内,範圍内有1個蘋果和1個橘子(橘子被拿走,蘋果被放回)
這些訊息能被記錄並在txt文檔中并及時返回到PC裏,進而實現所需功能

软硬件版本信息
01 studio K230 開發板
YOLO11

尝试解决过程
網路上未找到怎麽在板子上得到數據並返回到PC上

补充材料
from libs.PipeLine import PipeLine, ScopedTiming
from libs.YOLO import YOLO11
import os,sys,gc
import ulab.numpy as np
import image

if name=="main":
# 显示模式,默认"hdmi",可以选择"hdmi"和"lcd"
display_mode="hdmi"
rgb888p_size=[1280,720]
if display_mode=="hdmi":
display_size=[1920,1080]
else:
display_size=[800,480]
kmodel_path="/data/best.kmodel"
labels = ["apple","orange"]
confidence_threshold = 0.8
nms_threshold=0.45
model_input_size=[320,320]
# 初始化PipeLine
pl=PipeLine(rgb888p_size=rgb888p_size,display_size=display_size,display_mode=display_mode)
pl.create()
# 初始化YOLO11实例
yolo=YOLO11(task_type="detect",mode="video",kmodel_path=kmodel_path,labels=labels,rgb888p_size=rgb888p_size,model_input_size=model_input_size,display_size=display_size,conf_thresh=confidence_threshold,nms_thresh=nms_threshold,max_boxes_num=50,debug_mode=0)
yolo.config_preprocess()
try:
while True:
os.exitpoint()
with ScopedTiming("total",1):
# 逐帧推理
img=pl.get_frame()
res=yolo.run(img)
yolo.draw_result(res,pl.osd_img)
pl.show_image()
gc.collect()
except Exception as e:
sys.print_exception(e)
finally:
yolo.deinit()
pl.destroy()

1 Answers

res就是后处理之后的数据列表,你可以通过打印看到,每一条数据中包含一个框的坐标位置,类别索引和分数,你只需要在这里添加统计的代码即可实现您需要的功能。

我現在在.py尾部添加了
print(res)
請問現在輸出結果保存在何處呢,謝謝
或者説我需要另外的指令來進行統計保存在K230的sd卡内?