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):
357
357
to any label and orig_ids=False, its id will be set to -1.
358
358
ctab : ndarray, shape (n_labels, 5)
359
359
RGBA + label id colortable array.
360
- names : list of str
360
+ names : list of str (python 2), list of bytes (python 3)
361
361
The names of the labels. The length of the list is n_labels.
362
-
363
362
"""
364
363
with open (filepath , "rb" ) as fobj :
365
364
dt = _ANNOT_DT
@@ -391,9 +390,6 @@ def read_annot(filepath, orig_ids=False):
391
390
# generate annotation values for each LUT entry
392
391
ctab [:, [4 ]] = _pack_rgba (ctab [:, :4 ])
393
392
394
- # make sure names are strings, not bytes
395
- names = [n .decode ('ascii' ) for n in names ]
396
-
397
393
if not orig_ids :
398
394
ord = np .argsort (ctab [:, - 1 ])
399
395
mask = labels != 0
@@ -522,6 +518,7 @@ def write(num, dtype=dt):
522
518
np .array ([num ]).astype (dtype ).tofile (fobj )
523
519
524
520
def write_string (s ):
521
+ s = s .encode () + b'\00 '
525
522
write (len (s ))
526
523
write (s , dtype = '|S%d' % len (s ))
527
524
You can’t perform that action at this time.
0 commit comments