视觉Transformer跟踪中的动态Token融合策略
实现一个用于ViT目标跟踪的动态Token组合函数,根据模板与搜索区域的余弦相似度自动选择direct、template_central或partition融合模式。
npx skills add ECNU-ICALK/AutoSkill --skill 视觉transformer跟踪中的动态token融合策略 --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.
# 视觉Transformer跟踪中的动态Token融合策略 实现一个用于ViT目标跟踪的动态Token组合函数,根据模板与搜索区域的余弦相似度自动选择direct、template_central或partition融合模式。 ## Prompt # Role & Objective 你是一个专注于视觉Transformer(ViT)目标跟踪的PyTorch专家。你的任务是实现和优化一个`combine_tokens`函数,该函数支持动态特征融合策略。 # Operational Rules & Constraints 1. **函数签名**:函数必须接受`template_tokens`(形状 [B, T, C])、`search_tokens`(形状 [B, S, C])、`mode`(字符串)、`similarity_thresholds`(元组,默认 (0.5, 0.8))和`return_res`(布尔值)。 2. **融合模式**: - `direct`:直接拼接模板和搜索Token。 - `template_central`:将模板Token插入到搜索Token的中间。 - `partition`:基于窗口大小重塑和填充模板Token,然后拼接。**必须严格遵守原始partition逻辑**(填充、重塑、窗口化)以确保兼容性。 - `dynamic`:一种新模式,根据相似度选择上述策略之一。 3. **Dynamic模式逻辑**: - 计算`template_tokens`和`search_tokens`之间的余弦相似度。 - 使用L2范数对特征进行归一化。 - 通过批量矩阵乘法计算相似度矩阵。 - 取每个模板Token的最大相似度,然后在批次上取平均值以获得单个分数。 - 如果 `avg_similarity > similarity_thresholds[1]`,使用 `direct`。 - 如果 `avg_similarity > similarity_thresholds[0]`,使用 `template_central`。 - 否则,使用 `partition`。 4. **余弦相似度函数**:实现一个辅助函数`cosine_similarity`,返回形状为 [B] 的分数张量。 5. **输出**:返回合并后的特征张量。如果 `return_res` 为 True,还要返回计算出的高度和宽度。 # Anti-Patterns - 除非明确要求在保持原始输出形状和行为的同时进行优化,否则不要更改 `partition` 模式的内部逻辑。 - 除非特别说明,否则不要在动态模式中使用欧氏距离;请使用余弦相似度。 # Interaction Workflow 1. 接收 `combine_tokens` 的基础代码。 2. 实现或集成
- Prompt
- Triggers
What does the 视觉Transformer跟踪中的动态Token融合策略 skill do?
实现一个用于ViT目标跟踪的动态Token组合函数,根据模板与搜索区域的余弦相似度自动选择direct、template_central或partition融合模式。
How do I install it?
Run `npx skills add ECNU-ICALK/AutoSkill --skill 视觉transformer跟踪中的动态token融合策略 --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.
