[Solved] When labelme edits the label, it flashes back; the error "IndexError: list index out of range" is reported

Current virtual environment:

python     3.6.13

labelme 5.0.1

pip           21.3.1

1.IndexError: list index out of range

When labelme edits the label, it crashes, as follows:

 Solution:

Modify the file D:\Anaconda3\envs\zhmpytorch\Lib\site-packages\labelme\app.py

Add code on line 1075 , as follows:

if not self.uniqLabelList.findItemsByLabel(shape.label):
    print('shape.label:', shape.label, 'group_id:', shape.group_id)
    item = self.uniqLabelList.createItemFromLabel(shape.label)
    self.uniqLabelList.addItem(item)
    rgb = self._get_rgb_by_label(shape.label)
    self.uniqLabelList.setItemLabel(item, shape.label, rgb)

Line 1085 deletes the following code:

if not self.uniqLabelList.findItemsByLabel(shape.label):
    item = QtWidgets.QListWidgetItem()
    item.setData(Qt.UserRole, shape.label)
    self.uniqLabelList.addItem(item)

Note that tabs must be used for indentation, not four spaces.

 

Other problems and solutions:

2.TabError: inconsistent use of tabs and spaces in indentation

Solution:

It is mainly the indentation of the newly added code, only tabs can be used, spaces are not available. 

 

Guess you like

Origin blog.csdn.net/shanxiderenheni/article/details/126352330