├── LICENSE ├── README.md ├── eval.py ├── metrics └── clip_score.py ├── source ├── 265_Amidst the lush canopy of a deep jungle, a playful panda is brewing a potion, captured with the stark realism of a photo.png ├── 426_Behold a noble king in the throes of skillfully strumming the guitar surrounded by the tranquil waters of a serene lake, envisioned in the style of an oil painting.png ├── 619_Amidst a sun-dappled forest, a mischievous fairy is carefully repairing a broken robot, captured in the style of an oil painting.png ├── 824_Within the realm of the backdrop of an alien planet's red skies, a treasure-seeking pirate cleverly solving a puzzle, each moment immortalized in the style of an oil painting.png ├── I2VFramework.jpg └── radar_chart_high_res.jpg └── utils.py /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AIGCBench 2 | 3 | :dart::dart: AIGCBench is a novel and comprehensive benchmark designed for evaluating the capabilities of state-of-the-art video generation algorithms. Official code for the paper: 4 | 5 | > **AIGCBench: Comprehensive Evaluation of Image-to-Video Content Generated by AI**, ***BenchCouncil Transactions on Benchmarks, Standards and Evaluations (TBench)***. 6 | > 7 | > Fanda Fan, Chunjie Luo, Wanling Gao, Jianfeng Zhan 8 | > 9 | > 10 | 11 |

12 | 13 |

14 | 15 | Illustration of our AIGCBench. Our AIGCBench is divided into three modules: the evaluation dataset, the evaluation metrics, and the video generation models to be assessed. 16 | 17 | 18 | 19 | Key Features of AIGCBench: 20 | - Diverse Datasets: AIGCBench incorporates a variety of datasets, including real-world video-text pairs and image-text pairs, to ensure a broad and realistic evaluation spectrum. Additionally, it includes a newly generated dataset created through an innovative text-to-image generation pipeline, enhancing the diversity and representativeness of the benchmark. 21 | - Extensive Evaluation Metrics: AIGCBench introduces a set of evaluation metrics that cover four crucial dimensions of video generation—**control-video alignment**, **motion effects**, **temporal consistency**, and **video quality**. Our evaluation metrics encompass both reference **video-based metrics** and **video-free metrics**. 22 | - Validated by Human Judgment: The benchmark's evaluation criteria are thoroughly verified against human preferences to confirm their reliability and alignment with human judgments. 23 | - In-Depth Analysis: Through extensive evaluations, AIGCBench reveals insightful findings about the current strengths and limitations of existing I2V models, offering valuable guidance for future advancements in the field. 24 | - Future Expansion: AIGCBench is not only comprehensive and scalable in its current form but also designed with the vision to encompass a wider range of video generation tasks in the future. This will allow for a unified and in-depth benchmarking of various aspects of AI-generated content (AIGC), setting a new standard for the evaluation of video generation technologies. 25 | 26 | ## :fire:News 27 | - [01/24/2024] Our paper has been accepted by BenchCouncil Transactions on Benchmarks, Standards and Evaluations (Tbench)! 28 | - [01/10/2024] The evaluation dataset and evaluation code have been released. 29 | 30 | ## Dataset 31 | 32 | :smile:The [Hugging Face link](https://huggingface.co/datasets/stevenfan/AIGCBench_v1.0) for our dataset. 33 | 34 | This dataset is intended for the evaluation of video generation tasks. Our dataset includes image-text pairs and video-text pairs. The dataset comprises three parts: 35 | 1. `Ours` - A custom generation of image-text samples. 36 | 2. `Webvid val` - A subset of 1000 video samples from the WebVid val dataset. 37 | 3. `Laion-aesthetics` - A subset of LAION dataset that includes 925 curated image-text samples. 38 | 39 | Below are some images we generated, with the corresponding text: 40 | | Image | Description | 41 | |------------------|------------------| 42 | | | *Amidst the lush canopy of a deep jungle, a playful panda is brewing a potion, captured with the stark realism of a photo.* | 43 | | | *Behold a noble king in the throes of skillfully strumming the guitar surrounded by the tranquil waters of a serene lake, envisioned in the style of an oil painting.* | 44 | | | *Amidst a sun-dappled forest, a mischievous fairy is carefully repairing a broken robot, captured in the style of an oil painting.* | 45 | | | *Within the realm of the backdrop of an alien planet's red skies, a treasure-seeking pirate cleverly solving a puzzle, each moment immortalized in the style of an oil painting.* | 46 | 47 | 48 | 49 | ## Metrics 50 | 51 | We have encapsulated the evaluation metrics used in our paper in `eval.py`; for more details, please refer to the paper. To use the code, please first download the [clip model](https://openaipublic.azureedge.net/clip/models/b8cca3fd41ae0c99ba7e8951adf17d267cdb84cd88be6f7c2e0eca1737a03836/ViT-L-14.pt) file and replace the 'path_to_dir' with the actual path. 52 | 53 | Below is a simple example: 54 | ```python 55 | batch_video_path = os.path.join('path_to_videos', '*.mp4') 56 | video_path_list = sorted(glob.glob(batch_video_path)) 57 | 58 | sum_res = 0 59 | cnt = 0 60 | for video_path in video_path_list: 61 | res = compute_video_video_similarity(ref_video_path, video_path) 62 | sum_res += res['clip'] 63 | cnt += res["state"] 64 | print(sum_res / cnt) 65 | ``` 66 | 67 | ## Evaluation Results 68 | 69 | Quantitative analysis for different Image-to-Video algorithms. An upward arrow indicates that higher values are better, while a downward arrow means lower values are preferable. 70 | | Dimensions | Metrics | VideoCrafter | I2VGen-XL | SVD | Pika | Gen2 | 71 | |------------|---------|------------------|---------------|---------|----------|----------| 72 | | Control-video Alignment | MSE (First) ↓ | 3929.65 | 4491.90 | 640.75 | **155.30** | 235.53 | 73 | | | SSIM (First) ↑ | 0.300 | 0.354 | 0.612 | 0.800 | **0.803** | 74 | | | Image-GenVideo Clip ↑ | 0.830 | 0.832 | 0.919 | 0.930 | **0.939** | 75 | | | GenVideo-Text Clip ↑ | 0.23 | 0.24 | - | **0.271** | 0.270 | 76 | | | GenVideo-RefVideo CliP (Keyframes) ↑ | 0.763 | 0.764 | - | **0.824** | 0.820 | 77 | | Motion Effects | Flow-Square-Mean | 1.24 | 1.80 | 2.52 | 0.281 | 1.18 | 78 | | | GenVideo-RefVideo CliP (Corresponding frames) ↑ | 0.764 | 0.764 | 0.796 | **0.823** | 0.818 | 79 | | Temporal Consistency | GenVideo Clip (Adjacent frames) ↑ | 0.980 | 0.971 | 0.974 | **0.996** | 0.995 | 80 | | | GenVideo-RefVideo CliP (Corresponding frames) ↑ | 0.764 | 0.764 | 0.796 | **0.823** | 0.818 | 81 | | Video Quality | Frame Count ↑ | 16 | 32 | 25 | 72 | **96** | 82 | | | DOVER ↑ | 0.518 | 0.510 | 0.623 | 0.715 | **0.775** | 83 | | | GenVideo-RefVideo SSIM ↑ | 0.367 | 0.304 | 0.507 | **0.560** | 0.504 | 84 | 85 | To validate the alignment of our proposed evaluation standards with human preferences, we conducted a study. We randomly selected 30 generated results from each of the five methods. Then, we asked participants to vote on the best algorithm outcomes across four dimensions: Image Fidelity, Motion Effects, Temporal Consistency, and Video Quality. A total of 42 individuals participated in the voting process. The specific results of the study are presented below: 86 | 87 | Alt text 88 | 89 | ## Contact Us 90 | 91 | :email: If you have any questions, please feel free to contact us via email at fanfanda@ict.ac.cn and jianfengzhan.benchcouncil@gmail.com. 92 | 93 | 94 | 95 | ## Citation 96 | 97 | If you find our work useful in your research, please consider citing our paper: 98 | 99 | ```bibtex 100 | @article{fan2024aigcbench, 101 | title={AIGCBench: Comprehensive evaluation of image-to-video content generated by AI}, 102 | author={Fan, Fanda and Luo, Chunjie and Gao, Wanling and Zhan, Jianfeng}, 103 | journal={BenchCouncil Transactions on Benchmarks, Standards and Evaluations}, 104 | pages={100152}, 105 | year={2024}, 106 | publisher={Elsevier} 107 | } 108 | ``` 109 | -------------------------------------------------------------------------------- /eval.py: -------------------------------------------------------------------------------- 1 | import clip 2 | from PIL import Image 3 | import numpy as np 4 | from einops import rearrange 5 | from metrics.clip_score import calculate_clip_score 6 | from utils import load_video, load_image 7 | from skimage.metrics import mean_squared_error, structural_similarity as ssim 8 | 9 | model, preprocess = clip.load("path_to_dir/ViT-L-14.pt", device="cuda") 10 | 11 | 12 | # GenVideo-RefVideo SSIM 13 | def compute_video_video_similarity_ssim(reference_video_path, 14 | video_path, 15 | keyframes=[0, 4, 8, 12, 15]): 16 | global model, preprocess 17 | 18 | reference_video = load_video(reference_video_path) 19 | try: 20 | video_frames = load_video(video_path, 21 | size=(reference_video[0].shape[1], 22 | reference_video[0].shape[0]))[:16] 23 | except: 24 | print(video_path, ' Error !!') 25 | return {'ssim': 0, 'state': 0} 26 | 27 | all_frame_scores = 0. 28 | for idx, frames in enumerate(keyframes): 29 | im1 = np.array( 30 | reference_video[10 + frames * 3] 31 | ) # In webvid, we start with the tenth frame of the video for the motion. Different fps * 3 32 | im2 = np.array(video_frames[frames]) 33 | 34 | ssim_value = ssim(im1, 35 | im2, 36 | multichannel=True, 37 | win_size=7, 38 | channel_axis=-1) 39 | 40 | all_frame_scores += ssim_value 41 | 42 | all_frame_scores /= len(keyframes) 43 | return {'ssim': all_frame_scores, 'state': 1} 44 | 45 | 46 | # GenVideo clip 47 | def compute_temporal_consistency(video_path): 48 | global model, preprocess 49 | 50 | all_frame_scores = 0. 51 | video_frames = load_video(video_path)[:16] # get pre 16 frames 52 | for i in range(1, len(video_frames)): 53 | pre_frame = Image.fromarray(video_frames[i - 1]) 54 | next_frame = Image.fromarray(video_frames[i]) 55 | score = calculate_clip_score(model, 56 | preprocess, 57 | first_data=pre_frame, 58 | second_data=next_frame, 59 | first_flag='img', 60 | second_flag='img').cpu().numpy() 61 | all_frame_scores += score 62 | return all_frame_scores / (len(video_frames) - 1) 63 | 64 | 65 | # GenVideo-Text clip 66 | def compute_video_text_alignment(video_path, text): 67 | global model, preprocess 68 | 69 | all_frame_scores = 0. 70 | video_frames = load_video(video_path, )[:16] 71 | assert len(video_frames) != 0, 'check video_path {video_path}!' 72 | for frame in video_frames: 73 | frame = Image.fromarray(frame) 74 | score = calculate_clip_score(model, 75 | preprocess, 76 | first_data=text, 77 | second_data=frame, 78 | first_flag='txt', 79 | second_flag='img').cpu().numpy() 80 | all_frame_scores += score 81 | return all_frame_scores / len(video_frames) 82 | 83 | 84 | # GenVideo-RefVideo clip (keyframes) 85 | def compute_video_video_similarity(reference_video_path, 86 | video_path, 87 | keyframes=[0, 4, 8, 12, 15]): 88 | global model, preprocess 89 | 90 | reference_video = load_video(reference_video_path) 91 | try: 92 | video_frames = load_video(video_path, 93 | size=reference_video[0].shape[:2]) 94 | except: 95 | print(video_path, ' Error !!') 96 | return {'clip': 0, 'state': 0} 97 | 98 | all_frame_scores = 0. 99 | for idx, frames in enumerate(keyframes): 100 | im1 = Image.fromarray(np.array(reference_video[10 + frames * 3])) 101 | im2 = Image.fromarray(np.array(video_frames[frames])) 102 | score = calculate_clip_score(model, 103 | preprocess, 104 | first_data=im1, 105 | second_data=im2, 106 | first_flag='img', 107 | second_flag='img').cpu().numpy() 108 | all_frame_scores += score 109 | 110 | all_frame_scores /= len(keyframes) 111 | return {'clip': all_frame_scores, 'state': 1} 112 | 113 | 114 | # MSE (First) and SSIM (First) 115 | def compute_image_image_similarity(init_image_path, video_path): 116 | global model, preprocess 117 | 118 | # all_frame_scores = 0. 119 | init_image = Image.fromarray(load_image(init_image_path)) 120 | try: 121 | video_frames = load_video(video_path, 122 | size=init_image.size) # size=(512, 904) 123 | except: 124 | print(video_path, ' Error !!') 125 | return {'MSE': 0, 'SSIM': 0, 'state': 0} 126 | init_image_np = np.array(init_image) 127 | video_frame_np = np.array(video_frames[0]) # or 10th frames 128 | 129 | if init_image_np.shape == video_frame_np.shape: 130 | mse_value = mean_squared_error(init_image_np, video_frame_np) 131 | ssim_value = ssim(init_image_np, 132 | video_frame_np, 133 | multichannel=True, 134 | win_size=7, 135 | channel_axis=-1) 136 | else: 137 | print("Error: The images do not have the same dimensions.", video_path) 138 | return {'MSE': 0, 'SSIM': 0, 'state': 0} 139 | 140 | return {'MSE': mse_value, 'SSIM': ssim_value, 'state': 1} 141 | 142 | 143 | # Image-GenVideo clip 144 | def compute_video_image_similarity(video_path, image_path): 145 | global model, preprocess 146 | 147 | all_frame_scores = 0. 148 | image = Image.fromarray(load_image(image_path)) 149 | 150 | try: 151 | video_frames = load_video(video_path, size=image.size) 152 | except: 153 | print(video_path, ' Error !!') 154 | return {"clip_per": all_frame_scores / len(video_frames), "state": 0} 155 | 156 | for frame in video_frames: 157 | frame = Image.fromarray(frame) 158 | score = calculate_clip_score(model, 159 | preprocess, 160 | first_data=image, 161 | second_data=frame, 162 | first_flag='img', 163 | second_flag='img').cpu().numpy() 164 | all_frame_scores += score 165 | return {"clip_per": all_frame_scores / len(video_frames), "state": 1} 166 | -------------------------------------------------------------------------------- /metrics/clip_score.py: -------------------------------------------------------------------------------- 1 | """ 2 | Calculates the CLIP Scores 3 | """ 4 | import clip 5 | import torch 6 | 7 | 8 | def forward_modality(model, preprocess, data, flag): 9 | device = next(model.parameters()).device 10 | if flag == 'img': 11 | data = preprocess(data).unsqueeze(0) 12 | features = model.encode_image(data.to(device)) 13 | elif flag == 'txt': 14 | data = clip.tokenize(data) 15 | features = model.encode_text(data.to(device)) 16 | else: 17 | raise TypeError 18 | # print(flag, features.shape) 19 | return features 20 | 21 | 22 | @torch.no_grad() 23 | def calculate_clip_score(model, 24 | preprocess, 25 | first_data, 26 | second_data, 27 | first_flag='txt', 28 | second_flag='img'): 29 | # logit_scale = model.logit_scale.exp() 30 | first_features = forward_modality(model, preprocess, first_data, 31 | first_flag) 32 | second_features = forward_modality(model, preprocess, second_data, 33 | second_flag) 34 | 35 | # normalize features 36 | first_features = first_features / first_features.norm( 37 | dim=1, keepdim=True).to(torch.float32) 38 | second_features = second_features / second_features.norm( 39 | dim=1, keepdim=True).to(torch.float32) 40 | 41 | # calculate scores 42 | # score = logit_scale * (second_features * first_features).sum() 43 | score = (second_features * first_features).sum() 44 | return score 45 | -------------------------------------------------------------------------------- /source/265_Amidst the lush canopy of a deep jungle, a playful panda is brewing a potion, captured with the stark realism of a photo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BenchCouncil/AIGCBench/cc230c8474fdd1af8a7a0749981aa1d09198eaf3/source/265_Amidst the lush canopy of a deep jungle, a playful panda is brewing a potion, captured with the stark realism of a photo.png -------------------------------------------------------------------------------- /source/426_Behold a noble king in the throes of skillfully strumming the guitar surrounded by the tranquil waters of a serene lake, envisioned in the style of an oil painting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BenchCouncil/AIGCBench/cc230c8474fdd1af8a7a0749981aa1d09198eaf3/source/426_Behold a noble king in the throes of skillfully strumming the guitar surrounded by the tranquil waters of a serene lake, envisioned in the style of an oil painting.png -------------------------------------------------------------------------------- /source/619_Amidst a sun-dappled forest, a mischievous fairy is carefully repairing a broken robot, captured in the style of an oil painting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BenchCouncil/AIGCBench/cc230c8474fdd1af8a7a0749981aa1d09198eaf3/source/619_Amidst a sun-dappled forest, a mischievous fairy is carefully repairing a broken robot, captured in the style of an oil painting.png -------------------------------------------------------------------------------- /source/824_Within the realm of the backdrop of an alien planet's red skies, a treasure-seeking pirate cleverly solving a puzzle, each moment immortalized in the style of an oil painting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BenchCouncil/AIGCBench/cc230c8474fdd1af8a7a0749981aa1d09198eaf3/source/824_Within the realm of the backdrop of an alien planet's red skies, a treasure-seeking pirate cleverly solving a puzzle, each moment immortalized in the style of an oil painting.png -------------------------------------------------------------------------------- /source/I2VFramework.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BenchCouncil/AIGCBench/cc230c8474fdd1af8a7a0749981aa1d09198eaf3/source/I2VFramework.jpg -------------------------------------------------------------------------------- /source/radar_chart_high_res.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BenchCouncil/AIGCBench/cc230c8474fdd1af8a7a0749981aa1d09198eaf3/source/radar_chart_high_res.jpg -------------------------------------------------------------------------------- /utils.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import cv2 3 | from PIL import Image 4 | 5 | 6 | def load_video(video_path, size=None, mode="RGB"): 7 | video_frames = [] 8 | cap = cv2.VideoCapture(video_path) 9 | frame_count = int(cap.get(cv2.CAP_PROP_FRAME_COUNT)) 10 | frame_index = list(range(frame_count)) 11 | cur_index = 0 12 | k = 0 13 | while cap.isOpened(): 14 | ret = cap.grab() 15 | if not ret: 16 | break 17 | if k in frame_index: 18 | _, frame = cap.retrieve() 19 | if size != None: 20 | frame = cv2.resize(frame, size) 21 | if mode == "RGB": 22 | frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) 23 | video_frames.append(frame) 24 | cur_index += 1 25 | k += 1 26 | cap.release() 27 | return video_frames 28 | 29 | 30 | def load_image(image_path, mode="RGB"): 31 | return np.array(Image.open(image_path).convert("RGB")) 32 | --------------------------------------------------------------------------------