@@ -97,12 +97,14 @@ def _info(self):
97
97
"lr" : tfds .features .Image (),
98
98
"hr" : tfds .features .Image (),
99
99
}),
100
+ supervised_keys = ("lr" , "hr" ),
100
101
homepage = _DL_URL ,
101
102
citation = _CITATION ,
102
103
)
103
104
104
105
def _split_generators (self , dl_manager ):
105
106
"""Returns SplitGenerators."""
107
+ print ("EXTRACTING" , self .builder_config .download_urls )
106
108
extracted_paths = dl_manager .download_and_extract (
107
109
self .builder_config .download_urls )
108
110
@@ -125,16 +127,10 @@ def _split_generators(self, dl_manager):
125
127
126
128
def _generate_examples (self , lr_path , hr_path ):
127
129
"""Yields examples."""
128
- if not tf .io .gfile .listdir (hr_path )[0 ].endswith (".png" ):
129
- hr_path = os .path .join (hr_path , tf .io .gfile .listdir (hr_path )[0 ])
130
-
131
130
for root , _ , files in tf .io .gfile .walk (lr_path ):
132
- if len (files ):
133
- for file_path in files :
134
- yield root + file_path , {
135
- "lr" : os .path .join (root , file_path ),
136
- #extract for corresponding file with matching 4 digit id
137
- "hr" : os .path .join (hr_path ,
138
- re .search (r'\d{4}' ,
139
- str (file_path )).group (0 ) + ".png" )
140
- }
131
+ for file_path in files :
132
+ yield file_path , {
133
+ "lr" : os .path .join (root , file_path ),
134
+ #Extract the image id from the filename: "0001x2.png"
135
+ "hr" : os .path .join (hr_path , file_path [:4 ]+ ".png" )
136
+ }
0 commit comments