ml.postprocessing.edgeimpulse --- Edge Impulse#
ml.postprocessing.edgeimpulse 模块包含用于 Edge Impulse 模型的后处理类。
class Fomo -- Fast Objects More Objects#
FOMO(Fast Objects More Objects)模型输出的后处理器。
- class ml.postprocessing.edgeimpulse.Fomo(threshold: float = 0.4, w_scale: float = 1.414214, h_scale: float = 1.414214, nms_threshold: float = 0.1, nms_sigma: float = 0.001)#
创建一个 FOMO 后处理器。
threshold保留一个检测结果所需的最低分数。w_scale在非极大值抑制之前应用于网格单元宽度的水平缩放因子。较大的值会导致相邻单元被合并为单个检测结果。h_scale在非极大值抑制之前应用于网格单元高度的垂直缩放因子。较大的值会导致相邻单元被合并为单个检测结果。nms_threshold传递给非极大值抑制的 IoU 阈值。nms_sigma传递给非极大值抑制(soft-NMS)的 sigma 值。
class YoloPro -- YOLO Pro#
Edge Impulse YOLO Pro 目标检测模型输出的后处理器。YOLO Pro 模型为每个候选框输出一行,其中包含 xmin, ymin, xmax, ymax(已归一化到输入尺寸),其后是逐类别的分数向量。关于如何训练此类模型,请参阅 YOLO Pro 文档。
- class ml.postprocessing.edgeimpulse.YoloPro(threshold: float = 0.6, nms_threshold: float = 0.1, nms_sigma: float = 0.1)#
创建一个 YOLO Pro 后处理器。
threshold在非极大值抑制之前保留一个框所需的最低类别分数。nms_threshold传递给非极大值抑制的 IoU 阈值。nms_sigma传递给非极大值抑制(soft-NMS)的 sigma 值。
示例:
import csi
import ml
from ml.postprocessing.edgeimpulse import YoloPro
csi0 = csi.CSI()
csi0.reset()
csi0.pixformat(csi.RGB565)
csi0.framesize(csi.VGA)
model = ml.Model("/rom/<model_file_name>", postprocess=YoloPro(threshold=0.4))
while True:
img = csi0.snapshot()
for i, detections in enumerate(model.predict([img])):
for (x, y, w, h), score in detections:
img.draw_rectangle(x, y, w, h)
print(model.labels[i], score)