Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save mask as uint8 for better compatibility with other tools #1452

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion labelme/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import imgviz
import natsort
import numpy as np
from qtpy import QtCore
from qtpy import QtGui
from qtpy import QtWidgets
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion labelme/label_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
Loading