diff --git a/labelme/app.py b/labelme/app.py index 9a83a3711..2f277307e 100644 --- a/labelme/app.py +++ b/labelme/app.py @@ -10,6 +10,7 @@ import imgviz import natsort +import numpy as np from qtpy import QtCore from qtpy import QtGui from qtpy import QtWidgets @@ -1303,7 +1304,9 @@ def format_shape(s): 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 diff --git a/labelme/label_file.py b/labelme/label_file.py index bffee8af3..3c1f31530 100644 --- a/labelme/label_file.py +++ b/labelme/label_file.py @@ -111,7 +111,9 @@ def load(self, filename): 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"]