File tree Expand file tree Collapse file tree 1 file changed +2
-5
lines changed Expand file tree Collapse file tree 1 file changed +2
-5
lines changed Original file line number Diff line number Diff line change @@ -357,9 +357,8 @@ def read_annot(filepath, orig_ids=False):
357357 to any label and orig_ids=False, its id will be set to -1.
358358 ctab : ndarray, shape (n_labels, 5)
359359 RGBA + label id colortable array.
360- names : list of str
360+ names : list of str (python 2), list of bytes (python 3)
361361 The names of the labels. The length of the list is n_labels.
362-
363362 """
364363 with open (filepath , "rb" ) as fobj :
365364 dt = _ANNOT_DT
@@ -391,9 +390,6 @@ def read_annot(filepath, orig_ids=False):
391390 # generate annotation values for each LUT entry
392391 ctab [:, [4 ]] = _pack_rgba (ctab [:, :4 ])
393392
394- # make sure names are strings, not bytes
395- names = [n .decode ('ascii' ) for n in names ]
396-
397393 if not orig_ids :
398394 ord = np .argsort (ctab [:, - 1 ])
399395 mask = labels != 0
@@ -522,6 +518,7 @@ def write(num, dtype=dt):
522518 np .array ([num ]).astype (dtype ).tofile (fobj )
523519
524520 def write_string (s ):
521+ s = s .encode () + b'\00 '
525522 write (len (s ))
526523 write (s , dtype = '|S%d' % len (s ))
527524
You can’t perform that action at this time.
0 commit comments