cleaned file
Browse files- TID2008.py +1 -47
TID2008.py
CHANGED
@@ -1,12 +1,7 @@
|
|
1 |
-
import csv
|
2 |
-
import json
|
3 |
import os
|
4 |
-
from PIL import Image
|
5 |
|
6 |
import pandas as pd
|
7 |
-
from huggingface_hub import hf_hub_download, snapshot_download
|
8 |
import datasets
|
9 |
-
import cv2
|
10 |
|
11 |
# _CITATION = """\
|
12 |
# @InProceedings{huggingface:dataset,
|
@@ -26,17 +21,6 @@ In total there are 1700 (reference, distortion, MOS) tuples.
|
|
26 |
|
27 |
# _LICENSE = ""
|
28 |
|
29 |
-
# TODO: Add link to the official dataset URLs here
|
30 |
-
# The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
|
31 |
-
# This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
|
32 |
-
# _URLS = {
|
33 |
-
# "first_domain": "https://huggingface.co/great-new-dataset-first_domain.zip",
|
34 |
-
# "second_domain": "https://huggingface.co/great-new-dataset-second_domain.zip",
|
35 |
-
# }
|
36 |
-
|
37 |
-
# _REPO = "https://huggingface.co/datasets/frgfm/imagenette/resolve/main/metadata" # Stolen from imagenette.py
|
38 |
-
_REPO = "https://huggingface.co/datasets/Jorgvt/TID2008/resolve/main"
|
39 |
-
|
40 |
class TID2008(datasets.GeneratorBasedBuilder):
|
41 |
"""TID2008 Image Quality Dataset"""
|
42 |
|
@@ -63,31 +47,17 @@ class TID2008(datasets.GeneratorBasedBuilder):
|
|
63 |
def _split_generators(self, dl_manager):
|
64 |
data_path = dl_manager.download("image_pairs_mos.csv")
|
65 |
data = pd.read_csv(data_path, index_col=0)
|
66 |
-
|
67 |
-
# kk = dl_manager.download("distorted_images")
|
68 |
-
# print(kk)
|
69 |
-
|
70 |
-
root_path = "/".join(data_path.split("/")[:-1])
|
71 |
-
# reference_path = dl_manager.download("reference_images")
|
72 |
-
# distorted_path = dl_manager.download("distorted_images")
|
73 |
|
74 |
reference_paths = data["Reference"].apply(lambda x: os.path.join("reference_images", x)).to_list()
|
75 |
distorted_paths = data["Distorted"].apply(lambda x: os.path.join("distorted_images", x)).to_list()
|
76 |
|
77 |
reference_paths = dl_manager.download(reference_paths)
|
78 |
distorted_paths = dl_manager.download(distorted_paths)
|
79 |
-
|
80 |
-
# dl_manager.download(data["Reference"])
|
81 |
-
|
82 |
-
# data["Reference"] = data["Reference"].apply(lambda x: os.path.join(reference_path, x))
|
83 |
-
# data["Distorted"] = data["Distorted"].apply(lambda x: os.path.join(distorted_path, x))
|
84 |
|
85 |
return [
|
86 |
datasets.SplitGenerator(
|
87 |
name=datasets.Split.TRAIN,
|
88 |
gen_kwargs={
|
89 |
-
# "reference": data["Reference"],
|
90 |
-
# "distorted": data["Distorted"],
|
91 |
"reference": reference_paths,
|
92 |
"distorted": distorted_paths,
|
93 |
"mos": data["MOS"],
|
@@ -103,20 +73,4 @@ class TID2008(datasets.GeneratorBasedBuilder):
|
|
103 |
"reference": ref,
|
104 |
"distorted": dist,
|
105 |
"mos": m,
|
106 |
-
}
|
107 |
-
# with open(filepath, encoding="utf-8") as f:
|
108 |
-
# for key, row in enumerate(f):
|
109 |
-
# data = json.loads(row)
|
110 |
-
# if self.config.name == "first_domain":
|
111 |
-
# # Yields examples as (key, example) tuples
|
112 |
-
# yield key, {
|
113 |
-
# "sentence": data["sentence"],
|
114 |
-
# "option1": data["option1"],
|
115 |
-
# "answer": "" if split == "test" else data["answer"],
|
116 |
-
# }
|
117 |
-
# else:
|
118 |
-
# yield key, {
|
119 |
-
# "sentence": data["sentence"],
|
120 |
-
# "option2": data["option2"],
|
121 |
-
# "second_domain_answer": "" if split == "test" else data["second_domain_answer"],
|
122 |
-
# }
|
|
|
|
|
|
|
1 |
import os
|
|
|
2 |
|
3 |
import pandas as pd
|
|
|
4 |
import datasets
|
|
|
5 |
|
6 |
# _CITATION = """\
|
7 |
# @InProceedings{huggingface:dataset,
|
|
|
21 |
|
22 |
# _LICENSE = ""
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
class TID2008(datasets.GeneratorBasedBuilder):
|
25 |
"""TID2008 Image Quality Dataset"""
|
26 |
|
|
|
47 |
def _split_generators(self, dl_manager):
|
48 |
data_path = dl_manager.download("image_pairs_mos.csv")
|
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 |
"reference": reference_paths,
|
62 |
"distorted": distorted_paths,
|
63 |
"mos": data["MOS"],
|
|
|
73 |
"reference": ref,
|
74 |
"distorted": dist,
|
75 |
"mos": m,
|
76 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|