Download VideoX-Fun/VBench/VBench-2.0/divide_video.py from YFanwang/Backup: direct link, hf CLI and curl.
- Browser
- Download file 1.8 kB
-
https://huggingface.co/datasets/YFanwang/Backup/resolve/main/VideoX-Fun/VBench/VBench-2.0/divide_video.py
- Command line
-
hf download hf://datasets/YFanwang/Backup/VideoX-Fun/VBench/VBench-2.0/divide_video.py
-
curl -L -o divide_video.py https://huggingface.co/datasets/YFanwang/Backup/resolve/main/VideoX-Fun/VBench/VBench-2.0/divide_video.py
1.8 kB
| import os | |
| import json | |
| import re | |
| import shutil | |
| json_path = 'prompts/VBench2_full_text_info.json' | |
| source_video_file = '/mnt/petrelfs/zhengdian/zhengdian/VBench2.0/sample_video/vbench2_videos' # CHANGE | |
| target_video_file = '/mnt/petrelfs/zhengdian/zhengdian/VBench2.0/sample_video/Vidu_Q1' # DEFAULT | |
| with open(json_path, 'r', encoding='utf-8') as f: | |
| data = json.load(f) | |
| for video in os.listdir(source_video_file): | |
| source_path = os.path.join(source_video_file, video) | |
| video_suffix = re.split(r'-\d+\.mp4', video)[0] | |
| info = data[video_suffix[:180]] | |
| if 'Diversity' in info['dimension'] and len(info['dimension'])==1: | |
| target_path = os.path.join(target_video_file, 'Diversity', video) | |
| os.makedirs(os.path.dirname(target_path), exist_ok=True) | |
| shutil.copy(source_path, target_path) | |
| elif 'Diversity' in info['dimension'] and len(info['dimension'])!=1: | |
| caption = info['caption'][:180] | |
| for dimension in info['dimension']: | |
| if video in [f"{caption}-0.mp4", f"{caption}-1.mp4", f"{caption}-2.mp4"]: | |
| target_path = os.path.join(target_video_file, dimension, video) | |
| os.makedirs(os.path.dirname(target_path), exist_ok=True) | |
| shutil.copy(source_path, target_path) | |
| else: | |
| if dimension == 'Diversity': | |
| target_path = os.path.join(target_video_file, dimension, video) | |
| os.makedirs(os.path.dirname(target_path), exist_ok=True) | |
| shutil.copy(source_path, target_path) | |
| else: | |
| for dimension in info['dimension']: | |
| target_path = os.path.join(target_video_file, dimension, video) | |
| os.makedirs(os.path.dirname(target_path), exist_ok=True) | |
| shutil.copy(source_path, target_path) |