rvorias commited on
Commit
d33c309
1 Parent(s): f98e06e

add dataset_info and update loader

Browse files
Files changed (2) hide show
  1. dataset_infos.json +104 -0
  2. realms_adventurers.py +19 -23
dataset_infos.json ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "default": {
3
+ "description": "This is the public dataset for the realms adventurer generator.\nIt contains images of characters and annotations to form structured captions.",
4
+ "citation": "",
5
+ "homepage": "",
6
+ "license": "https://docs.midjourney.com/docs/terms-of-service",
7
+ "features": {
8
+ "image": {
9
+ "decode": true,
10
+ "id": null,
11
+ "_type": "Image"
12
+ },
13
+ "caption": {
14
+ "dtype": "string",
15
+ "id": null,
16
+ "_type": "Value"
17
+ },
18
+ "components": {
19
+ "sex": {
20
+ "dtype": "string",
21
+ "id": null,
22
+ "_type": "Value"
23
+ },
24
+ "race": {
25
+ "dtype": "string",
26
+ "id": null,
27
+ "_type": "Value"
28
+ },
29
+ "class": {
30
+ "dtype": "string",
31
+ "id": null,
32
+ "_type": "Value"
33
+ },
34
+ "inherent_features": {
35
+ "dtype": "string",
36
+ "id": null,
37
+ "_type": "Value"
38
+ },
39
+ "clothing": {
40
+ "dtype": "string",
41
+ "id": null,
42
+ "_type": "Value"
43
+ },
44
+ "accessories": {
45
+ "dtype": "string",
46
+ "id": null,
47
+ "_type": "Value"
48
+ },
49
+ "background": {
50
+ "dtype": "string",
51
+ "id": null,
52
+ "_type": "Value"
53
+ },
54
+ "shot": {
55
+ "dtype": "string",
56
+ "id": null,
57
+ "_type": "Value"
58
+ },
59
+ "view": {
60
+ "dtype": "string",
61
+ "id": null,
62
+ "_type": "Value"
63
+ }
64
+ }
65
+ },
66
+ "post_processed": null,
67
+ "supervised_keys": {
68
+ "input": "image",
69
+ "output": "caption"
70
+ },
71
+ "task_templates": null,
72
+ "builder_name": "realms_adventurers",
73
+ "config_name": "default",
74
+ "version": {
75
+ "version_str": "1.0.0",
76
+ "description": null,
77
+ "major": 1,
78
+ "minor": 0,
79
+ "patch": 0
80
+ },
81
+ "splits": {
82
+ "train": {
83
+ "name": "train",
84
+ "num_bytes": 72390,
85
+ "num_examples": 175,
86
+ "dataset_name": "realms_adventurers"
87
+ }
88
+ },
89
+ "download_checksums": {
90
+ "https://huggingface.co/datasets/rvorias/realms_adventurers/resolve/main/data/images_001.zip": {
91
+ "num_bytes": 177930282,
92
+ "checksum": "b96fdea763d54939fbd8de3936ababd9fada7569a735f5b39b6dbbdbb27f98b5"
93
+ },
94
+ "https://huggingface.co/datasets/rvorias/realms_adventurers/resolve/main/metadata.json": {
95
+ "num_bytes": 89974,
96
+ "checksum": "c5f4130f05744481cdf6a52a835413cdd6c3a469c5c489f6a2ab03875800b047"
97
+ }
98
+ },
99
+ "download_size": 178020256,
100
+ "post_processing_size": null,
101
+ "dataset_size": 72390,
102
+ "size_in_bytes": 178092646
103
+ }
104
+ }
realms_adventurers.py CHANGED
@@ -83,14 +83,10 @@ class RealmsAdventurersDataset(datasets.GeneratorBasedBuilder):
83
  def _split_generators(self, dl_manager):
84
  images_url = _URLS["images"]
85
  images_dir = dl_manager.download_and_extract(images_url)
86
-
87
- print("AA")
88
 
89
- annotations_url = _URLS["annotations"]
90
  annotations_path = dl_manager.download(annotations_url)
91
 
92
- print(images_dir)
93
-
94
  return [
95
  datasets.SplitGenerator(
96
  name=datasets.Split.TRAIN,
@@ -106,21 +102,21 @@ class RealmsAdventurersDataset(datasets.GeneratorBasedBuilder):
106
  def _generate_examples(self, root_dir, metadata_path):
107
  with open(metadata_path, encoding="utf-8") as f:
108
  data = json.load(f)
109
- # for sample in data:
110
- # image_path = os.path.join(root_dir, sample["file_name"])
111
- # with open(image_path, "rb") as file_obj:
112
- # yield image_path, {
113
- # "image": {"path": image_path, "bytes": file_obj.read()},
114
- # "caption": sample["caption"],
115
- # "components": {
116
- # "sex": sample.get("sex"),
117
- # "race": sample.get("race"),
118
- # "class": sample.get("class"),
119
- # "inherent_features": sample.get("inherent_features"),
120
- # "clothing": sample.get("clothing"),
121
- # "accessories": sample.get("accessories"),
122
- # "background": sample.get("background"),
123
- # "shot": sample.get("shot"),
124
- # "view": sample.get("view"),
125
- # },
126
- # }
 
83
  def _split_generators(self, dl_manager):
84
  images_url = _URLS["images"]
85
  images_dir = dl_manager.download_and_extract(images_url)
 
 
86
 
87
+ annotations_url = _URLS["metadata"]
88
  annotations_path = dl_manager.download(annotations_url)
89
 
 
 
90
  return [
91
  datasets.SplitGenerator(
92
  name=datasets.Split.TRAIN,
 
102
  def _generate_examples(self, root_dir, metadata_path):
103
  with open(metadata_path, encoding="utf-8") as f:
104
  data = json.load(f)
105
+ for sample in data:
106
+ image_path = os.path.join(root_dir, sample["file_name"])
107
+ with open(image_path, "rb") as file_obj:
108
+ yield image_path, {
109
+ "image": {"path": image_path, "bytes": file_obj.read()},
110
+ "caption": sample["caption"],
111
+ "components": {
112
+ "sex": sample.get("sex"),
113
+ "race": sample.get("race"),
114
+ "class": sample.get("class"),
115
+ "inherent_features": sample.get("inherent_features"),
116
+ "clothing": sample.get("clothing"),
117
+ "accessories": sample.get("accessories"),
118
+ "background": sample.get("background"),
119
+ "shot": sample.get("shot"),
120
+ "view": sample.get("view"),
121
+ },
122
+ }