feat: add bbox_id
Browse files- license_plates.py +19 -15
license_plates.py
CHANGED
@@ -44,9 +44,10 @@ class LicensePlates(datasets.GeneratorBasedBuilder):
|
|
44 |
def _info(self):
|
45 |
|
46 |
features = datasets.Features({
|
|
|
|
|
47 |
'image': datasets.Image(),
|
48 |
'labeled_image': datasets.Image(),
|
49 |
-
'bbox': datasets.Value('string'),
|
50 |
'license_plate.id': datasets.Value('string'),
|
51 |
'license_plate.visibility': datasets.Value('string'),
|
52 |
'license_plate.rows_count': datasets.Value('uint8'),
|
@@ -85,18 +86,22 @@ class LicensePlates(datasets.GeneratorBasedBuilder):
|
|
85 |
file_name = file_path.split('/')[-1]
|
86 |
images[file_name] = (file_path, file.read())
|
87 |
|
88 |
-
annotations_df.drop(
|
89 |
-
|
90 |
-
|
|
|
91 |
|
92 |
annotations_df.fillna(0, inplace=True)
|
|
|
93 |
|
94 |
-
for row in annotations_df.itertuples(index=
|
95 |
-
image = images[row[
|
96 |
-
name, ext = row[
|
97 |
labeled_image = images[f'{name}_labeled.{ext}']
|
98 |
|
99 |
yield idx, {
|
|
|
|
|
100 |
"image": {
|
101 |
"path": image[0],
|
102 |
"bytes": image[1]
|
@@ -105,12 +110,11 @@ class LicensePlates(datasets.GeneratorBasedBuilder):
|
|
105 |
"path": labeled_image[0],
|
106 |
"bytes": labeled_image[1]
|
107 |
},
|
108 |
-
'
|
109 |
-
'license_plate.
|
110 |
-
'license_plate.
|
111 |
-
'license_plate.
|
112 |
-
'license_plate.
|
113 |
-
'license_plate.
|
114 |
-
'license_plate.
|
115 |
-
'license_plate.mask': row[8]
|
116 |
}
|
|
|
44 |
def _info(self):
|
45 |
|
46 |
features = datasets.Features({
|
47 |
+
'bbox_id': datasets.Value('uint32'),
|
48 |
+
'bbox': datasets.Value('string'),
|
49 |
'image': datasets.Image(),
|
50 |
'labeled_image': datasets.Image(),
|
|
|
51 |
'license_plate.id': datasets.Value('string'),
|
52 |
'license_plate.visibility': datasets.Value('string'),
|
53 |
'license_plate.rows_count': datasets.Value('uint8'),
|
|
|
86 |
file_name = file_path.split('/')[-1]
|
87 |
images[file_name] = (file_path, file.read())
|
88 |
|
89 |
+
annotations_df.drop(
|
90 |
+
columns=['license_plate.region', 'license_plate.color'],
|
91 |
+
inplace=True,
|
92 |
+
errors='ignore')
|
93 |
|
94 |
annotations_df.fillna(0, inplace=True)
|
95 |
+
annotations_df.sort_values(by='file_name', inplace=True)
|
96 |
|
97 |
+
for row in annotations_df.itertuples(index=True):
|
98 |
+
image = images[row[1]]
|
99 |
+
name, ext = row[1].split('.')
|
100 |
labeled_image = images[f'{name}_labeled.{ext}']
|
101 |
|
102 |
yield idx, {
|
103 |
+
'bbox_id': row[0],
|
104 |
+
'bbox': row[2],
|
105 |
"image": {
|
106 |
"path": image[0],
|
107 |
"bytes": image[1]
|
|
|
110 |
"path": labeled_image[0],
|
111 |
"bytes": labeled_image[1]
|
112 |
},
|
113 |
+
'license_plate.id': row[3],
|
114 |
+
'license_plate.visibility': row[4],
|
115 |
+
'license_plate.rows_count': row[5],
|
116 |
+
'license_plate.number': row[6],
|
117 |
+
'license_plate.serial': row[7],
|
118 |
+
'license_plate.country': row[8],
|
119 |
+
'license_plate.mask': row[9]
|
|
|
120 |
}
|