From 8bc2dfe3f669da165298ac902b2180ad3756753a Mon Sep 17 00:00:00 2001 From: healthonrails Date: Thu, 13 Jun 2024 14:35:48 -0400 Subject: [PATCH] Save mask as uint8 for better compatibility with other tools https://github.com/labelmeai/labelme/commit/9085123e560fc829bdda37313f75be41bdb5bec6 --- annolid/gui/app.py | 5 +++-- annolid/gui/label_file.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/annolid/gui/app.py b/annolid/gui/app.py index ce58a32..5f51835 100644 --- a/annolid/gui/app.py +++ b/annolid/gui/app.py @@ -7,6 +7,7 @@ import html import shutil import pandas as pd +import numpy as np from collections import deque import torch import codecs @@ -1218,7 +1219,7 @@ def saveLabels(self, filename): def format_shape(s): data = s.other_data.copy() - if 'zone' in s.description.lower(): + if s.description and 'zone' in s.description.lower(): has_zone_shapes = True if len(s.points) <= 1: s.shape_type = 'point' @@ -1231,7 +1232,7 @@ def format_shape(s): flags=s.flags, mask=None if s.mask is None - else utils.img_arr_to_b64(s.mask), + else utils.img_arr_to_b64(s.mask.astype(np.uint8)), visible=s.visible, description=s.description ) diff --git a/annolid/gui/label_file.py b/annolid/gui/label_file.py index 6e45e4f..0f75494 100644 --- a/annolid/gui/label_file.py +++ b/annolid/gui/label_file.py @@ -120,7 +120,7 @@ def load(self, filename): description=s.get("description"), group_id=s.get("group_id"), mask=utils.img_b64_to_arr( - s["mask"]) if s.get("mask") else None, + s["mask"]).astype(bool) if s.get("mask") else None, visible=s.get("visible"), other_data={k: v for k, v in s.items() if k not in shape_keys},