计划使用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

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}")

Logo

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。

更多推荐