Datasets:
add scripts for processing ego4d and json to tsv (#3)
Browse files- Update PR with scripts and README.md (4ed93295058fd0c4f73670d530d0ae36692ae6d2)
Co-authored-by: Chun-Hsiao Yeh <danielchyeh@users.noreply.huggingface.co>
Files changed (4)
- README.md+114
- folder_list.txtAdded+83
- scripts/json2tsv_pair.pyAdded+60
- scripts/process_ego4d_exo.pyAdded+89
16 unmodified lines1718192021228 unmodified lines31323334353616 unmodified lines# Dataset Card for All-Angles Bench## Dataset Description<!-- Provide a longer summary of what this dataset is. -->8 unmodified lines- **[Ego-Exo4D](https://github.com/facebookresearch/Ego4d)** - Large-scale egocentric and exocentric video dataset for multi-person interaction understanding## Usage```python16 unmodified lines171819202122232425262728293031323334353637383940414243448 unmodified lines535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915016 unmodified lines# Dataset Card for All-Angles Bench## Dataset Description<!-- Provide a longer summary of what this dataset is. -->The dataset presents a comprehensive benchmark consistin---license: mitlanguage:- ensize_categories:- 1K<n<10K---<h1>Seeing from Another Perspective: Evaluating Multi-View Understanding in MLLMs</h1><a href='https://danielchyeh.github.io/All-Angles-Bench/'><img src='https://img.shields.io/badge/Project-Page-Green'></a><a href='https://arxiv.org/pdf/2504.15280'><img src='https://img.shields.io/badge/Paper-PDF-orange'></a><a href='https://arxiv.org/abs/2504.15280'><img src='https://img.shields.io/badge/Arxiv-Page-purple'></a><a href="https://github.com/Chenyu-Wang567/All-Angles-Bench/tree/main"><img src='https://img.shields.io/badge/Code-Github-red'></a># Dataset Card for All-Angles Bench## Dataset Description<!-- Provide a longer summary of what this dataset is. -->8 unmodified lines- **[Ego-Exo4D](https://github.com/facebookresearch/Ego4d)** - Large-scale egocentric and exocentric video dataset for multi-person interaction understanding## Usage```pythonfrom datasets import load_datasetdataset = load_dataset("ch-chenyu/All-Angles-Bench")```## Prepare Full Benchmark Data on Local Machine1. **Set up Git lfs and clone the benchmark:**```bash$ conda install git-lfs$ git lfs install$ git lfs clone https://huggingface.co/datasets/ch-chenyu/All-Angles-Bench```2. **Download Ego4D-Exo dataset and extract the frames for the benchmark scenes:**We provide the image files for the EgoHumans dataset. For the Ego-Exo4D dataset, due to licensing restrictions, you will need to first sign the license agreement from the official Ego-Exo4D repository at https://ego4ddataset.com/egoexo-license/. After signing the license, you can download the dataset (`downscaled_takes/448`) and then use the preprocessing scripts to extract the corresponding images.```bash$ pip install ego4d --upgrade$ egoexo -o All-Angles-Bench/ --parts downscaled_takes/448$ python All-Angles-Bench/scripts/process_ego4d_exo.py --input All-Angles-Bench```3. **Transform JSON metadata into benchmark TSV format:**To convert the metadata from JSON format into a structured TSV format compatible with benchmark evaluation scripts in [VLMEvalKit](https://github.com/open-compass/VLMEvalKit), run:```bash$ python All-Angles-Bench/scripts/json2tsv_pair.py --input All-Angles-Bench/data.json```## Dataset Structure<!-- This section provides a description of the dataset fields, and additional information about the dataset structure such as criteria used to create the splits, relationships between data points, etc. -->The JSON data contains the following key-value pairs:| Key | Type | Description ||------------------|------------|-----------------------------------------------------------------------------|| `index` | Integer | Unique identifier for the data entry (e.g. `1221`) || `folder` | String | Directory name where the scene is stored (e.g. `"05_volleyball"`) || `category` | String | Task category (e.g. `"counting"`) || `pair_idx` | String | Index of a corresponding paired question (if applicable) || `image_path` | List | Array of input image paths || `question` | String | Natural language query about the scene || `A`/`B`/`C` | String | Multiple choice options || `answer` | String | Correct option label (e.g. `"B"`) || `sourced_dataset`| String | Source dataset name (e.g. `"EgoHumans"`) |## Citation<!-- If there is a paper or blog post introducing the dataset, the APA and Bibtex information for that should go in this section. -->```bibtex@article{yeh2025seeing,title={Seeing from Another Perspective: Evaluating Multi-View Understanding in MLLMs},author={Chun-Hsiao Yeh, Chenyu Wang, Shengbang Tong, Ta-Ying Cheng, Ruoyu Wang, Tianzhe Chu, Yuexiang Zhai, Yubei Chen, Shenghua Gao and Yi Ma},journal={arXiv preprint arXiv:2504.15280},year={2025}}```## AcknowledgementsYou may refer to related work that serves as foundations for our framework and code repository,[EgoHumans](https://github.com/rawalkhirodkar/egohumans),[Ego-Exo4D](https://github.com/facebookresearch/Ego4d),[VLMEvalKit](https://github.com/open-compass/VLMEvalKit).Thanks for their wonderful work and data.g of over 2,100 human-annotated multi-view question-answer (QA) pairs, spanning 90 real-world scenes. Each scene is captured from multiple viewpoints, providing diverse perspectives and context for the associated questions.## Dataset Sources<!-- Provide the basic links for the dataset. -->- **[EgoHumans](https://github.com/rawalkhirodkar/egohumans)** - Egocentric multi-view human activity understanding dataset- **[Ego-Exo4D](https://github.com/facebookresearch/Ego4d)** - Large-scale egocentric and exocentric video dataset for multi-person interaction understanding## Usage```python
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283uniandes_bouldering_012_29georgiatech_bike_15_4georgiatech_cooking_11_02_6utokyo_omelet_5_1001_4utokyo_pcr_2001_23_2indiana_cooking_23_2nus_cooking_17_5indiana_bike_11_9nus_cpr_25_1georgiatech_covid_09_2cmu_soccer03_1minnesota_cooking_060_2sfu_cooking027_9iiith_piano_003_2cmu_soccer12_2utokyo_salad_12_1018_4cmu_bike20_3cmu_bike21_3cmu_bike18_6utokyo_sushi_4_1008_4sfu_cooking032_3utokyo_soccer_8000_17_6cmu_bike19_5cmu_bike15_3cmu_bike14_3unc_music_04-26-23_02_11cmu_bike16_3cmu_bike17_3sfu_cooking031_10iiith_guitar_002_10cmu_bike11_5cmu_bike12_5fair_cooking_05_6sfu_cooking024_2sfu_cooking022_2cmu_bike01_7sfu_cooking029_2sfu_cooking015_2cmu_soccer08_3sfu_cooking030_6cmu_bike06_2cmu_soccer11_2nus_covidtest_49_1sfu_basketball016_5sfu_basketball_04_2sfu_basketball014_9uniandes_dance_020_31sfu_basketball017_9unc_soccer_09-22-23_01_13indiana_music_04_2minnesota_rockclimbing_021_32sfu_basketball012_12iiith_cooking_90_2unc_basketball_03-31-23_02_38fair_bike_06_7uniandes_basketball_005_10utokyo_cpr_2005_28_2nus_soccer_17_3sfu_cooking_005_4cmu_bike08_2cmu_bike09_4iiith_soccer_033_6sfu_covid_013_12cmu_bike05_2cmu_bike02_5sfu_basketball015_7cmu_soccer16_6cmu_soccer15_5cmu_bike13_4uniandes_cooking_001_5sfu_basketball013_28cmu_bike10_7sfu_cooking020_8sfu_cooking026_4sfu_cooking023_8sfu_cooking025_5sfu_cooking028_8cmu_bike03_2cmu_soccer06_6cmu_soccer07_2sfu_cooking017_4cmu_soccer09_2cmu_soccer14_4123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960import jsonimport csvimport osimport argparsefrom pathlib import Path
def process_question(question, A, B, C): options = [A, B, C] question_no_options = question.replace(A, "").replace(B, "").replace(C, "") question_no_options = question_no_options.strip().replace(",", "").strip()
while len(options) < 3: options.append("") return question_no_options, options
def main(json_path): json_path = Path(json_path).resolve() base_path = json_path.parent # All-Angles-Bench/ output_dir = base_path / "bench_tsv" output_dir.mkdir(parents=True, exist_ok=True) output_path = output_dir / "all_angles_bench_huggingface.tsv"
with open(json_path, 'r', encoding='utf-8') as f: data = json.load(f)
tsv_data = []
for entry in data: folder = entry["folder"] category = entry["category"] image_paths = entry["image_path"] modified_input_images = [str(base_path / p) for p in image_paths]
question = entry["question"] answer = entry["answer"] index = entry["index"] pair_idx = entry["pair_idx"]
A = entry["A"] B = entry["B"] C = entry["C"] question_no_options, options = process_question(question, A, B, C)
tsv_data.append([ index, folder, category, pair_idx, modified_input_images, question_no_options ] + options + [answer])
with open(output_path, 'w', newline='', encoding='utf-8') as tsv_file: tsv_writer = csv.writer(tsv_file, delimiter='\t') tsv_writer.writerow(['index', 'folder', 'category', 'pair_idx', 'image_path', 'question', 'A', 'B', 'C', 'answer']) tsv_writer.writerows(tsv_data)
print(f"Saved TSV to {output_path}")
if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('--input', required=True, help='Path to the data.json file (e.g., All-Angles-Bench/data.json)') args = parser.parse_args() main(args.input)1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889import osimport shutilimport argparsefrom pathlib import Pathimport cv2
def extract_frames_from_video(video_path, output_folder, num_frames=16): cap = cv2.VideoCapture(video_path) total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT)) fps = cap.get(cv2.CAP_PROP_FPS) interval = total_frames // num_frames output_folder.mkdir(parents=True, exist_ok=True)
for i in range(num_frames): cap.set(cv2.CAP_PROP_POS_FRAMES, i * interval) ret, frame = cap.read() if not ret: break frame_filename = output_folder / f"frame{i + 1}_{Path(video_path).stem}.jpg" cv2.imwrite(str(frame_filename), frame) cap.release()
def process_subfolders(root_path, folder_list, output_root): for subfolder in Path(root_path).iterdir(): if subfolder.is_dir(): folder_name = subfolder.name if folder_name not in folder_list: continue target_folder = subfolder / "frame_aligned_videos/downscaled/448"
if target_folder.exists() and target_folder.is_dir(): for video_file in target_folder.glob("cam*.mp4"): print(f"Processing video: {video_file}") new_subfolder = Path(output_root) / subfolder.name new_subfolder.mkdir(parents=True, exist_ok=True) extract_frames_from_video(video_file, new_subfolder)
def move_and_rename_frames_from_file(file_path, destination_root, source_root): with open(file_path, 'r') as f: folder_list = [line.strip() for line in f.readlines()]
for folder in folder_list: folder_path = Path(os.path.join(source_root, folder)) if folder_path.exists() and folder_path.is_dir(): target_folder = Path(destination_root) / folder_path.name target_folder.mkdir(parents=True, exist_ok=True) for frame_file in folder_path.glob("frame2_*.jpg"): new_filename = frame_file.name.replace("frame2_", "") destination_file = target_folder / new_filename shutil.move(str(frame_file), str(destination_file)) print(f"Moved and renamed {frame_file} to {destination_file}") else: print(f"Folder {folder} does not exist or is not a directory.")
if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('--input', required=True, help='Path to All-Angles-Bench (root folder)') args = parser.parse_args()
root_input = Path(args.input) folder_list_file = root_input / "folder_list.txt" input_path = root_input / "takes" output_root = root_input / "extracted_frames_huggingface" destination_root = root_input / "ego_exo4d_scenes"
with open(folder_list_file, 'r') as f: folder_list = [line.strip() for line in f.readlines()]
process_subfolders(input_path, folder_list, output_root) print("Processing frames extraction completed!") move_and_rename_frames_from_file(folder_list_file, destination_root, output_root) print("Files moved and renamed successfully!")
# Clean up if output_root.exists() and output_root.is_dir(): shutil.rmtree(output_root) print(f"Removed intermediate folder: {output_root}")README.md+114
folder_list.txtAdded+83
scripts/json2tsv_pair.pyAdded+60
scripts/process_ego4d_exo.pyAdded+89