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非最大抑制の前にグリッドセルの幅に適用される水平方向のスケール係数。値が大きいほど、隣接するセルが 1 つの検出にまとめられます。h_scale非最大抑制の前にグリッドセルの高さに適用される垂直方向のスケール係数。値が大きいほど、隣接するセルが 1 つの検出にまとめられます。nms_threshold非最大抑制に渡される IoU のしきい値。nms_sigma非最大抑制(soft-NMS)に渡されるシグマ値。
class YoloPro -- YOLO Pro#
Edge Impulse YOLO Pro 物体検出モデル出力用の後処理クラス。YOLO Pro モデルは候補ボックスごとに 1 行を出力し、各行には(入力に対して正規化された)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 の後処理関数を作成します。
thresholdnon-max-suppression の前にボックスが保持されるために必要な最小クラススコア。nms_threshold非最大抑制に渡される IoU のしきい値。nms_sigma非最大抑制(soft-NMS)に渡されるシグマ値。
例:
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)