Initial commit
Browse filesThese files are added according to the fill50k dataset. Future changes in the structure might be needed.
- Distorted_Human_Images.py +145 -0
- distorted.zip +3 -0
- flawless.zip +3 -0
- mask.zip +3 -0
- original.zip +3 -0
- train.jsonl +8 -0
Distorted_Human_Images.py
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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.1")
|
| 7 |
+
|
| 8 |
+
_DESCRIPTION = "TODO"
|
| 9 |
+
_HOMEPAGE = "TODO"
|
| 10 |
+
_LICENSE = "TODO"
|
| 11 |
+
_CITATION = "TODO"
|
| 12 |
+
|
| 13 |
+
_FEATURES = datasets.Features(
|
| 14 |
+
{
|
| 15 |
+
"flawless": datasets.Image(),
|
| 16 |
+
"distorted": datasets.Image(),
|
| 17 |
+
"mask": datasets.Image(),
|
| 18 |
+
"original": datasets.Image(),
|
| 19 |
+
"prompt": datasets.Value("string"),
|
| 20 |
+
},
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
METADATA_URL = hf_hub_url(
|
| 24 |
+
"NegarMov/Distorted_Human_Images",
|
| 25 |
+
filename="train.jsonl",
|
| 26 |
+
repo_type="dataset",
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
FLAWLESS_URL = hf_hub_url(
|
| 30 |
+
"NegarMov/Distorted_Human_Images",
|
| 31 |
+
filename="flawless.zip",
|
| 32 |
+
repo_type="dataset",
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
DISTORTED_URL = hf_hub_url(
|
| 36 |
+
"NegarMov/Distorted_Human_Images",
|
| 37 |
+
filename="distorted.zip",
|
| 38 |
+
repo_type="dataset",
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
MASK_URL = hf_hub_url(
|
| 42 |
+
"NegarMov/Distorted_Human_Images",
|
| 43 |
+
filename="mask.zip",
|
| 44 |
+
repo_type="dataset",
|
| 45 |
+
)
|
| 46 |
+
|
| 47 |
+
ORIGINAL_URL = hf_hub_url(
|
| 48 |
+
"NegarMov/Distorted_Human_Images",
|
| 49 |
+
filename="original.zip",
|
| 50 |
+
repo_type="dataset",
|
| 51 |
+
)
|
| 52 |
+
|
| 53 |
+
_DEFAULT_CONFIG = datasets.BuilderConfig(name="default", version=_VERSION)
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
class Distorted_Human_Images(datasets.GeneratorBasedBuilder):
|
| 57 |
+
BUILDER_CONFIGS = [_DEFAULT_CONFIG]
|
| 58 |
+
DEFAULT_CONFIG_NAME = "default"
|
| 59 |
+
|
| 60 |
+
def _info(self):
|
| 61 |
+
return datasets.DatasetInfo(
|
| 62 |
+
description=_DESCRIPTION,
|
| 63 |
+
features=_FEATURES,
|
| 64 |
+
supervised_keys=None,
|
| 65 |
+
homepage=_HOMEPAGE,
|
| 66 |
+
license=_LICENSE,
|
| 67 |
+
citation=_CITATION,
|
| 68 |
+
)
|
| 69 |
+
|
| 70 |
+
def _split_generators(self, dl_manager):
|
| 71 |
+
metadata_path = dl_manager.download(METADATA_URL)
|
| 72 |
+
flawless_dir = dl_manager.download_and_extract(
|
| 73 |
+
FLAWLESS_URL
|
| 74 |
+
)
|
| 75 |
+
distorted_dir = dl_manager.download_and_extract(
|
| 76 |
+
DISTORTED_URL
|
| 77 |
+
)
|
| 78 |
+
mask_dir = dl_manager.download_and_extract(
|
| 79 |
+
MASK_URL
|
| 80 |
+
)
|
| 81 |
+
original_dir = dl_manager.download_and_extract(
|
| 82 |
+
ORIGINAL_URL
|
| 83 |
+
)
|
| 84 |
+
|
| 85 |
+
return [
|
| 86 |
+
datasets.SplitGenerator(
|
| 87 |
+
name=datasets.Split.TRAIN,
|
| 88 |
+
# These kwargs will be passed to _generate_examples
|
| 89 |
+
gen_kwargs={
|
| 90 |
+
"metadata_path": metadata_path,
|
| 91 |
+
"flawless_dir": flawless_dir,
|
| 92 |
+
"distorted_dir": distorted_dir,
|
| 93 |
+
"mask_dir": mask_dir,
|
| 94 |
+
"original_dir": original_dir,
|
| 95 |
+
},
|
| 96 |
+
),
|
| 97 |
+
]
|
| 98 |
+
|
| 99 |
+
def _generate_examples(self, metadata_path, flawless_dir, distorted_dir, mask_dir, original_dir):
|
| 100 |
+
metadata = pd.read_json(metadata_path, lines=True)
|
| 101 |
+
|
| 102 |
+
for _, row in metadata.iterrows():
|
| 103 |
+
prompt = row["prompt"]
|
| 104 |
+
|
| 105 |
+
flawless_path = row["flawless"]
|
| 106 |
+
flawless_path = os.path.join(flawless_dir, flawless_path)
|
| 107 |
+
flawless = open(flawless_path, "rb").read()
|
| 108 |
+
|
| 109 |
+
distorted_path = row["distorted"]
|
| 110 |
+
distorted_path = os.path.join(
|
| 111 |
+
distorted_dir, row["distorted"]
|
| 112 |
+
)
|
| 113 |
+
distorted = open(distorted_path, "rb").read()
|
| 114 |
+
|
| 115 |
+
mask_path = row["mask"]
|
| 116 |
+
mask_path = os.path.join(
|
| 117 |
+
mask_dir, row["mask"]
|
| 118 |
+
)
|
| 119 |
+
mask = open(mask_path, "rb").read()
|
| 120 |
+
|
| 121 |
+
original_path = row["original"]
|
| 122 |
+
original_path = os.path.join(
|
| 123 |
+
original_dir, row["original"]
|
| 124 |
+
)
|
| 125 |
+
original = open(original_path, "rb").read()
|
| 126 |
+
|
| 127 |
+
yield row["flawless"], {
|
| 128 |
+
"prompt": prompt,
|
| 129 |
+
"flawless": {
|
| 130 |
+
"path": flawless_path,
|
| 131 |
+
"bytes": flawless,
|
| 132 |
+
},
|
| 133 |
+
"distorted": {
|
| 134 |
+
"path": distorted_path,
|
| 135 |
+
"bytes": distorted,
|
| 136 |
+
},
|
| 137 |
+
"mask": {
|
| 138 |
+
"path": mask_path,
|
| 139 |
+
"bytes": mask,
|
| 140 |
+
},
|
| 141 |
+
"original": {
|
| 142 |
+
"path": original_path,
|
| 143 |
+
"bytes": original,
|
| 144 |
+
},
|
| 145 |
+
}
|
distorted.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6a8680a11aee35929216c297b56b33ad84d4cb8ef625cdf6fe4a95a52340c437
|
| 3 |
+
size 1680046
|
flawless.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a25df9b1c4f422c6cce3dd4a8fc8847a22e18e10d32098bb43c90a51f2a842fd
|
| 3 |
+
size 141708
|
mask.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:646c1ba8b3bba95d601c334765a23fb5f07b2567dfba2791e0f9c7d4232f8f0e
|
| 3 |
+
size 10643
|
original.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:05c14933796dc76fa0d38510aa02176d69e9b332f95917c19faf2b0a4275f26a
|
| 3 |
+
size 115824
|
train.jsonl
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"prompt": "high quality, detailed, professional photograph of a woman standing", "flawless": "flawless/1.png", "distorted": "distorted/1.png", "mask": "mask/1.png", original: "original/1.png"}
|
| 2 |
+
{"prompt": "high quality, detailed, professional photograph of a woman standing", "flawless": "flawless/2.png", "distorted": "distorted/2.png", "mask": "mask/2.png", original: "original/2.png"}
|
| 3 |
+
{"prompt": "high quality, detailed, professional photograph of a woman standing", "flawless": "flawless/3.png", "distorted": "distorted/3.png", "mask": "mask/3.png", original: "original/3.png"}
|
| 4 |
+
{"prompt": "high quality, detailed, professional photograph of a woman standing", "flawless": "flawless/4.png", "distorted": "distorted/4.png", "mask": "mask/4.png", original: "original/4.png"}
|
| 5 |
+
{"prompt": "high quality, detailed, professional photograph of a woman standing", "flawless": "flawless/5.png", "distorted": "distorted/5.png", "mask": "mask/5.png", original: "original/5.png"}
|
| 6 |
+
{"prompt": "high quality, detailed, professional photograph of a woman standing", "flawless": "flawless/6.png", "distorted": "distorted/6.png", "mask": "mask/6.png", original: "original/6.png"}
|
| 7 |
+
{"prompt": "high quality, detailed, professional photograph of a woman standing", "flawless": "flawless/7.png", "distorted": "distorted/7.png", "mask": "mask/7.png", original: "original/7.png"}
|
| 8 |
+
{"prompt": "high quality, detailed, professional photograph of a woman standing", "flawless": "flawless/8.png", "distorted": "distorted/8.png", "mask": "mask/8.png", original: "original/8.png"}
|