turn_into_zip
#1
by
Jorgvt
- opened
- TID2008.py +29 -19
- data.zip +3 -0
TID2008.py
CHANGED
@@ -21,6 +21,7 @@ _HOMEPAGE = "https://www.ponomarenko.info/tid2008.htm"
|
|
21 |
|
22 |
# _LICENSE = ""
|
23 |
|
|
|
24 |
class TID2008(datasets.GeneratorBasedBuilder):
|
25 |
"""TID2008 Image Quality Dataset"""
|
26 |
|
@@ -32,7 +33,7 @@ class TID2008(datasets.GeneratorBasedBuilder):
|
|
32 |
{
|
33 |
"reference": datasets.Image(),
|
34 |
"distorted": datasets.Image(),
|
35 |
-
"mos": datasets.Value("float")
|
36 |
}
|
37 |
)
|
38 |
return datasets.DatasetInfo(
|
@@ -45,32 +46,41 @@ class TID2008(datasets.GeneratorBasedBuilder):
|
|
45 |
)
|
46 |
|
47 |
def _split_generators(self, dl_manager):
|
48 |
-
data_path = dl_manager.download("
|
49 |
-
data = pd.read_csv(data_path, index_col=0)
|
50 |
-
|
51 |
-
reference_paths = data["Reference"].apply(lambda x: os.path.join("reference_images", x)).to_list()
|
52 |
-
distorted_paths = data["Distorted"].apply(lambda x: os.path.join("distorted_images", x)).to_list()
|
53 |
-
|
54 |
-
reference_paths = dl_manager.download(reference_paths)
|
55 |
-
distorted_paths = dl_manager.download(distorted_paths)
|
56 |
|
57 |
return [
|
58 |
datasets.SplitGenerator(
|
59 |
name=datasets.Split.TRAIN,
|
60 |
gen_kwargs={
|
61 |
-
"
|
62 |
-
"distorted": distorted_paths,
|
63 |
-
"mos": data["MOS"],
|
64 |
"split": "train",
|
65 |
},
|
66 |
)
|
67 |
]
|
68 |
|
69 |
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
70 |
-
def _generate_examples(self,
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
# _LICENSE = ""
|
23 |
|
24 |
+
|
25 |
class TID2008(datasets.GeneratorBasedBuilder):
|
26 |
"""TID2008 Image Quality Dataset"""
|
27 |
|
|
|
33 |
{
|
34 |
"reference": datasets.Image(),
|
35 |
"distorted": datasets.Image(),
|
36 |
+
"mos": datasets.Value("float"),
|
37 |
}
|
38 |
)
|
39 |
return datasets.DatasetInfo(
|
|
|
46 |
)
|
47 |
|
48 |
def _split_generators(self, dl_manager):
|
49 |
+
data_path = dl_manager.download("data.zip")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
return [
|
52 |
datasets.SplitGenerator(
|
53 |
name=datasets.Split.TRAIN,
|
54 |
gen_kwargs={
|
55 |
+
"data": dl_manager.download_and_extract(data_path),
|
|
|
|
|
56 |
"split": "train",
|
57 |
},
|
58 |
)
|
59 |
]
|
60 |
|
61 |
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
62 |
+
def _generate_examples(self, data, split):
|
63 |
+
df = pd.read_csv(os.path.join(data, "image_pairs_mos.csv"), index_col=0)
|
64 |
+
reference_paths = (
|
65 |
+
df["Reference"]
|
66 |
+
.apply(lambda x: os.path.join(data, "reference_images", x))
|
67 |
+
.to_list()
|
68 |
+
)
|
69 |
+
distorted_paths = (
|
70 |
+
df["Distorted"]
|
71 |
+
.apply(lambda x: os.path.join(data, "distorted_images", x))
|
72 |
+
.to_list()
|
73 |
+
)
|
74 |
+
|
75 |
+
for key, (ref, dist, m) in enumerate(
|
76 |
+
zip(reference_paths, distorted_paths, df["MOS"])
|
77 |
+
):
|
78 |
+
yield (
|
79 |
+
key,
|
80 |
+
{
|
81 |
+
"reference": ref,
|
82 |
+
"distorted": dist,
|
83 |
+
"mos": m,
|
84 |
+
},
|
85 |
+
)
|
86 |
+
|
data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c048c69418cb0146fe8363f637a35e16623ca6ce25a8b6bfcdd9fb47e85ecaf6
|
3 |
+
size 704640392
|