Skip to content

Annotator2d object has no attribute 'layers' #1141

@Sagnik700

Description

@Sagnik700

I am using micro-sam 1.7.0 from the source. This issue occurred while trying to annotate using Annotator 2D in napari.

After completing annotating one image and saving the committed objects layer, I deleted the raw image and committed objects layers from the layer list and imported the next raw image. After clicking on Compute Embeddings, the error prompt

'Annotator2d' object has no attribute 'layers'

came, and behind it the prompt saying 'Computer Embeddings for ....' came up as well, which signified that the embeddings were computed successfully. No other issues were faced during the annotation phase, and the committed objects layer got regenerated as well.

The error trace:

AttributeError Traceback (most recent call last)
File E:\source\micro-sam\micro_sam\sam_annotator_[annotator.py:204](http://annotator.py:204/), in _AnnotatorBase._update_image(self=<micro_sam.sam_annotator.annotator_2d.Annotator2d object>, segmentation_result=False)
201 self._shape = state.image_shape
203 # Before we reset the layers, we ensure all expected layers exist.
--> 204 self._require_layers()
self = <micro_sam.sam_annotator.annotator_2d.Annotator2d object at 0x000002060A958200> 206 # Update the image scale.
207 scale = state.image_scale

File E:\source\micro-sam\micro_sam\sam_annotator_[annotator.py:53](http://annotator.py:53/), in _AnnotatorBase._require_layers(self=<micro_sam.sam_annotator.annotator_2d.Annotator2d object>, layer_choices=None)
51 self._viewer.layers["committed_objects"].new_colormap()
52 if image_scale is not None:
---> 53 self.layers["committed_objects"].scale = image_scale
image_scale = (np.float64(1.0), np.float64(1.0))
self = <micro_sam.sam_annotator.annotator_2d.Annotator2d object at 0x000002060A958200> 55 # Add the point layer for point prompts.
56 self._point_labels = ["positive", "negative"]

AttributeError: 'Annotator2d' object has no attribute 'layers'

Image showing the issue:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidThis doesn't seem right

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions