upd: sharding problem try
Browse files- rwth_phoenix_weather_2014.py +25 -18
rwth_phoenix_weather_2014.py
CHANGED
@@ -97,9 +97,8 @@ class RWTHPhoenixWeather2014(datasets.GeneratorBasedBuilder):
|
|
97 |
)
|
98 |
|
99 |
def _split_generators(self, dl_manager: datasets.DownloadManager):
|
100 |
-
example_ids = {}
|
101 |
-
annotations = {}
|
102 |
frames = {}
|
|
|
103 |
|
104 |
dataDirMapper = {
|
105 |
datasets.Split.TRAIN: "train",
|
@@ -119,12 +118,12 @@ class RWTHPhoenixWeather2014(datasets.GeneratorBasedBuilder):
|
|
119 |
|
120 |
df = pd.read_csv(data_csv, sep='|')
|
121 |
|
122 |
-
example_ids
|
123 |
-
annotations
|
124 |
|
125 |
frame_archive_urls = dl_manager.download([
|
126 |
f"{base_url}/features/fullFrame-210x260px/{dataDirMapper[split]}/{id}.tar"
|
127 |
-
for id in example_ids
|
128 |
])
|
129 |
|
130 |
frames[split] = [
|
@@ -132,13 +131,22 @@ class RWTHPhoenixWeather2014(datasets.GeneratorBasedBuilder):
|
|
132 |
for url in frame_archive_urls
|
133 |
]
|
134 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
return [
|
136 |
datasets.SplitGenerator(
|
137 |
name=split,
|
138 |
gen_kwargs={
|
139 |
-
"
|
140 |
-
"
|
141 |
-
"frames": frames[split],
|
142 |
},
|
143 |
)
|
144 |
for split in [
|
@@ -148,22 +156,21 @@ class RWTHPhoenixWeather2014(datasets.GeneratorBasedBuilder):
|
|
148 |
]
|
149 |
]
|
150 |
|
151 |
-
def _generate_examples(self,
|
152 |
-
print(f"
|
153 |
-
print(f"
|
154 |
-
|
|
|
|
|
155 |
|
156 |
-
for key, (idx, annotation, frames_list) in enumerate(zip(example_ids, annotations, frames)):
|
157 |
result = {
|
158 |
-
"id":
|
159 |
-
"transcription": annotation,
|
160 |
}
|
161 |
|
162 |
-
print(frames[0])
|
163 |
-
|
164 |
if self.config.name != 'pre-training':
|
165 |
result["frames"] = [
|
166 |
-
{"path": p, "bytes": im.read()} for p, im in
|
167 |
]
|
168 |
|
169 |
yield key, result
|
|
|
97 |
)
|
98 |
|
99 |
def _split_generators(self, dl_manager: datasets.DownloadManager):
|
|
|
|
|
100 |
frames = {}
|
101 |
+
other_data = {}
|
102 |
|
103 |
dataDirMapper = {
|
104 |
datasets.Split.TRAIN: "train",
|
|
|
118 |
|
119 |
df = pd.read_csv(data_csv, sep='|')
|
120 |
|
121 |
+
example_ids = df['id']
|
122 |
+
annotations = df['annotation']
|
123 |
|
124 |
frame_archive_urls = dl_manager.download([
|
125 |
f"{base_url}/features/fullFrame-210x260px/{dataDirMapper[split]}/{id}.tar"
|
126 |
+
for id in example_ids
|
127 |
])
|
128 |
|
129 |
frames[split] = [
|
|
|
131 |
for url in frame_archive_urls
|
132 |
]
|
133 |
|
134 |
+
other_data_split = {}
|
135 |
+
|
136 |
+
for frame, idx, annotation, in zip(frames[split], example_ids, annotations):
|
137 |
+
other_data_split[frame] = {
|
138 |
+
"id": idx,
|
139 |
+
"annotation": annotation,
|
140 |
+
}
|
141 |
+
|
142 |
+
other_data[split] = other_data_split
|
143 |
+
|
144 |
return [
|
145 |
datasets.SplitGenerator(
|
146 |
name=split,
|
147 |
gen_kwargs={
|
148 |
+
"frame_archives": frames[split],
|
149 |
+
"other_data": other_data[split],
|
|
|
150 |
},
|
151 |
)
|
152 |
for split in [
|
|
|
156 |
]
|
157 |
]
|
158 |
|
159 |
+
def _generate_examples(self, frame_archives: list, other_data: dict):
|
160 |
+
print(f"frames len: {len(frame_archives)}")
|
161 |
+
print(f"other_data: {len(other_data)}")
|
162 |
+
|
163 |
+
for key, frames in enumerate(frame_archives):
|
164 |
+
ex = other_data[frames]
|
165 |
|
|
|
166 |
result = {
|
167 |
+
"id": ex['id'],
|
168 |
+
"transcription": ex['annotation'],
|
169 |
}
|
170 |
|
|
|
|
|
171 |
if self.config.name != 'pre-training':
|
172 |
result["frames"] = [
|
173 |
+
{"path": p, "bytes": im.read()} for p, im in frames
|
174 |
]
|
175 |
|
176 |
yield key, result
|