rvorias commited on
Commit
766f54f
1 Parent(s): eb2f979
Files changed (4) hide show
  1. README.md +49 -0
  2. data/images_001.zip +3 -0
  3. metadata.json +3 -0
  4. realms_adventurers.py +126 -0
README.md ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ task_categories:
4
+ - text-to-image
5
+ language:
6
+ - en
7
+ tags:
8
+ - stable-diffusion
9
+ - realms
10
+ pretty_name: Realms Adventurers Dataset
11
+ size_categories:
12
+ - n<1K
13
+ ---
14
+
15
+ # Realms Adventurer Dataset for Text-to-Image
16
+
17
+ This dataset contains annotated image-caption pairs with a specific structure.
18
+
19
+ ## Example
20
+
21
+ ```json
22
+ {
23
+ "file_name": "91200682-07_giants.png",
24
+ "sex": "male",
25
+ "race": "giant",
26
+ "class": "mage",
27
+ "inherent_features": "red flowers growing on his skin",
28
+ "clothing": "brown leather pants",
29
+ "accessories": null,
30
+ "background": "between tall red trees",
31
+ "shot": "full",
32
+ "view": "frontal",
33
+ "caption": "a male giant mage with red flowers growing on his skin, wearing brown leather pants, between tall red trees, full, frontal"
34
+ }
35
+ ```
36
+
37
+ ## Usage
38
+
39
+ ```python
40
+ import datasets
41
+
42
+ dataset = datasets.load_dataset("rvorias/realms_adventurers")
43
+
44
+ dataset["train"][0]
45
+ ```
46
+
47
+ ## Annotation tooling
48
+
49
+ Label-studio was used to organize and create annotations.
data/images_001.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b96fdea763d54939fbd8de3936ababd9fada7569a735f5b39b6dbbdbb27f98b5
3
+ size 177930282
metadata.json ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c5f4130f05744481cdf6a52a835413cdd6c3a469c5c489f6a2ab03875800b047
3
+ size 89974
realms_adventurers.py ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ import json
16
+ import os
17
+
18
+ import datasets
19
+ from huggingface_hub import hf_hub_url
20
+
21
+
22
+ _CITATION = ""
23
+ _DESCRIPTION = """This is the public dataset for the realms adventurer generator.
24
+ It contains images of characters and annotations to form structured captions."""
25
+
26
+ _HOMEPAGE = ""
27
+
28
+ _LICENSE = "https://docs.midjourney.com/docs/terms-of-service"
29
+
30
+ _URLS = {
31
+ "images": hf_hub_url(
32
+ "rvorias/realms_adventurers",
33
+ filename="images_001.zip",
34
+ subfolder="images",
35
+ repo_type="dataset",
36
+ ),
37
+ "metadata": hf_hub_url(
38
+ "rvorias/realms_adventurers",
39
+ filename=f"metadata.json",
40
+ repo_type="dataset",
41
+ ),
42
+ }
43
+
44
+
45
+ class RealmsAdventurersDataset(datasets.GeneratorBasedBuilder):
46
+ """Public dataset for the realms adventurer generator.
47
+ Containts images + structured captions."""
48
+
49
+ VERSION = datasets.Version("1.0.0")
50
+
51
+ def _info(self):
52
+ features = datasets.Features(
53
+ {
54
+ "image": datasets.Image(),
55
+ "caption": datasets.Value("string"),
56
+ "components": {
57
+ "sex": datasets.Value("string"),
58
+ "race": datasets.Value("string"),
59
+ "class": datasets.Value("string"),
60
+ "inherent_features": datasets.Value("string"),
61
+ "clothing": datasets.Value("string"),
62
+ "accessories": datasets.Value("string"),
63
+ "background": datasets.Value("string"),
64
+ "shot": datasets.Value("string"),
65
+ "view": datasets.Value("string"),
66
+ }
67
+ }
68
+ )
69
+ return datasets.DatasetInfo(
70
+ # This is the description that will appear on the datasets page.
71
+ description=_DESCRIPTION,
72
+ # This defines the different columns of the dataset and their types
73
+ features=features, # Here we define them above because they are different between the two configurations
74
+ supervised_keys=("image", "caption"),
75
+ # Homepage of the dataset for documentation
76
+ homepage=_HOMEPAGE,
77
+ # License for the dataset if available
78
+ license=_LICENSE,
79
+ # Citation for the dataset
80
+ citation=_CITATION,
81
+ )
82
+
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,
97
+ # These kwargs will be passed to _generate_examples
98
+ gen_kwargs={
99
+ "root_dir": images_dir,
100
+ "metadata_path": annotations_path,
101
+ },
102
+ ),
103
+ ]
104
+
105
+ # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
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
+ # }