此页面由 AI 自动翻译。查看英文原版
最后更新

本页目录

  • 类
  • FOMOVisualizer
Claude CodeCodexCursor
Luxonis 智能体工具包为你常用的编程智能体加载 Luxonis 上下文与技能,更快地基于 OAK 开发应用。
安装工具包

fomo_visualizer

最后更新
Python API: luxonis_train.attached_modules.visualizers.fomo_visualizer绘制 FOMO 头预测的点和目标框。

类

FOMOVisualizer

将 FOMO 热图检测可视化为点和可选框。
https://raw.githubusercontent.com/luxonis/luxonis-train/e542cf0efa20a0fc5c781ff505d699031cb0d228/media/example_viz/fomo_parking_lot.png
停车场中的预测点。每个类别都有自己的颜色。
  • 输入::
    • prediction_canvas, target_canvas (Tensor): [B, 3, H, W]
    • keypoints (list[Tensor]): 每张图像 [Ki, 1, 4],(x, y, prob, class),像素
    • target_boundingbox (Tensor | None): [N, 6],[batch, class, x, y, w, h],xywh 归一化
  • 输出::
    • Tensor | tuple[Tensor, Tensor]: [B, 3, H, W],给定目标时为一对

方法

init
Python
1def __init__(visibility_threshold: float = 0.5, radius: int = 5, **kwargs):
初始化可视化器并存储点选项。参数
  • visibility_threshold (float): 点的最小概率。draw_predictions_per_class 会跳过低于此值的点。forward 对于具有三个值的点会忽略它。默认为 0.5。
  • radius (int): 绘制点的半径,以像素为单位。默认为 5。
  • **kwargs: 转发给 BBoxVisualizer 的关键字参数,例如 labels、colors、scale 和 node。
draw_predictions_per_class
Python
1def draw_predictions_per_class(canvas: Tensor, predictions: list[Tensor]) -> Tensor:
绘制按类别着色的批次预测点。对于每张图像,该方法通过 scale 因子缩放坐标,并保留概率至少为 visibility_threshold 的点。然后将其钳制到图像中,并使用 torchvision.utils.draw_keypoints 绘制。类别采用 colors 中其名称的颜色,如果名称没有颜色则为白色。参数
  • canvas (Tensor): 形状为 [B, 3, H, W] 的 uint8 图像。该方法不会修改它。
  • predictions (list[Tensor]): 每张图像一个张量,形状为 [K_i, 1, 4],行格式为 (x, y, prob, class),以像素为单位。
返回
  • Tensor: 绘制了点的 canvas 副本。
forward
Python
1def forward(prediction_canvas: Tensor, target_canvas: Tensor, keypoints: list[Tensor], target_boundingbox: Tensor | None) -> tuple[Tensor, Tensor] | Tensor:
绘制预测点,并在给定目标时绘制目标框。当 keypoints 中的每个张量每个点有三个值时,该方法使用 KeypointVisualizer.draw_predictions 和 radius 以红色绘制点。该调用会忽略 visibility_threshold 和 scale 因子。它会在坐标处绘制概率至少为 0.5 的点,并在左上角绘制任何其他点。否则,该方法会调用 draw_predictions_per_class,它会按类别着色点并应用 visibility_threshold 和 scale 因子。FOMOHead 总是为每个点生成四个值,因此其输出会走第二条路径。参数
  • prediction_canvas (Tensor): 形状为 [B, 3, H, W] 的 uint8 图像,用于绘制点。
  • target_canvas (Tensor): 形状为 [B, 3, H, W] 的 uint8 图像,用于绘制目标框。
  • keypoints (list[Tensor]): 每张图像一个张量,形状为 [K_i, 1, 4],行格式为 (x, y, prob, class),以像素为单位;或者形状为 [K_i, 1, 3],不包含类别。
  • target_boundingbox (Tensor | None): 形状为 [N, 6] 的框,行格式为 [batch_index, class, x, y, w, h],xywh 归一化到 [0, 1]。当批次没有 boundingbox 标签时为 None。
返回
  • tuple[Tensor, Tensor] | Tensor: 当 target_boundingbox 不为 None 时,返回绘制图像的对 (targets, predictions);否则只返回预测图像。

属性

supported_tasks