Upload 4 files
Browse files- conditioning_images.zip +3 -0
- images.zip +3 -0
- labelfill10k.py +99 -0
- prompt.json +0 -0
conditioning_images.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4a31ee0c10335d613bd6f3d7dd3f7ebd4084d998231c2088fc4efcde2a9e8c56
|
3 |
+
size 49246032
|
images.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:25f026181c8c8f883c7e08dfb3f356b91f873468f826c00b27a01112605761c5
|
3 |
+
size 44583102
|
labelfill10k.py
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
from huggingface_hub import hf_hub_url
|
3 |
+
import datasets
|
4 |
+
import os
|
5 |
+
|
6 |
+
_VERSION = datasets.Version("0.0.2")
|
7 |
+
|
8 |
+
_DESCRIPTION = "TODO"
|
9 |
+
_HOMEPAGE = "TODO"
|
10 |
+
_LICENSE = "TODO"
|
11 |
+
_CITATION = "TODO"
|
12 |
+
|
13 |
+
_FEATURES = datasets.Features(
|
14 |
+
{
|
15 |
+
"image": datasets.Image(),
|
16 |
+
"conditioning_image": datasets.Image(),
|
17 |
+
"text": datasets.Value("string"),
|
18 |
+
},
|
19 |
+
)
|
20 |
+
|
21 |
+
METADATA_URL = hf_hub_url(
|
22 |
+
"triciahu/labelfill10k",
|
23 |
+
filename="prompt.json",
|
24 |
+
repo_type="dataset",
|
25 |
+
)
|
26 |
+
|
27 |
+
IMAGES_URL = hf_hub_url(
|
28 |
+
"triciahu/labelfill10k",
|
29 |
+
filename="images.zip",
|
30 |
+
repo_type="dataset",
|
31 |
+
)
|
32 |
+
|
33 |
+
CONDITIONING_IMAGES_URL = hf_hub_url(
|
34 |
+
"triciahu/labelfill10k",
|
35 |
+
filename="conditioning_images.zip",
|
36 |
+
repo_type="dataset",
|
37 |
+
)
|
38 |
+
|
39 |
+
_DEFAULT_CONFIG = datasets.BuilderConfig(name="default", version=_VERSION)
|
40 |
+
|
41 |
+
|
42 |
+
class labelfill10k(datasets.GeneratorBasedBuilder):
|
43 |
+
BUILDER_CONFIGS = [_DEFAULT_CONFIG]
|
44 |
+
DEFAULT_CONFIG_NAME = "default"
|
45 |
+
|
46 |
+
def _info(self):
|
47 |
+
return datasets.DatasetInfo(
|
48 |
+
description=_DESCRIPTION,
|
49 |
+
features=_FEATURES,
|
50 |
+
supervised_keys=None,
|
51 |
+
homepage=_HOMEPAGE,
|
52 |
+
license=_LICENSE,
|
53 |
+
citation=_CITATION,
|
54 |
+
)
|
55 |
+
|
56 |
+
def _split_generators(self, dl_manager):
|
57 |
+
metadata_path = dl_manager.download(METADATA_URL)
|
58 |
+
images_dir = dl_manager.download_and_extract(IMAGES_URL)
|
59 |
+
conditioning_images_dir = dl_manager.download_and_extract(
|
60 |
+
CONDITIONING_IMAGES_URL
|
61 |
+
)
|
62 |
+
|
63 |
+
return [
|
64 |
+
datasets.SplitGenerator(
|
65 |
+
name=datasets.Split.TRAIN,
|
66 |
+
# These kwargs will be passed to _generate_examples
|
67 |
+
gen_kwargs={
|
68 |
+
"metadata_path": metadata_path,
|
69 |
+
"images_dir": images_dir,
|
70 |
+
"conditioning_images_dir": conditioning_images_dir,
|
71 |
+
},
|
72 |
+
),
|
73 |
+
]
|
74 |
+
|
75 |
+
def _generate_examples(self, metadata_path, images_dir, conditioning_images_dir):
|
76 |
+
metadata = pd.read_json(metadata_path, lines=True)
|
77 |
+
|
78 |
+
for _, row in metadata.iterrows():
|
79 |
+
text = row["prompt"]
|
80 |
+
|
81 |
+
image_path = row["target"]
|
82 |
+
image_path = os.path.join(images_dir, image_path)
|
83 |
+
image = open(image_path, "rb").read()
|
84 |
+
|
85 |
+
conditioning_image_path = row["source"]
|
86 |
+
conditioning_image_path = os.path.join(conditioning_images_dir, conditioning_image_path)
|
87 |
+
conditioning_image = open(image_path, "rb").read()
|
88 |
+
|
89 |
+
yield row["target"], {
|
90 |
+
"text": text,
|
91 |
+
"image": {
|
92 |
+
"path": image_path,
|
93 |
+
"bytes": image,
|
94 |
+
},
|
95 |
+
"conditioning_image": {
|
96 |
+
"path": conditioning_image_path,
|
97 |
+
"bytes": conditioning_image,
|
98 |
+
},
|
99 |
+
}
|
prompt.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|