Skip to content

Commit 150e8c3

Browse files
committed
fix yolo exporter
1 parent 5c3158d commit 150e8c3

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

source/Label.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def getColorAsKey(self):
2929
return "{:03d}-{:03d}-{:03d}".format(r,g,b)
3030

3131
@staticmethod
32-
def convertColorToKey(self, r, g, b):
32+
def convertColorToKey(r, g, b):
3333

3434
return "{:03d}-{:03d}-{:03d}".format(r,g,b)
3535

source/NewDataset.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,8 +1238,16 @@ def export_tiles(self, basename, tilename):
12381238
yolo_class_mapper_inv[i] = key
12391239

12401240
for i in range(self.yolo_class_counter):
1241-
label_name = genutils.getLabelNamesByColor(yolo_class_mapper_inv[i])
1242-
txt = (" {:d}: {:s}\n").format(i, label_name)
1241+
color_key = yolo_class_mapper_inv[i]
1242+
r = int(color_key.split("-")[0])
1243+
g = int(color_key.split("-")[1])
1244+
b = int(color_key.split("-")[2])
1245+
color = [r, g, b]
1246+
label_name = genutils.getLabelNamesByColor(self.labels_dict, color)
1247+
if len(label_name) > 0:
1248+
txt = (" {:d}: {:s}\n").format(i, label_name[0])
1249+
else:
1250+
txt = (" {:d}: class{:d}\n").format(i, i+1)
12431251
fy.write(txt)
12441252
txt = "path: " + basename + "\n"
12451253
fy.write(txt)

0 commit comments

Comments
 (0)