Update mini_car_bikes_detection.py
Browse files- mini_car_bikes_detection.py +11 -1
mini_car_bikes_detection.py
CHANGED
@@ -21,6 +21,11 @@ _URLS = {
|
|
21 |
"test_images": f"{_URL}/data/test.zip",
|
22 |
}
|
23 |
|
|
|
|
|
|
|
|
|
|
|
24 |
_CATEGORIES = ['Car', 'bike']
|
25 |
|
26 |
|
@@ -46,22 +51,27 @@ class MiniCarBikesDetection(datasets.GeneratorBasedBuilder):
|
|
46 |
|
47 |
def _split_generators(self, dl_manager):
|
48 |
data_files = dl_manager.download(_URLS)
|
|
|
49 |
return [
|
50 |
datasets.SplitGenerator(
|
51 |
name=datasets.Split.TRAIN,
|
52 |
gen_kwargs={
|
53 |
"image_files": dl_manager.iter_archive(data_files["train_images"]),
|
|
|
54 |
},
|
55 |
),
|
56 |
datasets.SplitGenerator(
|
57 |
name=datasets.Split.TEST,
|
58 |
gen_kwargs={
|
59 |
"image_files": dl_manager.iter_archive(data_files["test_images"]),
|
|
|
60 |
},
|
61 |
),
|
62 |
]
|
63 |
|
64 |
-
def _generate_examples(self, image_files):
|
|
|
|
|
65 |
for image_file in image_files:
|
66 |
image_name = image_file[0].split("/")[1]
|
67 |
yield image_file, {
|
|
|
21 |
"test_images": f"{_URL}/data/test.zip",
|
22 |
}
|
23 |
|
24 |
+
_ANNOTATIONS = {
|
25 |
+
"train_annotations": f"{_URL}/annotations/train_annotations.json"
|
26 |
+
"test_annotations": f"{_URL}/annotations/test_annotations.json"
|
27 |
+
}
|
28 |
+
|
29 |
_CATEGORIES = ['Car', 'bike']
|
30 |
|
31 |
|
|
|
51 |
|
52 |
def _split_generators(self, dl_manager):
|
53 |
data_files = dl_manager.download(_URLS)
|
54 |
+
annotations_files = _ANNOTATIONS
|
55 |
return [
|
56 |
datasets.SplitGenerator(
|
57 |
name=datasets.Split.TRAIN,
|
58 |
gen_kwargs={
|
59 |
"image_files": dl_manager.iter_archive(data_files["train_images"]),
|
60 |
+
"annotations_file": annotations_files["train_annotations"]
|
61 |
},
|
62 |
),
|
63 |
datasets.SplitGenerator(
|
64 |
name=datasets.Split.TEST,
|
65 |
gen_kwargs={
|
66 |
"image_files": dl_manager.iter_archive(data_files["test_images"]),
|
67 |
+
"annotations_file": annotations_files["test_annotations"]
|
68 |
},
|
69 |
),
|
70 |
]
|
71 |
|
72 |
+
def _generate_examples(self, image_files, annotations_file):
|
73 |
+
with open(annotations_file) as jf:
|
74 |
+
annotations = json.load(jf)
|
75 |
for image_file in image_files:
|
76 |
image_name = image_file[0].split("/")[1]
|
77 |
yield image_file, {
|