nastyboget
commited on
Commit
•
ad86a9a
1
Parent(s):
086a577
Update stackmix_cyrillic.py
Browse files- stackmix_cyrillic.py +3 -11
stackmix_cyrillic.py
CHANGED
@@ -24,21 +24,13 @@ class StackmixCyrillic(datasets.GeneratorBasedBuilder):
|
|
24 |
_URLS = {f"img{i:02d}": f"img/img-{i:02d}.zip" for i in range(15)}
|
25 |
_URLS["labels"] = "gt.txt"
|
26 |
|
27 |
-
data_paths = dl_manager.
|
28 |
-
|
29 |
-
img_path = os.path.join(os.path.split(data_paths["labels"])[0], "img")
|
30 |
-
os.makedirs(img_path, exist_ok=True)
|
31 |
|
32 |
-
for archive_path in archive_paths:
|
33 |
-
with zipfile.ZipFile(archive_path) as archive:
|
34 |
-
archive.extractall(img_path)
|
35 |
-
os.remove(archive_path)
|
36 |
-
|
37 |
-
image_paths = [os.path.join(img_path, img_name) for img_name in os.listdir(img_path)]
|
38 |
return [datasets.SplitGenerator(
|
39 |
name=datasets.Split.TRAIN,
|
40 |
gen_kwargs={
|
41 |
-
"image_paths": image_paths,
|
42 |
"labels_path": data_paths["labels"]
|
43 |
})]
|
44 |
|
|
|
24 |
_URLS = {f"img{i:02d}": f"img/img-{i:02d}.zip" for i in range(15)}
|
25 |
_URLS["labels"] = "gt.txt"
|
26 |
|
27 |
+
data_paths = dl_manager.download_and_extract(_URLS)
|
28 |
+
image_paths = [data_paths[key] for key in data_paths if key.startswith("img")]
|
|
|
|
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
return [datasets.SplitGenerator(
|
31 |
name=datasets.Split.TRAIN,
|
32 |
gen_kwargs={
|
33 |
+
"image_paths": dl_manager.iter_files(image_paths),
|
34 |
"labels_path": data_paths["labels"]
|
35 |
})]
|
36 |
|