MOT16数据集做目标检测的预处理(类别合并与清理)

计划使用MOT16数据集做基于ConvLSTM的目标检测,其标注数据在gt.txt中,第8列为分类,有以下12类

  1. Pedestrian(行人)------主要目标,要跟踪

  2. Person on vehicle(车上的人)

  3. Car(轿车)

  4. Bicycle(自行车)

  5. Motorbike(摩托车)

  6. Non motorized vehicle(非机动车)

  7. Static person(静止的人)

  8. Distractor(干扰物)

  9. Occluder(遮挡物)

  10. Occluder on the ground(地面遮挡物)

  11. Occluder full(完全遮挡)

  12. Reflection(倒影)

下面代码把1/2/7合并为1类,把3作为2类,把4/5合并为3类,其他的全部不要,生成new_gt.txt

python 复制代码
import os
import numpy as np

mot16_root = "MOT16/train"
seqs = [d for d in os.listdir(mot16_root) if os.path.isdir(os.path.join(mot16_root, d))]

for seq in seqs:
    gt_path = os.path.join(mot16_root, seq, "gt/gt.txt")
    out_path = os.path.join(mot16_root, seq, "gt/new_gt.txt")
    
    if not os.path.exists(gt_path):
        continue
    
    data = np.loadtxt(gt_path, delimiter=',')
    new_data = []
    
    for row in data:
        cls = int(row[7])
        
        if cls in [1, 2, 7]:
            row[7] = 1
            new_data.append(row)
        elif cls == 3:
            row[7] = 2
            new_data.append(row)
        elif cls in [4, 5]:
            row[7] = 3
            new_data.append(row)
    
    if new_data:
        np.savetxt(out_path, np.array(new_data), fmt='%.6g', delimiter=',')
        print(f"Saved: {out_path}")
相关推荐
aaaak_2 分钟前
Agent Harness 具体要如何设计 入门科普
人工智能·agent·harness
Java后端的Ai之路7 分钟前
07React_Props验证器
人工智能·python·react.js·架构·fastapi
chien0119 分钟前
为什么一串文字能变成一个向量?——从分布假说到语言模型的语义表示
人工智能·语言模型·自然语言处理
QYR-分析14 分钟前
54.46亿美元赛道上的毫米战争:汽车顶装式天窗如何穿越“全景化”与“标准升级”双重周期
人工智能
阿崽meitoufa17 分钟前
调研:老龄与社区服务中的AGENT
人工智能
Anhty20 分钟前
自媒体剪音频选哪个?3 款音频剪辑工具实测分享
人工智能·功能测试·音视频·媒体
AIGC小尼21 分钟前
本地 AI 漫剧流水线模型缓存与特征向量持久化:IPAdapter 预编码、特征池复用与内存池管理实战
人工智能·spring boot·缓存·预编码算法·comfyui·ai漫剧
kaixin_啊啊23 分钟前
【零基础学AI】第 9 章——安装 Python 和开发工具
人工智能·python
yichengerp26 分钟前
中小电子厂用什么ERP?电子厂ERP管理软件实施要点与易呈方案推荐
大数据·运维·人工智能·云计算·制造
枯木◊靠推文躺平版27 分钟前
Claude Code 替代品有哪些?TRAE vs Claude Code 从价格、门槛到中文开发,一篇看懂怎么选
人工智能