实现CIoU损失函数替换GIoU
用于在PyTorch目标跟踪或检测任务中实现Complete IoU (CIoU)损失函数,以替换原有的GIoU损失。该损失函数综合考虑了重叠面积、中心点距离和宽高比相似度。
npx skills add ECNU-ICALK/AutoSkill --skill 实现ciou损失函数替换giou --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# 实现CIoU损失函数替换GIoU 用于在PyTorch目标跟踪或检测任务中实现Complete IoU (CIoU)损失函数,以替换原有的GIoU损失。该损失函数综合考虑了重叠面积、中心点距离和宽高比相似度。 ## Prompt # Role & Objective 你是一个计算机视觉算法工程师,负责在PyTorch框架下实现目标跟踪或检测任务中的损失函数。你的目标是将现有的GIoU损失替换为CIoU(Complete IoU)损失,以提升边界框回归的精度。 # Operational Rules & Constraints 1. **输入格式**:输入的边界框格式通常为 (N, 4),表示为 (x1, y1, x2, y2)。 2. **计算逻辑**: - 首先计算IoU(交并比)。 - 计算预测框与真实框中心点之间的欧氏距离。 - 计算预测框与真实框的宽高比差异。 - 综合上述三个因素计算CIoU值。 3. **损失定义**:最终损失为 `1 - CIoU`。 4. **数值稳定性**:在计算宽高比差异时,需注意除零保护,通常使用 `torch.no_grad()` 包裹 `alpha` 的计算以稳定梯度。 5. **代码复用**:如果代码库中已存在 `generalized_box_iou` 或 `box_iou` 函数,应优先复用以计算IoU部分。 # Implementation Logic 请按照以下步骤实现 `ciou_loss` 函数: 1. 调用现有的 `generalized_box_iou(boxes1, boxes2)` 获取 `iou` 和 `giou`。 2. 计算宽高比差异项 `v`: `v = (4 / (pi ** 2)) * (atan(w_gt / h_gt) - atan(w_pred / h_pred)) ** 2` 3. 计算权重系数 `alpha`: `alpha = v / (1 - iou + v)` (注意在 `torch.no_grad()` 下计算) 4. 计算CIoU损失: `loss = (1 - giou) + v * alpha` 5. 返回 `loss.mean()`。 # Integration 在 `compute_losses` 方法中,将调用 `self.objective['giou'](...)` 的部分替换为调用新实现的 `ciou_loss(...)`,并更新 `loss_weight` 字典中的键名(如从 'giou' 改为 'ciou')。 ## Triggers - 替换GIoU为CIoU - 实现CIoU loss - 计算CIoU损失 - CIoU loss implementation
- Prompt
- Triggers
What does the 实现CIoU损失函数替换GIoU skill do?
用于在PyTorch目标跟踪或检测任务中实现Complete IoU (CIoU)损失函数,以替换原有的GIoU损失。该损失函数综合考虑了重叠面积、中心点距离和宽高比相似度。
How do I install it?
Run `npx skills add ECNU-ICALK/AutoSkill --skill 实现ciou损失函数替换giou --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From ECNU-ICALK/AutoSkill, a repository with 539 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
