Skip to content

Commit

Permalink
Save mask as uint8 for better compatibility with other tools wkentaro…
Browse files Browse the repository at this point in the history
  • Loading branch information
healthonrails committed Jun 13, 2024
1 parent 3611529 commit 8bc2dfe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions annolid/gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import html
import shutil
import pandas as pd
import numpy as np
from collections import deque
import torch
import codecs
Expand Down Expand Up @@ -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'
Expand All @@ -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
)
Expand Down
2 changes: 1 addition & 1 deletion annolid/gui/label_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down

0 comments on commit 8bc2dfe

Please sign in to comment.