Update Stomatal_Images_Datasets.py
Browse files- Stomatal_Images_Datasets.py +14 -14
Stomatal_Images_Datasets.py
CHANGED
@@ -114,20 +114,20 @@ class NewDataset(datasets.GeneratorBasedBuilder):
|
|
114 |
# return annotations
|
115 |
|
116 |
def _parse_yolo_labels(self, label_path, width, height):
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
|
132 |
|
133 |
|
|
|
114 |
# return annotations
|
115 |
|
116 |
def _parse_yolo_labels(self, label_path, width, height):
|
117 |
+
annotations = []
|
118 |
+
with open(label_path, 'r') as file:
|
119 |
+
yolo_data = file.readlines()
|
120 |
+
|
121 |
+
for line in yolo_data:
|
122 |
+
class_id, x_center_rel, y_center_rel, width_rel, height_rel = map(float, line.split())
|
123 |
+
annotations.append({
|
124 |
+
"category_id": int(class_id),
|
125 |
+
"x_center_rel": x_center_rel,
|
126 |
+
"y_center_rel": y_center_rel,
|
127 |
+
"width_rel": width_rel,
|
128 |
+
"height_rel": height_rel,
|
129 |
+
})
|
130 |
+
return annotations
|
131 |
|
132 |
|
133 |
|