Skip to content

Commit 329a564

Browse files
committed
[update] custom_video_evaluation
1 parent af4606c commit 329a564

File tree

2 files changed

+47
-37
lines changed

2 files changed

+47
-37
lines changed

VBench-2.0/README.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,39 @@ Evaluate 18 dimensions on different GPUs, one dimension per GPU. You can set the
8787
bash evaluate.sh --max_parallel_tasks 8
8888
```
8989

90+
### **[New]** Evaluating Single Dimension of Your Own Videos
91+
We support evaluating any video. Simply provide the path to the video file. There is no requirement on the videos' names except `Diversity` dimension.
92+
- Note: We support customized videos / prompts for the following dimensions: `'Human_Anatomy', 'Human_Identity', 'Human_Clothes', 'Diversity', 'Multi-View_Consistency'`
93+
- Note: `Diversity` requires at least 20 videos for one prompt to robustly test the diversity of your model and the naming format should be `prompt-index.mp4` where index ranges from 0 to 19
94+
- Note: `Diversity` and `Multi-View_Consistency` should be placed in separate folders while `'Human_Anatomy', 'Human_Identity', 'Human_Clothes'` can share a folder (save your time).
95+
96+
To evaluate videos with customized input prompt, run our script with `--mode=custom_input`:
97+
```bash
98+
python evaluate.py \
99+
--dimension $DIMENSION \
100+
--videos_path /path/to/folder_or_video/ \
101+
--output_path "evaluation_results/$DIMENSION" \
102+
--mode=custom_input
103+
```
104+
For example:
105+
```bash
106+
python evaluate.py \
107+
--dimension "Diversity" \
108+
--videos_path "YOUR_VIDEO_PATH" \
109+
--output_path "evaluation_results/Diversity" \
110+
--mode=custom_input
111+
```
112+
90113
### Evaluating Single Dimension on the Standard Prompt Suite of VBench-2.0
91114

92-
##### command line
115+
<!-- ##### command line
93116
```bash
94117
vbench2 evaluate --videos_path $VIDEO_PATH --dimension $DIMENSION
95118
```
96119
For example:
97120
```bash
98121
vbench2 evaluate --videos_path "sampled_videos/HunyuanVideo/Human_Interaction" --dimension "Human_Interaction"
99-
```
122+
``` -->
100123
##### python
101124
```python
102125
from vbench2 import VBench2

VBench-2.0/vbench2/__init__.py

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def build_full_dimension_list(self, ):
2121
def check_dimension_requires_extra_info(self, dimension_list):
2222
dim_custom_not_supported = set(dimension_list) & set([
2323
'Composition', 'Dynamic_Attribute', 'Dynamic_Spatial_Relationship', 'Instance_Preservation', 'Complex_Plot', 'Complex_Landscape',
24-
'Motion_Rationality', 'Motion_Order_Understanding', 'Mechanics', 'Thermotics', 'Material', "Camera_Motion"
24+
'Motion_Rationality', 'Motion_Order_Understanding', 'Mechanics', 'Thermotics', 'Material', "Camera_Motion", "Human_Interaction"
2525
])
2626

2727
assert len(dim_custom_not_supported) == 0, f"dimensions : {dim_custom_not_supported} not supported for custom input"
@@ -31,47 +31,34 @@ def build_full_info_json(self, videos_path, name, dimension_list, prompt_list=[]
3131
cur_full_info_list=[] # to save the prompt and video path info for the current dimensions
3232
if mode=='custom_input':
3333
self.check_dimension_requires_extra_info(dimension_list)
34-
if os.path.isfile(videos_path):
35-
cur_full_info_list = [{"prompt_en": get_prompt_from_filename(videos_path), "dimension": dimension_list, "video_list": [videos_path]}]
36-
if len(prompt_list) == 1:
37-
cur_full_info_list[0]["prompt_en"] = prompt_list[0]
38-
else:
39-
video_names = os.listdir(videos_path)
40-
41-
cur_full_info_list = []
42-
43-
for filename in video_names:
44-
postfix = Path(os.path.join(videos_path, filename)).suffix
45-
if postfix.lower() not in ['.mp4', '.gif', '.jpg', '.png']:
34+
video_names = os.listdir(videos_path)
35+
assert len(video_names)>0, f"ERROR : The video files is empty"
36+
cur_full_info_list = []
37+
prompt_check_list = []
38+
for filename in video_names:
39+
postfix = Path(os.path.join(videos_path, filename)).suffix
40+
if postfix.lower() not in ['.mp4']:
41+
continue
42+
if dimension_list[0]=='Diversity':
43+
prompt_en = get_prompt_from_filename(filename)
44+
if prompt_en in prompt_check_list:
4645
continue
46+
prompt_check_list.append(prompt_en)
47+
item = {
48+
"prompt_en": prompt_en,
49+
"dimension": dimension_list,
50+
"video_list": []
51+
}
52+
for ite in range(20):
53+
item['video_list'].append(os.path.join(videos_path, f'{prompt_en}{special_str}-{str(ite)}{postfix}'))
54+
cur_full_info_list.append(item)
55+
else:
4756
cur_full_info_list.append({
4857
"prompt_en": get_prompt_from_filename(filename),
4958
"dimension": dimension_list,
5059
"video_list": [os.path.join(videos_path, filename)]
5160
})
5261

53-
if len(prompt_list) > 0:
54-
prompt_list = {os.path.join(videos_path, path): prompt_list[path] for path in prompt_list}
55-
assert len(prompt_list) >= len(cur_full_info_list), """
56-
Number of prompts should match with number of videos.\n
57-
Got {len(prompt_list)=}, {len(cur_full_info_list)=}\n
58-
To read the prompt from filename, delete --prompt_file and --prompt_list
59-
"""
60-
61-
all_video_path = [os.path.abspath(file) for file in list(chain.from_iterable(vid["video_list"] for vid in cur_full_info_list))]
62-
backslash = "\n"
63-
assert len(set(all_video_path) - set([os.path.abspath(path_key) for path_key in prompt_list])) == 0, f"""
64-
The prompts for the following videos are not found in the prompt file: \n
65-
{backslash.join(set(all_video_path) - set([os.path.abspath(path_key) for path_key in prompt_list]))}
66-
"""
67-
68-
video_map = {}
69-
for prompt_key in prompt_list:
70-
video_map[os.path.abspath(prompt_key)] = prompt_list[prompt_key]
71-
72-
for video_info in cur_full_info_list:
73-
video_info["prompt_en"] = video_map[os.path.abspath(video_info["video_list"][0])]
74-
7562
else:
7663
full_info_list = load_json(self.full_info_dir)
7764
video_names = os.listdir(videos_path)

0 commit comments

Comments
 (0)