#!/usr/bin/env python3 """按类别重新解压StreamingBench的zip到各自子目录""" import os import zipfile os.chdir("/mnt/tokyo-ai/gst/StreamingBench") # 类别名 -> zip文件列表 CATEGORIES = { "Anomaly_Context_Understanding": ["Anomaly Context Understanding.zip"], "Emotion_Recognition": ["Emotion Recognition.zip"], "Misleading_Context_Understanding": ["Misleading Context Understanding.zip"], "Multimodal_Alignment": ["Multimodal Alignment.zip"], "Source_Discrimination": ["Source Discrimination.zip"], "Proactive_Output": ["Proactive Output_1-25.zip", "Proactive Output_26-50.zip"], "Scene_Understanding": ["Scene Understanding_1-25.zip", "Scene Understanding_26-50.zip"], "Sequential_Question_Answering": ["Sequential Question Answering_1-25.zip", "Sequential Question Answering_26-50.zip"], } for category, zips in CATEGORIES.items(): dest = os.path.join(".", category) os.makedirs(dest, exist_ok=True) for zf_name in zips: if not os.path.exists(zf_name): print(f"跳过(不存在): {zf_name}") continue print(f"解压 {zf_name} -> {category}/", flush=True) with zipfile.ZipFile(zf_name, 'r') as zf: for member in zf.namelist(): # 跳过 __MACOSX 垃圾 if "__MACOSX" in member: continue zf.extract(member, dest) # 统计 samples = [d for d in os.listdir(dest) if d.startswith("sample_") and os.path.isdir(os.path.join(dest, d))] videos = sum(1 for s in samples if os.path.exists(os.path.join(dest, s, "video.mp4"))) print(f" -> {len(samples)} samples, {videos} videos\n", flush=True) # Real-Time Visual Understanding 已经在根目录的 sample_1~500 print("Real_Time_Visual_Understanding: 已在根目录 sample_1~500") print("\n=== 汇总 ===") for cat in CATEGORIES: path = os.path.join(".", cat) if os.path.isdir(path): samples = [d for d in os.listdir(path) if d.startswith("sample_")] print(f" {cat}: {len(samples)} samples") rtvu = [d for d in os.listdir(".") if d.startswith("sample_") and os.path.isdir(d)] print(f" Real_Time_Visual_Understanding: {len(rtvu)} samples") print("\n完成!")