File size: 1,618 Bytes
69652bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import pandas as pd
import os

# 任务类型与缩写的映射
TASK_TYPE_TO_ABBR = {
    "Object Perception": "OP",
    "Causal Reasoning": "CR",
    "Clips Summarize": "CS",          # 注意原始数据中为 "Clips Summarize"
    "Attribute Perception": "ATP",
    "Event Understanding": "EU",
    "Text-Rich Understanding": "TR",
    "Prospective Reasoning": "PR",
    "Spatial Understanding": "SU",
    "Action Perception": "ACP",
    "Counting": "CT"
}

def split_by_task_type(input_file, output_dir="."):
    """
    读取 input_file,按 task_type 分组,保存为多个 CSV 文件。
    文件名格式:Real_Time_Visual_Understanding_<缩写>.csv
    """
    # 读取 CSV
    df = pd.read_csv(input_file, encoding='utf-8')
    
    # 确保输出目录存在
    os.makedirs(output_dir, exist_ok=True)
    
    # 获取所有任务类型
    task_types = df['task_type'].unique()
    
    for task in task_types:
        # 查找缩写,如果找不到则使用原始名称(避免出错)
        abbr = TASK_TYPE_TO_ABBR.get(task, task.replace(' ', '_'))
        # 筛选数据
        sub_df = df[df['task_type'] == task]
        # 输出文件名
        out_file = os.path.join(output_dir, f"Real_Time_Visual_Understanding_{abbr}.csv")
        # 保存
        sub_df.to_csv(out_file, index=False, encoding='utf-8')
        print(f"已保存 {len(sub_df)} 条记录到 {out_file}")

if __name__ == "__main__":
    # 请根据实际文件路径修改
    input_csv = "/root/dataset/videoqa/StreamingBench/StreamingBench/Real_Time_Visual_Understanding_copy.csv"
    split_by_task_type(input_csv)