NegarMov commited on
Commit
2310c93
·
1 Parent(s): 17fcc87

Upload dataset files

Browse files
Files changed (5) hide show
  1. DF_segmented_mask.py +124 -0
  2. flawless.zip +3 -0
  3. mask.zip +3 -0
  4. reference.zip +3 -0
  5. train.jsonl +0 -0
DF_segmented_mask.py ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "mask": datasets.Image(),
17
+ "reference": datasets.Image(),
18
+ "prompt": datasets.Value("string"),
19
+ },
20
+ )
21
+
22
+ METADATA_URL = hf_hub_url(
23
+ "NegarMov/DF_segmented_mask",
24
+ filename="train.jsonl",
25
+ repo_type="dataset",
26
+ )
27
+
28
+ FLAWLESS_URL = hf_hub_url(
29
+ "NegarMov/DF_segmented_mask",
30
+ filename="flawless.zip",
31
+ repo_type="dataset",
32
+ )
33
+
34
+ MASK_URL = hf_hub_url(
35
+ "NegarMov/DF_segmented_mask",
36
+ filename="mask.zip",
37
+ repo_type="dataset",
38
+ )
39
+
40
+ reference_URL = hf_hub_url(
41
+ "NegarMov/DF_segmented_mask",
42
+ filename="reference.zip",
43
+ repo_type="dataset",
44
+ )
45
+
46
+ _DEFAULT_CONFIG = datasets.BuilderConfig(name="default", version=_VERSION)
47
+
48
+
49
+ class DF_segmented_mask(datasets.GeneratorBasedBuilder):
50
+ BUILDER_CONFIGS = [_DEFAULT_CONFIG]
51
+ DEFAULT_CONFIG_NAME = "default"
52
+
53
+ def _info(self):
54
+ return datasets.DatasetInfo(
55
+ description=_DESCRIPTION,
56
+ features=_FEATURES,
57
+ supervised_keys=None,
58
+ homepage=_HOMEPAGE,
59
+ license=_LICENSE,
60
+ citation=_CITATION,
61
+ )
62
+
63
+ def _split_generators(self, dl_manager):
64
+ metadata_path = dl_manager.download(METADATA_URL)
65
+ flawless_dir = dl_manager.download_and_extract(
66
+ FLAWLESS_URL
67
+ )
68
+ mask_dir = dl_manager.download_and_extract(
69
+ MASK_URL
70
+ )
71
+ reference_dir = dl_manager.download_and_extract(
72
+ reference_URL
73
+ )
74
+
75
+ return [
76
+ datasets.SplitGenerator(
77
+ name=datasets.Split.TRAIN,
78
+ # These kwargs will be passed to _generate_examples
79
+ gen_kwargs={
80
+ "metadata_path": metadata_path,
81
+ "flawless_dir": flawless_dir,
82
+ "mask_dir": mask_dir,
83
+ "reference_dir": reference_dir,
84
+ },
85
+ ),
86
+ ]
87
+
88
+ def _generate_examples(self, metadata_path, flawless_dir, mask_dir, reference_dir):
89
+ metadata = pd.read_json(metadata_path, lines=True)
90
+
91
+ for _, row in metadata.iterrows():
92
+ prompt = row["prompt"]
93
+
94
+ flawless_path = row["flawless"]
95
+ flawless_path = os.path.join(flawless_dir, flawless_path)
96
+ flawless = open(flawless_path, "rb").read()
97
+
98
+ mask_path = row["mask"]
99
+ mask_path = os.path.join(
100
+ mask_dir, row["mask"]
101
+ )
102
+ mask = open(mask_path, "rb").read()
103
+
104
+ reference_path = row["reference"]
105
+ reference_path = os.path.join(
106
+ reference_dir, row["reference"]
107
+ )
108
+ reference = open(reference_path, "rb").read()
109
+
110
+ yield row["flawless"], {
111
+ "prompt": prompt,
112
+ "flawless": {
113
+ "path": flawless_path,
114
+ "bytes": flawless,
115
+ },
116
+ "mask": {
117
+ "path": mask_path,
118
+ "bytes": mask,
119
+ },
120
+ "reference": {
121
+ "path": reference_path,
122
+ "bytes": reference,
123
+ },
124
+ }
flawless.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5090c6b4fb01c647e0ca1ee0e703bac396be76ff932263466e050a025d30b26e
3
+ size 100028209
mask.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1b706e37b3a28150b9d9674e74e6f308e72dbeec4b20987a35691396cc9f5e71
3
+ size 23283557
reference.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5c2585692c9468f6473566ea74eb4a5215a4c7761a1afead845b66e47b0b5bbe
3
+ size 101138075
train.jsonl ADDED
The diff for this file is too large to render. See raw diff