wkentaro / labelme

Image Polygonal Annotation with Python (polygon, rectangle, circle, line, point and image-level flag annotation).
https://labelme.io
Other
13.62k stars 3.42k forks source link

ValueError: <labelme.shape.Shape object at 0x000001BFA54D6310> is not in list #1396

Open monkeycc opened 10 months ago

monkeycc commented 10 months ago

win11 python 3.11 labelme 5.4.1


Traceback (most recent call last):
  File "E:\anaconda3\envs\PY311\Lib\site-packages\labelme\widgets\canvas.py", line 973, in keyReleaseEvent
    index = self.shapes.index(self.selectedShapes[0])
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: <labelme.shape.Shape object at 0x000001BFA54D6310> is not in list
wkentaro commented 10 months ago

@monkeycc Thanks for the report. Do you know how to reproduce this?

starn1 commented 7 months ago

win11 python 3.11 labelme 5.4.1


Traceback (most recent call last):
  File "E:\anaconda3\envs\PY311\Lib\site-packages\labelme\widgets\canvas.py", line 973, in keyReleaseEvent
    index = self.shapes.index(self.selectedShapes[0])
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: <labelme.shape.Shape object at 0x000001BFA54D6310> is not in list

解决了吗 我也有一样的问题

mafeng199325 commented 5 months ago

(base) D:\软件安装\labelme\cvat-2.14.4>labelme 2024-06-28 11:58:14,133 [INFO ] init:get_config:67- Loading config file from: C:\Users\Administrator.labelmerc Traceback (most recent call last): File "D:\Anaconda3\lib\site-packages\labelme\widgets\canvas.py", line 973, in keyReleaseEvent index = self.shapes.index(self.selectedShapes[0]) ValueError: <labelme.shape.Shape object at 0x000001B1803AFD00> is not in list

papertiger0016 commented 4 months ago

Hi, I'm having the same issue as well. Below are what information I could provide:

Provide environment information python=3.9.7 labelme = v5.0.5 (I heard the same thing happening in recent versions such as v5.4.1 as well.

What OS are you using? win11

Describe the Bug The program crashes in every 10~15 instances, when I'm editing a label or after I finish and move to the next file. This seems to happen more often when the editing involves a polygon label(compared to a rectangle or a line), And it also seems to happen more often when moving to the next file than it does while editing.

The error message displayed is as below.

Traceback (most recent call last): File "C:\Users\selectstar\anaconda3\lib\site-packages\labelme\widgets\canvas.py", line 812, in keyReleaseEvent index = self.shapes.index(self.selectedShapes[0]) ValueError: <labelme.shape.Shape object at 0x0000026EDB226580> is not in list

Expected Behavior The program continues to run without crashing

To Reproduce After loading a list of files using "Open Dir", edit a polygon label and move to the next file.

yixing98 commented 3 months ago

An easy way around it:

    def keyReleaseEvent(self, ev):
        modifiers = ev.modifiers()
        if self.drawing():
            if int(modifiers) == 0:
                self.snapping = True
        elif self.editing():
            if self.movingShape and self.selectedShapes:
                # index = self.shapes.index(self.selectedShapes[0])
                # if self.shapesBackups[-1][index].points != self.shapes[index].points:
                try:
                    index = self.shapes.index(self.selectedShapes[0])
                except ValueError:
                    index = None
                    print('self.selectedShapes[0] is not in self.shapes')

                if index and self.shapesBackups[-1][index].points != self.shapes[index].points:
                    self.storeShapes()
                    self.shapeMoved.emit()

                self.movingShape = False