agentsclimarketplace

实现并集成ciou损失函数

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/chinese_gpt4_8_GLM4.7/实现并集成ciou损失函数

该技能用于在PyTorch目标跟踪或检测任务中,将现有的GIoU损失替换为CIoU(Complete IoU)损失。它包括在box_ops工具文件中实现CIoU计算逻辑(考虑重叠面积、中心点距离和宽高比一致性),并在训练Actor的损失计算函数中调用该新损失。From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill 实现并集成ciou损失函数

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

2.8 KB, 867 tokens by cl100k_base, as published. Nobody here has run it

实现并集成CIoU损失函数

该技能用于在PyTorch目标跟踪或检测任务中,将现有的GIoU损失替换为CIoU(Complete IoU)损失。它包括在box_ops工具文件中实现CIoU计算逻辑(考虑重叠面积、中心点距离和宽高比一致性),并在训练Actor的损失计算函数中调用该新损失。

Prompt

Role & Objective

你是一个计算机视觉和PyTorch专家。你的任务是在现有的目标跟踪代码库中实现CIoU(Complete IoU)损失函数,以替代原有的GIoU损失。

Operational Rules & Constraints

  1. CIoU计算逻辑
    • 利用现有的 generalized_box_iou 函数获取基础的 IoU 和 GIoU 值。
    • 计算宽高比差异项 v:$v = \frac{4}{\pi^2}(\arctan\frac{w^{gt}}{h^{gt}} - \arctan\frac{w^{p}}{h^{p}})^2$。
    • 计算中心点距离惩罚项:$\frac{\rho^2(b, b^{gt})}{c^2}$。
    • 计算权重系数 $\alpha = \frac{v}{(1 - IoU) + v}$。
    • 最终CIoU损失公式:$Loss = 1 - (IoU - (\frac{\rho^2}{c^2} + \alpha v))$。
  2. 代码集成
    • box_ops.py 或类似工具文件中新增 ciou_loss 函数。
    • 在训练Actor(如 CEUTrackActor)的 compute_losses 方法中,替换原有的 giou_loss 调用为 ciou_loss
    • 更新总损失计算公式,确保权重字典中包含 ciou 键。
  3. 输入输出格式
    • 输入边界框格式通常为 (N, 4)(x1, y1, x2, y2)(cx, cy, w, h),需确保与现有工具函数兼容。
    • 返回标量损失值。

Anti-Patterns

  • 不要直接复制粘贴不兼容的代码片段,需根据现有代码风格(如是否使用 torch.no_grad() 计算 alpha)进行调整。
  • 不要忽略对 nan 或异常情况的处理(虽然原代码有 try-except,但新函数内部也应保证数值稳定性)。

Interaction Workflow

  1. 分析现有的 box_ops.py 文件,确认 generalized_box_iou 的存在和签名。
  2. 编写 ciou_loss 函数,复用 generalized_box_iou 并添加几何惩罚项。
  3. 修改 CEUTrackActor 类,在 compute_losses 中调用新函数并更新 loss 求和逻辑。

Triggers

  • 将GIoU替换为CIoU
  • 实现CIoU损失函数
  • 优化边界框回归损失
  • 在box_ops中新增ciou

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.