Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make group_id clearable by removing the already set value #1498

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 27 additions & 36 deletions labelme/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1221,17 +1221,6 @@ def _edit_label(self, value=None):
assert description is None
return

self.canvas.storeShapes()
for item in items:
self._update_item(
item=item,
text=text if edit_text else None,
flags=flags if edit_flags else None,
group_id=group_id if edit_group_id else None,
description=description if edit_description else None,
)

def _update_item(self, item, text, flags, group_id, description):
if not self.validateLabel(text):
self.errorMessage(
self.tr("Invalid label"),
Expand All @@ -1241,32 +1230,34 @@ def _update_item(self, item, text, flags, group_id, description):
)
return

shape = item.shape()

if text is not None:
shape.label = text
if flags is not None:
shape.flags = flags
if group_id is not None:
shape.group_id = group_id
if description is not None:
shape.description = description

self._update_shape_color(shape)
if shape.group_id is None:
item.setText(
'{} <font color="#{:02x}{:02x}{:02x}">●</font>'.format(
html.escape(shape.label), *shape.fill_color.getRgb()[:3]
self.canvas.storeShapes()
for item in items:
shape: Shape = item.shape()

if edit_text:
shape.label = text
if edit_flags:
shape.flags = flags
if edit_group_id:
shape.group_id = group_id
if edit_description:
shape.description = description

self._update_shape_color(shape)
if shape.group_id is None:
item.setText(
'{} <font color="#{:02x}{:02x}{:02x}">●</font>'.format(
html.escape(shape.label), *shape.fill_color.getRgb()[:3]
)
)
)
else:
item.setText("{} ({})".format(shape.label, shape.group_id))
self.setDirty()
if self.uniqLabelList.findItemByLabel(shape.label) is None:
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)
else:
item.setText("{} ({})".format(shape.label, shape.group_id))
self.setDirty()
if self.uniqLabelList.findItemByLabel(shape.label) is None:
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)

def fileSearchChanged(self):
self.importDirImages(
Expand Down
Loading