diff --git a/labelme_toolkit/_cli/_ai_annotate_rectangles.py b/labelme_toolkit/_cli/_ai_annotate_rectangles.py index 5e8bdfc..82cbf3a 100644 --- a/labelme_toolkit/_cli/_ai_annotate_rectangles.py +++ b/labelme_toolkit/_cli/_ai_annotate_rectangles.py @@ -42,10 +42,13 @@ def _ai_annotate_rectangles( for annotation in response.annotations: shape: _labelme.Shape = _labelme.Shape( type="rectangle", - points=[ - [annotation.bounding_box.xmin, annotation.bounding_box.ymin], - [annotation.bounding_box.xmax, annotation.bounding_box.ymax], - ], + points=np.array( + [ + [annotation.bounding_box.xmin, annotation.bounding_box.ymin], + [annotation.bounding_box.xmax, annotation.bounding_box.ymax], + ], + dtype=np.float32, + ), label=annotation.text, ) shape_dict: Dict = shape.to_json() diff --git a/labelme_toolkit/_labelme.py b/labelme_toolkit/_labelme.py index 8f4c8c5..f0bb45a 100644 --- a/labelme_toolkit/_labelme.py +++ b/labelme_toolkit/_labelme.py @@ -110,6 +110,7 @@ def draw_shape_( elif shape.type == "polygon": draw.polygon(xy=points, fill=fill_color, outline=line_color, width=line_width) elif shape.type == "mask": + assert shape.mask is not None mask_height, mask_width = shape.mask.shape (xmin, ymin), (xmax, ymax) = points mask = PIL.Image.fromarray(shape.mask)