Delete mini_car_bikes_detection.py
Browse files- mini_car_bikes_detection.py +0 -149
mini_car_bikes_detection.py
DELETED
@@ -1,149 +0,0 @@
|
|
1 |
-
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
2 |
-
#
|
3 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
-
# you may not use this file except in compliance with the License.
|
5 |
-
# You may obtain a copy of the License at
|
6 |
-
#
|
7 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
-
#
|
9 |
-
# Unless required by applicable law or agreed to in writing, software
|
10 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
-
# See the License for the specific language governing permissions and
|
13 |
-
# limitations under the License.
|
14 |
-
# TODO: Address all TODOs and remove all explanatory comments
|
15 |
-
"""Cars and bikes detection small dataset."""
|
16 |
-
|
17 |
-
import collections
|
18 |
-
import numpy as np
|
19 |
-
from PIL import Image
|
20 |
-
|
21 |
-
import json
|
22 |
-
import os
|
23 |
-
|
24 |
-
import datasets
|
25 |
-
|
26 |
-
|
27 |
-
_DESCRIPTION = """
|
28 |
-
|
29 |
-
"""
|
30 |
-
|
31 |
-
_HOMEPAGE = ""
|
32 |
-
|
33 |
-
_LICENSE = ""
|
34 |
-
|
35 |
-
_URL = "https://huggingface.co/datasets/alexrods/mini_car_bikes_detection/resolve/main"
|
36 |
-
|
37 |
-
_URLS = {
|
38 |
-
"train_images": f"{_URL}/data/train.zip",
|
39 |
-
"test_images": f"{_URL}/data/test.zip",
|
40 |
-
}
|
41 |
-
|
42 |
-
_CATEGORIES = ['Car', 'bike']
|
43 |
-
|
44 |
-
|
45 |
-
class MiniCarBikesDetection(datasets.GeneratorBasedBuilder):
|
46 |
-
|
47 |
-
VERSION = datasets.Version("1.0.0")
|
48 |
-
|
49 |
-
def _info(self):
|
50 |
-
features = datasets.Features(
|
51 |
-
{
|
52 |
-
# "image": datasets.Image(),
|
53 |
-
# "image_name": datasets.Value("string"),
|
54 |
-
"width": datasets.Value("int32"),
|
55 |
-
"height": datasets.Value("int32"),
|
56 |
-
# "objects": datasets.Sequence(
|
57 |
-
# {
|
58 |
-
# "name": datasets.ClassLabel(names=_CATEGORIES),
|
59 |
-
# "bbox": datasets.Sequence(datasets.Value("float32"), length=4)
|
60 |
-
# }
|
61 |
-
# ),
|
62 |
-
}
|
63 |
-
)
|
64 |
-
return datasets.DatasetInfo(
|
65 |
-
description=_DESCRIPTION,
|
66 |
-
features=features,
|
67 |
-
homepage=_HOMEPAGE,
|
68 |
-
license=_LICENSE,
|
69 |
-
)
|
70 |
-
|
71 |
-
def _split_generators(self, dl_manager):
|
72 |
-
data_files = dl_manager.download(_URLS)
|
73 |
-
return [
|
74 |
-
datasets.SplitGenerator(
|
75 |
-
name=datasets.Split.TRAIN,
|
76 |
-
gen_kwargs={
|
77 |
-
# "image_files": dl_manager.iter_archive(data_files["train_images"]),
|
78 |
-
"annotation_files": f"{_URL}/annotations/train_annotations.json",
|
79 |
-
"split": "train"
|
80 |
-
},
|
81 |
-
),
|
82 |
-
datasets.SplitGenerator(
|
83 |
-
name=datasets.Split.TEST,
|
84 |
-
gen_kwargs={
|
85 |
-
# "image_files": dl_manager.iter_archive(data_files["test_images"]),
|
86 |
-
"annotation_files": f"{_URL}/annotations/test_annotations.json",
|
87 |
-
"split": "test"
|
88 |
-
},
|
89 |
-
),
|
90 |
-
]
|
91 |
-
|
92 |
-
def _generate_examples(self, annotation_files, split):
|
93 |
-
with open(annotation_files, "r") as jf:
|
94 |
-
annotations = json.load(jf)
|
95 |
-
|
96 |
-
|
97 |
-
for annotation in annotations:
|
98 |
-
yield {
|
99 |
-
"width": annotation["width"],
|
100 |
-
"height": annotation["height"],
|
101 |
-
# "objects": [
|
102 |
-
# {
|
103 |
-
# "name": annotation["name"],
|
104 |
-
# "bbox": annotation["bbox"]
|
105 |
-
# }
|
106 |
-
# ]
|
107 |
-
}
|
108 |
-
|
109 |
-
# def _generate_examples(self, image_files, annotation_files, split):
|
110 |
-
# # for image_file in image_files:
|
111 |
-
# # return np.array(Image.open(image_file[1]))
|
112 |
-
# with open(annotation_files, "r") as jf:
|
113 |
-
# annotations = json.load(jf)
|
114 |
-
# for image_file in image_files:
|
115 |
-
# image_name = image_file[0].split("/")[1]
|
116 |
-
# image_array = np.array(Image.open(image_file[1]))
|
117 |
-
|
118 |
-
# for annotation in annotations:
|
119 |
-
# if annotation['image'] == image_name[0]:
|
120 |
-
# data = {
|
121 |
-
# "image": image_array,
|
122 |
-
# "width": annotation["width"],
|
123 |
-
# "height": annotation["height"],
|
124 |
-
# "objects": []
|
125 |
-
# }
|
126 |
-
# data["objects"].append(
|
127 |
-
# {
|
128 |
-
# "name": annotation["name"],
|
129 |
-
# "bbox": annotation["bbox"]
|
130 |
-
# }
|
131 |
-
# )
|
132 |
-
|
133 |
-
# yield data
|
134 |
-
|
135 |
-
# yield {
|
136 |
-
# "image": image_array,
|
137 |
-
# "width": annotation["width"],
|
138 |
-
# "height": annotation["height"],
|
139 |
-
# "objects": [
|
140 |
-
# {
|
141 |
-
# "name": [name for name in annotation["name"]],
|
142 |
-
# "bbox": [bbox for bbox in annotation["bbox"]]
|
143 |
-
# }
|
144 |
-
# ]
|
145 |
-
# }
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|