kenjiqq commited on
Commit
eab68ca
1 Parent(s): 5d60f4a

Upload 2 files

Browse files
Files changed (2) hide show
  1. imagereward-evaluation.py +56 -0
  2. images.zip +3 -0
imagereward-evaluation.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import datasets
2
+ import json
3
+
4
+ import json
5
+ import os
6
+
7
+ import datasets
8
+
9
+ _DESCRIPTION = """\
10
+ Dataset to perform Aesthetic evaluation from Table 2 in ImageReward: Learning and Evaluating Human Preferences for Text-to-Image Generation.
11
+
12
+ @misc{xu2023imagereward,
13
+ title={ImageReward: Learning and Evaluating Human Preferences for Text-to-Image Generation},
14
+ author={Jiazheng Xu and Xiao Liu and Yuchen Wu and Yuxuan Tong and Qinkai Li and Ming Ding and Jie Tang and Yuxiao Dong},
15
+ year={2023},
16
+ eprint={2304.05977},
17
+ archivePrefix={arXiv},
18
+ primaryClass={cs.CV}
19
+ }
20
+ """
21
+
22
+ class ImagerewardEvaluation(datasets.GeneratorBasedBuilder):
23
+ VERSION = datasets.Version("1.0.0")
24
+
25
+ def _info(self):
26
+ features = datasets.Features(
27
+ {
28
+ "id": datasets.Value("string"),
29
+ "prompt": datasets.Value("string"),
30
+ "generations": datasets.Sequence(datasets.Image()),
31
+ "ranking": datasets.Sequence(datasets.Value("int32")),
32
+ }
33
+ )
34
+ return datasets.DatasetInfo(
35
+ description=_DESCRIPTION,
36
+ features=features,
37
+ )
38
+
39
+ def _split_generators(self, dl_manager):
40
+ downloaded_files = dl_manager.download_and_extract("./test.json")
41
+ images = dl_manager.download_and_extract("./images.zip")
42
+ print(downloaded_files, images)
43
+ return [
44
+ datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"metadata_path": downloaded_files, "images_path": os.path.join(images, "test_images")}),
45
+ ]
46
+
47
+ def _generate_examples(self, metadata_path, images_path):
48
+ with open(metadata_path, encoding="utf-8") as f:
49
+ data = json.load(f)
50
+ for item in data:
51
+ yield item["id"], {
52
+ "id": item["id"],
53
+ "prompt": item["prompt"],
54
+ "generations": [os.path.join(images_path, x) for x in item["generations"]],
55
+ "ranking": item["ranking"],
56
+ }
images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e74d1b0d3017cc2ad58ba355a230ad9cede32841c655d5357aa6adc47a35e011
3
+ size 1183893396