Update AASL.py
Browse files
AASL.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import datasets
|
2 |
from datasets.tasks import ImageClassification
|
3 |
import os
|
4 |
-
|
5 |
_CITATION = """\
|
6 |
@misc{https://doi.org/10.48550/arxiv.2301.11932,
|
7 |
doi = {10.48550/ARXIV.2301.11932},
|
@@ -62,12 +62,16 @@ class AASL(datasets.GeneratorBasedBuilder):
|
|
62 |
|
63 |
def _generate_examples(self, images):
|
64 |
|
|
|
65 |
for i, file in enumerate(images):
|
66 |
-
|
|
|
|
|
|
|
|
|
67 |
if os.path.basename(file).endswith(".jpg"):
|
68 |
-
with open(file, "rb")
|
69 |
yield str(i), {
|
70 |
"image": file,
|
71 |
-
"label":
|
72 |
-
}
|
73 |
-
idx += 1
|
|
|
1 |
import datasets
|
2 |
from datasets.tasks import ImageClassification
|
3 |
import os
|
4 |
+
from collections import defaultdict
|
5 |
_CITATION = """\
|
6 |
@misc{https://doi.org/10.48550/arxiv.2301.11932,
|
7 |
doi = {10.48550/ARXIV.2301.11932},
|
|
|
62 |
|
63 |
def _generate_examples(self, images):
|
64 |
|
65 |
+
two_exp = defaultdict(int)
|
66 |
for i, file in enumerate(images):
|
67 |
+
class_name = os.path.basename(file).split('.')[0].split('_')[0]
|
68 |
+
two_exp[class_name] += 1
|
69 |
+
if two_exp[class_name]>2:
|
70 |
+
continue
|
71 |
+
else:
|
72 |
if os.path.basename(file).endswith(".jpg"):
|
73 |
+
with open(file, "rb"):
|
74 |
yield str(i), {
|
75 |
"image": file,
|
76 |
+
"label": class_name,
|
77 |
+
}
|
|