Jorgvt commited on
Commit
0517072
1 Parent(s): 39d11fb

turn_into_zip (#1)

Browse files

- :sparkles: added zip file (ca3bba9ef2b384038aa769b784bb1115eb5cf755)
- :sparkles: added support for zip file (c1fe403ea45786652da9a35ac76586af9d5ea378)

Files changed (2) hide show
  1. TID2013.py +28 -19
  2. data.zip +3 -0
TID2013.py CHANGED
@@ -33,6 +33,7 @@ _HOMEPAGE = "https://www.ponomarenko.info/tid2013.htm"
33
 
34
  # _LICENSE = ""
35
 
 
36
  class TID2013(datasets.GeneratorBasedBuilder):
37
  """TID2013 Image Quality Dataset"""
38
 
@@ -44,7 +45,7 @@ class TID2013(datasets.GeneratorBasedBuilder):
44
  {
45
  "reference": datasets.Image(),
46
  "distorted": datasets.Image(),
47
- "mos": datasets.Value("float")
48
  }
49
  )
50
  return datasets.DatasetInfo(
@@ -57,32 +58,40 @@ class TID2013(datasets.GeneratorBasedBuilder):
57
  )
58
 
59
  def _split_generators(self, dl_manager):
60
- data_path = dl_manager.download("image_pairs_mos.csv")
61
- data = pd.read_csv(data_path, index_col=0)
62
-
63
- reference_paths = data["Reference"].apply(lambda x: os.path.join("reference_images", x)).to_list()
64
- distorted_paths = data["Distorted"].apply(lambda x: os.path.join("distorted_images", x)).to_list()
65
-
66
- reference_paths = dl_manager.download(reference_paths)
67
- distorted_paths = dl_manager.download(distorted_paths)
68
 
69
  return [
70
  datasets.SplitGenerator(
71
  name=datasets.Split.TRAIN,
72
  gen_kwargs={
73
- "reference": reference_paths,
74
- "distorted": distorted_paths,
75
- "mos": data["MOS"],
76
  "split": "train",
77
  },
78
  )
79
  ]
80
 
81
  # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
82
- def _generate_examples(self, reference, distorted, mos, split):
83
- for key, (ref, dist, m) in enumerate(zip(reference, distorted, mos)):
84
- yield key, {
85
- "reference": ref,
86
- "distorted": dist,
87
- "mos": m,
88
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
  # _LICENSE = ""
35
 
36
+
37
  class TID2013(datasets.GeneratorBasedBuilder):
38
  """TID2013 Image Quality Dataset"""
39
 
 
45
  {
46
  "reference": datasets.Image(),
47
  "distorted": datasets.Image(),
48
+ "mos": datasets.Value("float"),
49
  }
50
  )
51
  return datasets.DatasetInfo(
 
58
  )
59
 
60
  def _split_generators(self, dl_manager):
61
+ data_path = dl_manager.download("data.zip")
 
 
 
 
 
 
 
62
 
63
  return [
64
  datasets.SplitGenerator(
65
  name=datasets.Split.TRAIN,
66
  gen_kwargs={
67
+ "data": dl_manager.download_and_extract(data_path),
 
 
68
  "split": "train",
69
  },
70
  )
71
  ]
72
 
73
  # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
74
+ def _generate_examples(self, data, split):
75
+ df = pd.read_csv(os.path.join(data, "image_pairs_mos.csv"), index_col=0)
76
+ reference_paths = (
77
+ df["Reference"]
78
+ .apply(lambda x: os.path.join(data, "reference_images", x))
79
+ .to_list()
80
+ )
81
+ distorted_paths = (
82
+ df["Distorted"]
83
+ .apply(lambda x: os.path.join(data, "distorted_images", x))
84
+ .to_list()
85
+ )
86
+
87
+ for key, (ref, dist, m) in enumerate(
88
+ zip(reference_paths, distorted_paths, df["MOS"])
89
+ ):
90
+ yield (
91
+ key,
92
+ {
93
+ "reference": ref,
94
+ "distorted": dist,
95
+ "mos": m,
96
+ },
97
+ )
data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:56b7bf4d6b4c498b80f52cb32422cb1b6c88d8095915582d4c7e465c5cad477f
3
+ size 1218738971