Selaa lähdekoodia

Save mask as uint8 for better compatibility with other tools

Kentaro Wada 11 kuukautta sitten
vanhempi
commit
9085123e56
2 muutettua tiedostoa jossa 7 lisäystä ja 2 poistoa
  1. 4 1
      labelme/app.py
  2. 3 1
      labelme/label_file.py

+ 4 - 1
labelme/app.py

@@ -10,6 +10,7 @@ import webbrowser
 
 import imgviz
 import natsort
+import numpy as np
 from qtpy import QtCore
 from qtpy import QtGui
 from qtpy import QtWidgets
@@ -1303,7 +1304,9 @@ class MainWindow(QtWidgets.QMainWindow):
                     description=s.description,
                     shape_type=s.shape_type,
                     flags=s.flags,
-                    mask=None if s.mask is None else utils.img_arr_to_b64(s.mask),
+                    mask=None
+                    if s.mask is None
+                    else utils.img_arr_to_b64(s.mask.astype(np.uint8)),
                 )
             )
             return data

+ 3 - 1
labelme/label_file.py

@@ -111,7 +111,9 @@ class LabelFile(object):
                     flags=s.get("flags", {}),
                     description=s.get("description"),
                     group_id=s.get("group_id"),
-                    mask=utils.img_b64_to_arr(s["mask"]) if s.get("mask") else None,
+                    mask=utils.img_b64_to_arr(s["mask"]).astype(bool)
+                    if s.get("mask")
+                    else None,
                     other_data={k: v for k, v in s.items() if k not in shape_keys},
                 )
                 for s in data["shapes"]