lazylabel-gui 1.0.7__tar.gz → 1.0.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. {lazylabel_gui-1.0.7 → lazylabel_gui-1.0.8}/PKG-INFO +1 -1
  2. {lazylabel_gui-1.0.7 → lazylabel_gui-1.0.8}/pyproject.toml +1 -1
  3. lazylabel_gui-1.0.8/src/lazylabel/controls.py +261 -0
  4. {lazylabel_gui-1.0.7 → lazylabel_gui-1.0.8}/src/lazylabel/custom_file_system_model.py +25 -16
  5. {lazylabel_gui-1.0.7 → lazylabel_gui-1.0.8}/src/lazylabel/main.py +288 -220
  6. {lazylabel_gui-1.0.7 → lazylabel_gui-1.0.8}/src/lazylabel/numeric_table_widget_item.py +0 -1
  7. {lazylabel_gui-1.0.7 → lazylabel_gui-1.0.8}/src/lazylabel/utils.py +1 -1
  8. {lazylabel_gui-1.0.7 → lazylabel_gui-1.0.8}/src/lazylabel_gui.egg-info/PKG-INFO +1 -1
  9. lazylabel_gui-1.0.7/src/lazylabel/controls.py +0 -163
  10. {lazylabel_gui-1.0.7 → lazylabel_gui-1.0.8}/LICENSE +0 -0
  11. {lazylabel_gui-1.0.7 → lazylabel_gui-1.0.8}/README.md +0 -0
  12. {lazylabel_gui-1.0.7 → lazylabel_gui-1.0.8}/setup.cfg +0 -0
  13. {lazylabel_gui-1.0.7 → lazylabel_gui-1.0.8}/src/lazylabel/editable_vertex.py +0 -0
  14. {lazylabel_gui-1.0.7 → lazylabel_gui-1.0.8}/src/lazylabel/hoverable_pixelmap_item.py +0 -0
  15. {lazylabel_gui-1.0.7 → lazylabel_gui-1.0.8}/src/lazylabel/hoverable_polygon_item.py +0 -0
  16. {lazylabel_gui-1.0.7 → lazylabel_gui-1.0.8}/src/lazylabel/photo_viewer.py +0 -0
  17. {lazylabel_gui-1.0.7 → lazylabel_gui-1.0.8}/src/lazylabel/reorderable_class_table.py +0 -0
  18. {lazylabel_gui-1.0.7 → lazylabel_gui-1.0.8}/src/lazylabel/sam_model.py +0 -0
  19. {lazylabel_gui-1.0.7 → lazylabel_gui-1.0.8}/src/lazylabel_gui.egg-info/SOURCES.txt +0 -0
  20. {lazylabel_gui-1.0.7 → lazylabel_gui-1.0.8}/src/lazylabel_gui.egg-info/dependency_links.txt +0 -0
  21. {lazylabel_gui-1.0.7 → lazylabel_gui-1.0.8}/src/lazylabel_gui.egg-info/entry_points.txt +0 -0
  22. {lazylabel_gui-1.0.7 → lazylabel_gui-1.0.8}/src/lazylabel_gui.egg-info/requires.txt +0 -0
  23. {lazylabel_gui-1.0.7 → lazylabel_gui-1.0.8}/src/lazylabel_gui.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lazylabel-gui
3
- Version: 1.0.7
3
+ Version: 1.0.8
4
4
  Summary: An image segmentation GUI for generating mask tensors.
5
5
  Author-email: "Deniz N. Cakan" <deniz.n.cakan@gmail.com>
6
6
  License: MIT License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "lazylabel-gui"
7
- version = "1.0.7"
7
+ version = "1.0.8"
8
8
  authors = [
9
9
  { name="Deniz N. Cakan", email="deniz.n.cakan@gmail.com" },
10
10
  ]
@@ -0,0 +1,261 @@
1
+ from PyQt6.QtWidgets import (
2
+ QWidget,
3
+ QVBoxLayout,
4
+ QPushButton,
5
+ QLabel,
6
+ QFrame,
7
+ QTableWidget,
8
+ QTreeView,
9
+ QAbstractItemView,
10
+ QHBoxLayout,
11
+ QComboBox,
12
+ QHeaderView,
13
+ QCheckBox,
14
+ QSlider,
15
+ QGroupBox,
16
+ QSplitter,
17
+ )
18
+ from PyQt6.QtCore import Qt
19
+ from .reorderable_class_table import ReorderableClassTable
20
+
21
+
22
+ class ControlPanel(QWidget):
23
+ def __init__(self, parent=None):
24
+ super().__init__(parent)
25
+ layout = QVBoxLayout(self)
26
+ layout.setAlignment(Qt.AlignmentFlag.AlignTop)
27
+
28
+ toggle_layout = QHBoxLayout()
29
+ self.btn_toggle_visibility = QPushButton("< Hide")
30
+ self.btn_toggle_visibility.setToolTip("Hide this panel")
31
+ toggle_layout.addWidget(self.btn_toggle_visibility)
32
+ toggle_layout.addStretch()
33
+ layout.addLayout(toggle_layout)
34
+
35
+ self.main_controls_widget = QWidget()
36
+ main_layout = QVBoxLayout(self.main_controls_widget)
37
+ main_layout.setContentsMargins(0, 0, 0, 0)
38
+
39
+ self.mode_label = QLabel("Mode: Points")
40
+ font = self.mode_label.font()
41
+ font.setPointSize(14)
42
+ font.setBold(True)
43
+ self.mode_label.setFont(font)
44
+ main_layout.addWidget(self.mode_label)
45
+
46
+ self.btn_sam_mode = QPushButton("Point Mode (1)")
47
+ self.btn_sam_mode.setToolTip("Switch to Point Mode for AI segmentation (1)")
48
+ self.btn_polygon_mode = QPushButton("Polygon Mode (2)")
49
+ self.btn_polygon_mode.setToolTip("Switch to Polygon Drawing Mode (2)")
50
+ self.btn_selection_mode = QPushButton("Selection Mode (E)")
51
+ self.btn_selection_mode.setToolTip("Toggle segment selection (E)")
52
+ main_layout.addWidget(self.btn_sam_mode)
53
+ main_layout.addWidget(self.btn_polygon_mode)
54
+ main_layout.addWidget(self.btn_selection_mode)
55
+
56
+ main_layout.addSpacing(20)
57
+ line1 = QFrame()
58
+ line1.setFrameShape(QFrame.Shape.HLine)
59
+ main_layout.addWidget(line1)
60
+ main_layout.addSpacing(10)
61
+
62
+ self.btn_fit_view = QPushButton("Fit View (.)")
63
+ self.btn_fit_view.setToolTip("Reset image zoom and pan to fit the view (.)")
64
+ self.btn_clear_points = QPushButton("Clear Clicks (C)")
65
+ self.btn_clear_points.setToolTip("Clear current temporary points/vertices (C)")
66
+ main_layout.addWidget(self.btn_fit_view)
67
+ main_layout.addWidget(self.btn_clear_points)
68
+
69
+ main_layout.addSpacing(10)
70
+
71
+ settings_group = QGroupBox("Settings")
72
+ settings_layout = QVBoxLayout()
73
+
74
+ self.chk_auto_save = QCheckBox("Auto-Save on Navigate")
75
+ self.chk_auto_save.setToolTip(
76
+ "Automatically save work when using arrow keys to change images."
77
+ )
78
+ self.chk_auto_save.setChecked(True)
79
+ settings_layout.addWidget(self.chk_auto_save)
80
+
81
+ self.chk_save_npz = QCheckBox("Save .npz")
82
+ self.chk_save_npz.setChecked(True)
83
+ self.chk_save_npz.setToolTip(
84
+ "Save the final mask as a compressed NumPy NPZ file."
85
+ )
86
+ settings_layout.addWidget(self.chk_save_npz)
87
+
88
+ self.chk_save_txt = QCheckBox("Save .txt")
89
+ self.chk_save_txt.setChecked(True)
90
+ self.chk_save_txt.setToolTip(
91
+ "Save bounding box annotations in YOLO TXT format."
92
+ )
93
+ settings_layout.addWidget(self.chk_save_txt)
94
+
95
+ self.chk_save_class_aliases = QCheckBox("Save Class Aliases (.json)")
96
+ self.chk_save_class_aliases.setToolTip(
97
+ "Save class aliases to a companion JSON file."
98
+ )
99
+ self.chk_save_class_aliases.setChecked(False)
100
+ settings_layout.addWidget(self.chk_save_class_aliases)
101
+
102
+ settings_group.setLayout(settings_layout)
103
+ main_layout.addWidget(settings_group)
104
+
105
+ sliders_group = QGroupBox("Adjustments")
106
+ sliders_layout = QVBoxLayout()
107
+
108
+ self.size_label = QLabel("Annotation Size: 1.0x")
109
+ self.size_slider = QSlider(Qt.Orientation.Horizontal)
110
+ self.size_slider.setRange(1, 50)
111
+ self.size_slider.setValue(10)
112
+ self.size_slider.setToolTip("Adjusts the size of points and lines (Ctrl +/-)")
113
+ sliders_layout.addWidget(self.size_label)
114
+ sliders_layout.addWidget(self.size_slider)
115
+
116
+ sliders_layout.addSpacing(10)
117
+
118
+ self.pan_label = QLabel("Pan Speed: 1.0x")
119
+ self.pan_slider = QSlider(Qt.Orientation.Horizontal)
120
+ self.pan_slider.setRange(1, 100)
121
+ self.pan_slider.setValue(10)
122
+ self.pan_slider.setToolTip(
123
+ "Adjusts the speed of WASD panning. Hold Shift for 5x boost."
124
+ )
125
+ sliders_layout.addWidget(self.pan_label)
126
+ sliders_layout.addWidget(self.pan_slider)
127
+
128
+ sliders_layout.addSpacing(10)
129
+
130
+ self.join_label = QLabel("Polygon Join Distance: 2px")
131
+ self.join_slider = QSlider(Qt.Orientation.Horizontal)
132
+ self.join_slider.setRange(1, 10)
133
+ self.join_slider.setValue(2)
134
+ self.join_slider.setToolTip("The pixel distance to 'snap' a polygon closed.")
135
+ sliders_layout.addWidget(self.join_label)
136
+ sliders_layout.addWidget(self.join_slider)
137
+
138
+ sliders_group.setLayout(sliders_layout)
139
+ main_layout.addWidget(sliders_group)
140
+
141
+ main_layout.addStretch()
142
+
143
+ self.notification_label = QLabel("")
144
+ font = self.notification_label.font()
145
+ font.setItalic(True)
146
+ self.notification_label.setFont(font)
147
+ self.notification_label.setStyleSheet("color: #ffa500;")
148
+ self.notification_label.setWordWrap(True)
149
+ main_layout.addWidget(self.notification_label)
150
+
151
+ self.device_label = QLabel("Device: Unknown")
152
+ main_layout.addWidget(self.device_label)
153
+
154
+ layout.addWidget(self.main_controls_widget)
155
+ self.setFixedWidth(250)
156
+
157
+
158
+ class RightPanel(QWidget):
159
+ def __init__(self, parent=None):
160
+ super().__init__(parent)
161
+ self.v_layout = QVBoxLayout(self)
162
+
163
+ toggle_layout = QHBoxLayout()
164
+ toggle_layout.addStretch()
165
+ self.btn_toggle_visibility = QPushButton("Hide >")
166
+ self.btn_toggle_visibility.setToolTip("Hide this panel")
167
+ toggle_layout.addWidget(self.btn_toggle_visibility)
168
+ self.v_layout.addLayout(toggle_layout)
169
+
170
+ self.main_controls_widget = QWidget()
171
+ main_layout = QVBoxLayout(self.main_controls_widget)
172
+ main_layout.setContentsMargins(0, 0, 0, 0)
173
+
174
+ v_splitter = QSplitter(Qt.Orientation.Vertical)
175
+
176
+ # --- File Explorer Widget ---
177
+ file_explorer_widget = QWidget()
178
+ file_explorer_layout = QVBoxLayout(file_explorer_widget)
179
+ file_explorer_layout.setContentsMargins(0, 0, 0, 0)
180
+ self.btn_open_folder = QPushButton("Open Image Folder")
181
+ self.btn_open_folder.setToolTip("Open a directory of images")
182
+ self.file_tree = QTreeView()
183
+ file_explorer_layout.addWidget(self.btn_open_folder)
184
+ file_explorer_layout.addWidget(self.file_tree)
185
+ v_splitter.addWidget(file_explorer_widget)
186
+
187
+ # --- Segment List Widget ---
188
+ segment_widget = QWidget()
189
+ segment_layout = QVBoxLayout(segment_widget)
190
+ segment_layout.setContentsMargins(0, 0, 0, 0)
191
+
192
+ class_filter_layout = QHBoxLayout()
193
+ class_filter_layout.addWidget(QLabel("Filter Class:"))
194
+ self.class_filter_combo = QComboBox()
195
+ self.class_filter_combo.setToolTip("Filter segments list by class")
196
+ class_filter_layout.addWidget(self.class_filter_combo)
197
+ segment_layout.addLayout(class_filter_layout)
198
+
199
+ self.segment_table = QTableWidget()
200
+ self.segment_table.setColumnCount(3)
201
+ self.segment_table.setHorizontalHeaderLabels(
202
+ ["Segment ID", "Class ID", "Alias"]
203
+ )
204
+ self.segment_table.horizontalHeader().setSectionResizeMode(
205
+ QHeaderView.ResizeMode.Stretch
206
+ )
207
+ self.segment_table.setSelectionBehavior(
208
+ QAbstractItemView.SelectionBehavior.SelectRows
209
+ )
210
+ self.segment_table.setSortingEnabled(True)
211
+ self.segment_table.setEditTriggers(QAbstractItemView.EditTrigger.NoEditTriggers)
212
+ segment_layout.addWidget(self.segment_table)
213
+
214
+ segment_action_layout = QHBoxLayout()
215
+ self.btn_merge_selection = QPushButton("Merge to Class")
216
+ self.btn_merge_selection.setToolTip(
217
+ "Merge selected segments into a single class (M)"
218
+ )
219
+ self.btn_delete_selection = QPushButton("Delete")
220
+ self.btn_delete_selection.setToolTip(
221
+ "Delete selected segments (Delete/Backspace)"
222
+ )
223
+ segment_action_layout.addWidget(self.btn_merge_selection)
224
+ segment_action_layout.addWidget(self.btn_delete_selection)
225
+ segment_layout.addLayout(segment_action_layout)
226
+ v_splitter.addWidget(segment_widget)
227
+
228
+ # --- Class Table Widget ---
229
+ class_widget = QWidget()
230
+ class_layout = QVBoxLayout(class_widget)
231
+ class_layout.setContentsMargins(0, 0, 0, 0)
232
+ class_layout.addWidget(QLabel("Class Order:"))
233
+ self.class_table = ReorderableClassTable()
234
+ self.class_table.setToolTip(
235
+ "Double-click to set class aliases and drag to reorder channels for saving."
236
+ )
237
+ self.class_table.setColumnCount(2)
238
+ self.class_table.setHorizontalHeaderLabels(["Alias", "Class ID"])
239
+ self.class_table.horizontalHeader().setSectionResizeMode(
240
+ 0, QHeaderView.ResizeMode.Stretch
241
+ )
242
+ self.class_table.horizontalHeader().setSectionResizeMode(
243
+ 1, QHeaderView.ResizeMode.ResizeToContents
244
+ )
245
+ self.class_table.setEditTriggers(QAbstractItemView.EditTrigger.DoubleClicked)
246
+ class_layout.addWidget(self.class_table)
247
+ self.btn_reassign_classes = QPushButton("Reassign Class IDs")
248
+ self.btn_reassign_classes.setToolTip(
249
+ "Re-index class channels based on the current order in this table"
250
+ )
251
+ class_layout.addWidget(self.btn_reassign_classes)
252
+ v_splitter.addWidget(class_widget)
253
+
254
+ main_layout.addWidget(v_splitter)
255
+
256
+ self.status_label = QLabel("")
257
+ self.status_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
258
+ main_layout.addWidget(self.status_label)
259
+
260
+ self.v_layout.addWidget(self.main_controls_widget)
261
+ self.setFixedWidth(350)
@@ -13,11 +13,10 @@ class CustomFileSystemModel(QFileSystemModel):
13
13
 
14
14
  def set_highlighted_path(self, path):
15
15
  self.highlighted_path = os.path.normpath(path) if path else None
16
- # Trigger repaint of the entire view
17
16
  self.layoutChanged.emit()
18
17
 
19
18
  def columnCount(self, parent: QModelIndex = QModelIndex()) -> int:
20
- return 2
19
+ return 3
21
20
 
22
21
  def headerData(
23
22
  self,
@@ -32,14 +31,15 @@ class CustomFileSystemModel(QFileSystemModel):
32
31
  if section == 0:
33
32
  return "File Name"
34
33
  if section == 1:
35
- return "Mask"
34
+ return ".npz"
35
+ if section == 2:
36
+ return ".txt"
36
37
  return super().headerData(section, orientation, role)
37
38
 
38
39
  def data(self, index: QModelIndex, role: int = Qt.ItemDataRole.DisplayRole):
39
40
  if not index.isValid():
40
41
  return None
41
42
 
42
- # Handle the temporary highlight for saving
43
43
  if role == Qt.ItemDataRole.BackgroundRole:
44
44
  filePath = os.path.normpath(self.filePath(index))
45
45
  if (
@@ -47,17 +47,26 @@ class CustomFileSystemModel(QFileSystemModel):
47
47
  and os.path.splitext(filePath)[0]
48
48
  == os.path.splitext(self.highlighted_path)[0]
49
49
  ):
50
- return QBrush(QColor(40, 80, 40)) # Dark green highlight
51
-
52
- if index.column() == 1:
53
- if role == Qt.ItemDataRole.CheckStateRole:
54
- filePath = self.filePath(index.siblingAtColumn(0))
55
- mask_path = os.path.splitext(filePath)[0] + ".npz"
56
- return (
57
- Qt.CheckState.Checked
58
- if os.path.exists(mask_path)
59
- else Qt.CheckState.Unchecked
60
- )
61
- return None
50
+ return QBrush(QColor(40, 80, 40))
51
+
52
+ if index.column() > 0 and role == Qt.ItemDataRole.CheckStateRole:
53
+ filePath = self.filePath(index.siblingAtColumn(0))
54
+ base_path = os.path.splitext(filePath)[0]
55
+
56
+ if index.column() == 1:
57
+ check_path = base_path + ".npz"
58
+ elif index.column() == 2:
59
+ check_path = base_path + ".txt"
60
+ else:
61
+ return None
62
+
63
+ return (
64
+ Qt.CheckState.Checked
65
+ if os.path.exists(check_path)
66
+ else Qt.CheckState.Unchecked
67
+ )
68
+
69
+ if index.column() > 0 and role == Qt.ItemDataRole.DisplayRole:
70
+ return ""
62
71
 
63
72
  return super().data(index, role)