Upload fusing_fill50k.py
Browse files- fusing_fill50k.py +21 -36
fusing_fill50k.py
CHANGED
|
@@ -5,18 +5,21 @@ import os
|
|
| 5 |
|
| 6 |
_VERSION = datasets.Version("0.0.2")
|
| 7 |
|
| 8 |
-
_DESCRIPTION = "
|
| 9 |
-
_HOMEPAGE = "
|
| 10 |
-
_LICENSE = "
|
| 11 |
-
_CITATION = "
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
)
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
METADATA_URL = hf_hub_url(
|
| 22 |
"spine-crook/test_dataset",
|
|
@@ -38,7 +41,6 @@ CONDITIONING_IMAGES_URL = hf_hub_url(
|
|
| 38 |
|
| 39 |
_DEFAULT_CONFIG = datasets.BuilderConfig(name="default", version=_VERSION)
|
| 40 |
|
| 41 |
-
|
| 42 |
class Fill50k(datasets.GeneratorBasedBuilder):
|
| 43 |
BUILDER_CONFIGS = [_DEFAULT_CONFIG]
|
| 44 |
DEFAULT_CONFIG_NAME = "default"
|
|
@@ -56,14 +58,11 @@ class Fill50k(datasets.GeneratorBasedBuilder):
|
|
| 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,
|
|
@@ -77,25 +76,11 @@ class Fill50k(datasets.GeneratorBasedBuilder):
|
|
| 77 |
|
| 78 |
for _, row in metadata.iterrows():
|
| 79 |
text = row["text"]
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
image_path = os.path.join(images_dir, image_path)
|
| 83 |
-
image = open(image_path, "rb").read()
|
| 84 |
-
|
| 85 |
-
conditioning_image_path = row["conditioning_image"]
|
| 86 |
-
conditioning_image_path = os.path.join(
|
| 87 |
-
conditioning_images_dir, row["conditioning_image"]
|
| 88 |
-
)
|
| 89 |
-
conditioning_image = open(conditioning_image_path, "rb").read()
|
| 90 |
|
| 91 |
yield row["image"], {
|
| 92 |
"text": text,
|
| 93 |
-
"image":
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
},
|
| 97 |
-
"conditioning_image": {
|
| 98 |
-
"path": conditioning_image_path,
|
| 99 |
-
"bytes": conditioning_image,
|
| 100 |
-
},
|
| 101 |
-
}
|
|
|
|
| 5 |
|
| 6 |
_VERSION = datasets.Version("0.0.2")
|
| 7 |
|
| 8 |
+
_DESCRIPTION = "This dataset includes images and conditioning images for XYZ purpose."
|
| 9 |
+
_HOMEPAGE = "https://www.example.com"
|
| 10 |
+
_LICENSE = "MIT"
|
| 11 |
+
_CITATION = """@article{YourDataset2021,
|
| 12 |
+
title={Your Dataset Title},
|
| 13 |
+
author={Your Name},
|
| 14 |
+
journal={Your Journal},
|
| 15 |
+
year={2021}
|
| 16 |
+
}"""
|
| 17 |
+
|
| 18 |
+
_FEATURES = datasets.Features({
|
| 19 |
+
"image": datasets.Value("string"), # Change from datasets.Image() to Value("string") if using paths directly
|
| 20 |
+
"conditioning_image": datasets.Value("string"),
|
| 21 |
+
"text": datasets.Value("string"),
|
| 22 |
+
})
|
| 23 |
|
| 24 |
METADATA_URL = hf_hub_url(
|
| 25 |
"spine-crook/test_dataset",
|
|
|
|
| 41 |
|
| 42 |
_DEFAULT_CONFIG = datasets.BuilderConfig(name="default", version=_VERSION)
|
| 43 |
|
|
|
|
| 44 |
class Fill50k(datasets.GeneratorBasedBuilder):
|
| 45 |
BUILDER_CONFIGS = [_DEFAULT_CONFIG]
|
| 46 |
DEFAULT_CONFIG_NAME = "default"
|
|
|
|
| 58 |
def _split_generators(self, dl_manager):
|
| 59 |
metadata_path = dl_manager.download(METADATA_URL)
|
| 60 |
images_dir = dl_manager.download_and_extract(IMAGES_URL)
|
| 61 |
+
conditioning_images_dir = dl_manager.download_and_extract(CONDITIONING_IMAGES_URL)
|
|
|
|
|
|
|
| 62 |
|
| 63 |
return [
|
| 64 |
datasets.SplitGenerator(
|
| 65 |
name=datasets.Split.TRAIN,
|
|
|
|
| 66 |
gen_kwargs={
|
| 67 |
"metadata_path": metadata_path,
|
| 68 |
"images_dir": images_dir,
|
|
|
|
| 76 |
|
| 77 |
for _, row in metadata.iterrows():
|
| 78 |
text = row["text"]
|
| 79 |
+
image_path = os.path.join(images_dir, row["image"])
|
| 80 |
+
conditioning_image_path = os.path.join(conditioning_images_dir, row["conditioning_image"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
yield row["image"], {
|
| 83 |
"text": text,
|
| 84 |
+
"image": image_path,
|
| 85 |
+
"conditioning_image": conditioning_image_path,
|
| 86 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|