lazylabel-gui 1.3.1__tar.gz → 1.3.2__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.
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/PKG-INFO +1 -1
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/pyproject.toml +1 -1
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/core/file_manager.py +33 -1
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/ui/main_window.py +213 -65
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/ui/right_panel.py +29 -2
- lazylabel_gui-1.3.2/src/lazylabel/utils/fast_file_manager.py +676 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel_gui.egg-info/PKG-INFO +1 -1
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel_gui.egg-info/SOURCES.txt +1 -1
- lazylabel_gui-1.3.1/src/lazylabel/ui/test_hover.py +0 -48
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/LICENSE +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/README.md +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/setup.cfg +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/__init__.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/__main__.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/config/__init__.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/config/hotkeys.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/config/paths.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/config/settings.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/core/__init__.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/core/model_manager.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/core/segment_manager.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/main.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/models/__init__.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/models/sam2_model.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/models/sam_model.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/ui/__init__.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/ui/control_panel.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/ui/editable_vertex.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/ui/hotkey_dialog.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/ui/hoverable_pixelmap_item.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/ui/hoverable_polygon_item.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/ui/modes/__init__.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/ui/modes/base_mode.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/ui/modes/multi_view_mode.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/ui/modes/single_view_mode.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/ui/numeric_table_widget_item.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/ui/photo_viewer.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/ui/reorderable_class_table.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/ui/widgets/__init__.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/ui/widgets/adjustments_widget.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/ui/widgets/border_crop_widget.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/ui/widgets/channel_threshold_widget.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/ui/widgets/fft_threshold_widget.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/ui/widgets/fragment_threshold_widget.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/ui/widgets/model_selection_widget.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/ui/widgets/settings_widget.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/ui/widgets/status_bar.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/utils/__init__.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/utils/custom_file_system_model.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/utils/logger.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel/utils/utils.py +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel_gui.egg-info/dependency_links.txt +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel_gui.egg-info/entry_points.txt +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel_gui.egg-info/requires.txt +0 -0
- {lazylabel_gui-1.3.1 → lazylabel_gui-1.3.2}/src/lazylabel_gui.egg-info/top_level.txt +0 -0
@@ -24,16 +24,48 @@ class FileManager:
|
|
24
24
|
crop_coords: tuple[int, int, int, int] | None = None,
|
25
25
|
) -> str:
|
26
26
|
"""Save segments as NPZ file."""
|
27
|
+
logger.debug(f"Saving NPZ for image: {image_path}")
|
28
|
+
logger.debug(f"Image size: {image_size}, Class order: {class_order}")
|
29
|
+
|
30
|
+
# Validate inputs
|
31
|
+
if not class_order:
|
32
|
+
raise ValueError("No classes defined for saving")
|
33
|
+
|
27
34
|
final_mask_tensor = self.segment_manager.create_final_mask_tensor(
|
28
35
|
image_size, class_order
|
29
36
|
)
|
30
37
|
|
38
|
+
# Validate mask tensor
|
39
|
+
if final_mask_tensor.size == 0:
|
40
|
+
raise ValueError("Empty mask tensor generated")
|
41
|
+
|
42
|
+
logger.debug(f"Final mask tensor shape: {final_mask_tensor.shape}")
|
43
|
+
|
31
44
|
# Apply crop if coordinates are provided
|
32
45
|
if crop_coords:
|
33
46
|
final_mask_tensor = self._apply_crop_to_mask(final_mask_tensor, crop_coords)
|
47
|
+
logger.debug(f"Applied crop: {crop_coords}")
|
34
48
|
|
35
49
|
npz_path = os.path.splitext(image_path)[0] + ".npz"
|
36
|
-
|
50
|
+
|
51
|
+
# Create parent directory if it doesn't exist
|
52
|
+
parent_dir = os.path.dirname(npz_path)
|
53
|
+
if parent_dir: # Only create if there's actually a parent directory
|
54
|
+
os.makedirs(parent_dir, exist_ok=True)
|
55
|
+
logger.debug(f"Ensured directory exists: {parent_dir}")
|
56
|
+
|
57
|
+
# Save the NPZ file
|
58
|
+
try:
|
59
|
+
np.savez_compressed(npz_path, mask=final_mask_tensor.astype(np.uint8))
|
60
|
+
logger.debug(f"Saved NPZ file: {npz_path}")
|
61
|
+
except Exception as e:
|
62
|
+
raise OSError(f"Failed to save NPZ file {npz_path}: {str(e)}") from e
|
63
|
+
|
64
|
+
# Verify the file was actually created
|
65
|
+
if not os.path.exists(npz_path):
|
66
|
+
raise OSError(f"NPZ file was not created: {npz_path}")
|
67
|
+
|
68
|
+
logger.info(f"Successfully saved NPZ: {os.path.basename(npz_path)}")
|
37
69
|
return npz_path
|
38
70
|
|
39
71
|
def save_yolo_txt(
|
@@ -1176,6 +1176,8 @@ class MainWindow(QMainWindow):
|
|
1176
1176
|
# Right panel connections
|
1177
1177
|
self.right_panel.open_folder_requested.connect(self._open_folder_dialog)
|
1178
1178
|
self.right_panel.image_selected.connect(self._load_selected_image)
|
1179
|
+
# Connect new path-based signal from FastFileManager
|
1180
|
+
self.right_panel.image_path_selected.connect(self._load_image_from_path)
|
1179
1181
|
self.right_panel.merge_selection_requested.connect(
|
1180
1182
|
self._assign_selected_to_class
|
1181
1183
|
)
|
@@ -1625,6 +1627,13 @@ class MainWindow(QMainWindow):
|
|
1625
1627
|
self._start_background_image_discovery()
|
1626
1628
|
self.viewer.setFocus()
|
1627
1629
|
|
1630
|
+
def _load_image_from_path(self, file_path: Path):
|
1631
|
+
"""Load image from a Path object (used by FastFileManager)."""
|
1632
|
+
if file_path.is_file() and self.file_manager.is_image_file(str(file_path)):
|
1633
|
+
# Convert Path to QModelIndex for compatibility
|
1634
|
+
# This allows existing code to work while using the new file manager
|
1635
|
+
self._load_image_by_path(str(file_path))
|
1636
|
+
|
1628
1637
|
def _load_selected_image(self, index):
|
1629
1638
|
"""Load the selected image. Auto-saves previous work if enabled."""
|
1630
1639
|
|
@@ -1686,6 +1695,131 @@ class MainWindow(QMainWindow):
|
|
1686
1695
|
|
1687
1696
|
self._show_success_notification(f"Loaded: {Path(self.current_image_path).name}")
|
1688
1697
|
|
1698
|
+
def _load_image_by_path(self, path: str):
|
1699
|
+
"""Load image by file path directly (for FastFileManager)."""
|
1700
|
+
# Check if we're in multi-view mode
|
1701
|
+
if hasattr(self, "view_mode") and self.view_mode == "multi":
|
1702
|
+
# For multi-view, we need to handle differently
|
1703
|
+
# Load the selected image and consecutive ones
|
1704
|
+
self._load_multi_view_from_path(path)
|
1705
|
+
return
|
1706
|
+
|
1707
|
+
if path == self.current_image_path: # Only reset if loading a new image
|
1708
|
+
return
|
1709
|
+
|
1710
|
+
# Auto-save if enabled and we have a current image (not the first load)
|
1711
|
+
if self.current_image_path and self.control_panel.get_settings().get(
|
1712
|
+
"auto_save", True
|
1713
|
+
):
|
1714
|
+
self._save_output_to_npz()
|
1715
|
+
|
1716
|
+
self.segment_manager.clear()
|
1717
|
+
# Remove all scene items except the pixmap
|
1718
|
+
items_to_remove = [
|
1719
|
+
item
|
1720
|
+
for item in self.viewer.scene().items()
|
1721
|
+
if item is not self.viewer._pixmap_item
|
1722
|
+
]
|
1723
|
+
for item in items_to_remove:
|
1724
|
+
self.viewer.scene().removeItem(item)
|
1725
|
+
self.current_image_path = path
|
1726
|
+
|
1727
|
+
# Load the image
|
1728
|
+
original_image = cv2.imread(path)
|
1729
|
+
if original_image is None:
|
1730
|
+
logger.error(f"Failed to load image: {path}")
|
1731
|
+
return
|
1732
|
+
|
1733
|
+
# Convert BGR to RGB
|
1734
|
+
if len(original_image.shape) == 3:
|
1735
|
+
original_image = cv2.cvtColor(original_image, cv2.COLOR_BGR2RGB)
|
1736
|
+
self.original_image = original_image
|
1737
|
+
|
1738
|
+
# Convert to QImage and display
|
1739
|
+
height, width = original_image.shape[:2]
|
1740
|
+
bytes_per_line = 3 * width if len(original_image.shape) == 3 else width
|
1741
|
+
|
1742
|
+
if len(original_image.shape) == 3:
|
1743
|
+
q_image = QImage(
|
1744
|
+
original_image.data.tobytes(),
|
1745
|
+
width,
|
1746
|
+
height,
|
1747
|
+
bytes_per_line,
|
1748
|
+
QImage.Format.Format_RGB888,
|
1749
|
+
)
|
1750
|
+
else:
|
1751
|
+
q_image = QImage(
|
1752
|
+
original_image.data.tobytes(),
|
1753
|
+
width,
|
1754
|
+
height,
|
1755
|
+
bytes_per_line,
|
1756
|
+
QImage.Format.Format_Grayscale8,
|
1757
|
+
)
|
1758
|
+
|
1759
|
+
pixmap = QPixmap.fromImage(q_image)
|
1760
|
+
self.viewer.set_photo(pixmap)
|
1761
|
+
|
1762
|
+
# Load existing segments and class aliases
|
1763
|
+
self.file_manager.load_class_aliases(path)
|
1764
|
+
self.file_manager.load_existing_mask(path)
|
1765
|
+
|
1766
|
+
# Update UI lists to reflect loaded segments
|
1767
|
+
self._update_all_lists()
|
1768
|
+
|
1769
|
+
# Update display if we have an update method
|
1770
|
+
if hasattr(self, "_update_display"):
|
1771
|
+
self._update_display()
|
1772
|
+
self._show_success_notification(f"Loaded: {Path(path).name}")
|
1773
|
+
|
1774
|
+
# Update file selection in the file manager
|
1775
|
+
self.right_panel.select_file(Path(path))
|
1776
|
+
|
1777
|
+
def _load_multi_view_from_path(self, path: str):
|
1778
|
+
"""Load multi-view starting from a specific path using FastFileManager."""
|
1779
|
+
config = self._get_multi_view_config()
|
1780
|
+
num_viewers = config["num_viewers"]
|
1781
|
+
|
1782
|
+
# Auto-save if enabled
|
1783
|
+
if (
|
1784
|
+
hasattr(self, "multi_view_images")
|
1785
|
+
and self.multi_view_images
|
1786
|
+
and self.multi_view_images[0]
|
1787
|
+
and self.control_panel.get_settings().get("auto_save", True)
|
1788
|
+
):
|
1789
|
+
self._save_multi_view_output()
|
1790
|
+
|
1791
|
+
# Get all files from the FastFileManager model
|
1792
|
+
file_manager_model = self.right_panel.file_manager._model
|
1793
|
+
all_files = []
|
1794
|
+
current_idx = -1
|
1795
|
+
|
1796
|
+
# Collect all files from the model
|
1797
|
+
for i in range(file_manager_model.rowCount()):
|
1798
|
+
file_info = file_manager_model.getFileInfo(i)
|
1799
|
+
if file_info:
|
1800
|
+
all_files.append(str(file_info.path))
|
1801
|
+
if str(file_info.path) == path:
|
1802
|
+
current_idx = i
|
1803
|
+
|
1804
|
+
if current_idx == -1:
|
1805
|
+
# File not found in current list
|
1806
|
+
return
|
1807
|
+
|
1808
|
+
# Load consecutive images
|
1809
|
+
images_to_load = []
|
1810
|
+
for i in range(num_viewers):
|
1811
|
+
idx = current_idx + i
|
1812
|
+
if idx < len(all_files):
|
1813
|
+
images_to_load.append(all_files[idx])
|
1814
|
+
else:
|
1815
|
+
images_to_load.append(None)
|
1816
|
+
|
1817
|
+
# Load the images
|
1818
|
+
self._load_multi_view_images(images_to_load)
|
1819
|
+
|
1820
|
+
# Update file manager selection
|
1821
|
+
self.right_panel.select_file(Path(path))
|
1822
|
+
|
1689
1823
|
def _load_selected_image_multi_view(self, index, path):
|
1690
1824
|
"""Load selected image in multi-view mode starting from the selected file."""
|
1691
1825
|
# Auto-save if enabled and we have current images (not the first load)
|
@@ -2141,17 +2275,9 @@ class MainWindow(QMainWindow):
|
|
2141
2275
|
self._load_next_multi_batch()
|
2142
2276
|
return
|
2143
2277
|
|
2144
|
-
|
2145
|
-
|
2146
|
-
|
2147
|
-
row = self.current_file_index.row()
|
2148
|
-
# Find next valid image file
|
2149
|
-
for next_row in range(row + 1, self.file_model.rowCount(parent)):
|
2150
|
-
next_index = self.file_model.index(next_row, 0, parent)
|
2151
|
-
path = self.file_model.filePath(next_index)
|
2152
|
-
if os.path.isfile(path) and self.file_manager.is_image_file(path):
|
2153
|
-
self._load_selected_image(next_index)
|
2154
|
-
return
|
2278
|
+
# Use new file manager navigation
|
2279
|
+
self.right_panel.navigate_next_image()
|
2280
|
+
return
|
2155
2281
|
|
2156
2282
|
def _load_previous_image(self):
|
2157
2283
|
"""Load previous image in the file list."""
|
@@ -2160,17 +2286,9 @@ class MainWindow(QMainWindow):
|
|
2160
2286
|
self._load_previous_multi_batch()
|
2161
2287
|
return
|
2162
2288
|
|
2163
|
-
|
2164
|
-
|
2165
|
-
|
2166
|
-
row = self.current_file_index.row()
|
2167
|
-
# Find previous valid image file
|
2168
|
-
for prev_row in range(row - 1, -1, -1):
|
2169
|
-
prev_index = self.file_model.index(prev_row, 0, parent)
|
2170
|
-
path = self.file_model.filePath(prev_index)
|
2171
|
-
if os.path.isfile(path) and self.file_manager.is_image_file(path):
|
2172
|
-
self._load_selected_image(prev_index)
|
2173
|
-
return
|
2289
|
+
# Use new file manager navigation
|
2290
|
+
self.right_panel.navigate_previous_image()
|
2291
|
+
return
|
2174
2292
|
|
2175
2293
|
# Segment management methods
|
2176
2294
|
def _assign_selected_to_class(self):
|
@@ -2823,20 +2941,34 @@ class MainWindow(QMainWindow):
|
|
2823
2941
|
|
2824
2942
|
def _handle_enter_press(self):
|
2825
2943
|
"""Handle enter key press."""
|
2944
|
+
logger.debug(f"Enter pressed - mode: {self.mode}, view_mode: {self.view_mode}")
|
2945
|
+
|
2826
2946
|
if self.mode == "polygon":
|
2827
|
-
|
2828
|
-
self.
|
2829
|
-
|
2830
|
-
|
2831
|
-
|
2947
|
+
logger.debug(
|
2948
|
+
f"Polygon mode - polygon_points: {len(self.polygon_points) if hasattr(self, 'polygon_points') and self.polygon_points else 0}"
|
2949
|
+
)
|
2950
|
+
if self.view_mode == "single":
|
2951
|
+
# If there are pending polygon points, finalize them first
|
2952
|
+
if self.polygon_points:
|
2953
|
+
logger.debug("Finalizing pending polygon")
|
2954
|
+
self._finalize_polygon()
|
2955
|
+
# Always save after handling pending work to show checkmarks and notifications
|
2956
|
+
logger.debug("Saving polygon segments to NPZ")
|
2957
|
+
self._save_output_to_npz()
|
2958
|
+
elif self.view_mode == "multi":
|
2832
2959
|
# Complete polygons for all viewers that have points
|
2833
|
-
|
2834
|
-
|
2835
|
-
|
2836
|
-
|
2837
|
-
self
|
2838
|
-
|
2839
|
-
|
2960
|
+
if hasattr(self, "multi_view_polygon_points"):
|
2961
|
+
for i, points in enumerate(self.multi_view_polygon_points):
|
2962
|
+
if points and len(points) >= 3:
|
2963
|
+
# Use the multi-view mode handler for proper pairing logic
|
2964
|
+
if hasattr(self, "multi_view_mode_handler"):
|
2965
|
+
self.multi_view_mode_handler._finalize_multi_view_polygon(
|
2966
|
+
i
|
2967
|
+
)
|
2968
|
+
else:
|
2969
|
+
self._finalize_multi_view_polygon(i)
|
2970
|
+
# Always save after handling pending work to show checkmarks and notifications
|
2971
|
+
self._save_output_to_npz()
|
2840
2972
|
else:
|
2841
2973
|
# First accept any AI segments (same as spacebar), then save
|
2842
2974
|
self._accept_ai_segment()
|
@@ -3198,7 +3330,13 @@ class MainWindow(QMainWindow):
|
|
3198
3330
|
try:
|
3199
3331
|
os.remove(file_path)
|
3200
3332
|
deleted_files.append(os.path.basename(file_path))
|
3201
|
-
|
3333
|
+
# Update FastFileManager after file deletion
|
3334
|
+
if hasattr(self, "right_panel") and hasattr(
|
3335
|
+
self.right_panel, "file_manager"
|
3336
|
+
):
|
3337
|
+
self.right_panel.file_manager.updateNpzStatus(
|
3338
|
+
Path(image_path)
|
3339
|
+
)
|
3202
3340
|
except Exception as e:
|
3203
3341
|
self._show_error_notification(
|
3204
3342
|
f"Error deleting {file_path}: {e}"
|
@@ -3213,20 +3351,15 @@ class MainWindow(QMainWindow):
|
|
3213
3351
|
f"Error saving {os.path.basename(image_path)}: {str(e)}"
|
3214
3352
|
)
|
3215
3353
|
|
3216
|
-
# Update
|
3217
|
-
if hasattr(self, "
|
3218
|
-
for
|
3219
|
-
if
|
3220
|
-
|
3221
|
-
self
|
3222
|
-
|
3223
|
-
|
3224
|
-
|
3225
|
-
self.file_model.set_highlighted_path(None)
|
3226
|
-
if self.file_model.highlighted_path == p
|
3227
|
-
else None
|
3228
|
-
),
|
3229
|
-
)
|
3354
|
+
# Update FastFileManager to show NPZ checkmarks for multi-view
|
3355
|
+
if hasattr(self, "multi_view_images") and self.multi_view_images:
|
3356
|
+
for image_path in self.multi_view_images:
|
3357
|
+
if (
|
3358
|
+
image_path
|
3359
|
+
and hasattr(self, "right_panel")
|
3360
|
+
and hasattr(self.right_panel, "file_manager")
|
3361
|
+
):
|
3362
|
+
self.right_panel.file_manager.updateNpzStatus(Path(image_path))
|
3230
3363
|
# Clear the tracking list for next save
|
3231
3364
|
self._saved_file_paths = []
|
3232
3365
|
|
@@ -3258,7 +3391,13 @@ class MainWindow(QMainWindow):
|
|
3258
3391
|
try:
|
3259
3392
|
os.remove(file_path)
|
3260
3393
|
deleted_files.append(file_path)
|
3261
|
-
|
3394
|
+
# Update FastFileManager after file deletion
|
3395
|
+
if hasattr(self, "right_panel") and hasattr(
|
3396
|
+
self.right_panel, "file_manager"
|
3397
|
+
):
|
3398
|
+
self.right_panel.file_manager.updateNpzStatus(
|
3399
|
+
Path(self.current_image_path)
|
3400
|
+
)
|
3262
3401
|
except Exception as e:
|
3263
3402
|
self._show_error_notification(
|
3264
3403
|
f"Error deleting {file_path}: {e}"
|
@@ -3276,24 +3415,35 @@ class MainWindow(QMainWindow):
|
|
3276
3415
|
try:
|
3277
3416
|
settings = self.control_panel.get_settings()
|
3278
3417
|
npz_path = None
|
3279
|
-
|
3418
|
+
|
3419
|
+
# Debug logging
|
3420
|
+
logger.debug(f"Starting save process for: {self.current_image_path}")
|
3421
|
+
logger.debug(f"Number of segments: {len(self.segment_manager.segments)}")
|
3422
|
+
|
3280
3423
|
if settings.get("save_npz", True):
|
3281
3424
|
h, w = (
|
3282
3425
|
self.viewer._pixmap_item.pixmap().height(),
|
3283
3426
|
self.viewer._pixmap_item.pixmap().width(),
|
3284
3427
|
)
|
3285
3428
|
class_order = self.segment_manager.get_unique_class_ids()
|
3429
|
+
logger.debug(f"Class order for saving: {class_order}")
|
3430
|
+
|
3286
3431
|
if class_order:
|
3432
|
+
logger.debug(
|
3433
|
+
f"Attempting to save NPZ to: {os.path.splitext(self.current_image_path)[0]}.npz"
|
3434
|
+
)
|
3287
3435
|
npz_path = self.file_manager.save_npz(
|
3288
3436
|
self.current_image_path,
|
3289
3437
|
(h, w),
|
3290
3438
|
class_order,
|
3291
3439
|
self.current_crop_coords,
|
3292
3440
|
)
|
3441
|
+
logger.debug(f"NPZ save completed: {npz_path}")
|
3293
3442
|
self._show_success_notification(
|
3294
3443
|
f"Saved: {os.path.basename(npz_path)}"
|
3295
3444
|
)
|
3296
3445
|
else:
|
3446
|
+
logger.warning("No classes defined for saving")
|
3297
3447
|
self._show_warning_notification("No classes defined for saving.")
|
3298
3448
|
if settings.get("save_txt", True):
|
3299
3449
|
h, w = (
|
@@ -3308,27 +3458,25 @@ class MainWindow(QMainWindow):
|
|
3308
3458
|
else:
|
3309
3459
|
class_labels = [str(cid) for cid in class_order]
|
3310
3460
|
if class_order:
|
3311
|
-
|
3461
|
+
self.file_manager.save_yolo_txt(
|
3312
3462
|
self.current_image_path,
|
3313
3463
|
(h, w),
|
3314
3464
|
class_order,
|
3315
3465
|
class_labels,
|
3316
3466
|
self.current_crop_coords,
|
3317
3467
|
)
|
3318
|
-
#
|
3319
|
-
|
3320
|
-
|
3321
|
-
|
3322
|
-
|
3323
|
-
|
3324
|
-
|
3325
|
-
|
3326
|
-
|
3327
|
-
|
3328
|
-
else None
|
3329
|
-
),
|
3330
|
-
)
|
3468
|
+
# Update FastFileManager to show NPZ checkmarks
|
3469
|
+
if (
|
3470
|
+
npz_path
|
3471
|
+
and hasattr(self, "right_panel")
|
3472
|
+
and hasattr(self.right_panel, "file_manager")
|
3473
|
+
):
|
3474
|
+
# Update the NPZ status in the FastFileManager
|
3475
|
+
self.right_panel.file_manager.updateNpzStatus(
|
3476
|
+
Path(self.current_image_path)
|
3477
|
+
)
|
3331
3478
|
except Exception as e:
|
3479
|
+
logger.error(f"Error saving file: {str(e)}", exc_info=True)
|
3332
3480
|
self._show_error_notification(f"Error saving: {str(e)}")
|
3333
3481
|
|
3334
3482
|
def _handle_merge_press(self):
|
@@ -1,5 +1,7 @@
|
|
1
1
|
"""Right panel with file explorer and segment management."""
|
2
2
|
|
3
|
+
from pathlib import Path
|
4
|
+
|
3
5
|
from PyQt6.QtCore import Qt, pyqtSignal
|
4
6
|
from PyQt6.QtWidgets import (
|
5
7
|
QComboBox,
|
@@ -14,6 +16,7 @@ from PyQt6.QtWidgets import (
|
|
14
16
|
QWidget,
|
15
17
|
)
|
16
18
|
|
19
|
+
from ..utils.fast_file_manager import FastFileManager
|
17
20
|
from .reorderable_class_table import ReorderableClassTable
|
18
21
|
|
19
22
|
|
@@ -23,6 +26,7 @@ class RightPanel(QWidget):
|
|
23
26
|
# Signals
|
24
27
|
open_folder_requested = pyqtSignal()
|
25
28
|
image_selected = pyqtSignal("QModelIndex")
|
29
|
+
image_path_selected = pyqtSignal(Path) # New signal for path-based selection
|
26
30
|
merge_selection_requested = pyqtSignal()
|
27
31
|
delete_selection_requested = pyqtSignal()
|
28
32
|
segments_selection_changed = pyqtSignal()
|
@@ -109,8 +113,13 @@ class RightPanel(QWidget):
|
|
109
113
|
self.btn_open_folder.setToolTip("Open a directory of images")
|
110
114
|
layout.addWidget(self.btn_open_folder)
|
111
115
|
|
112
|
-
|
113
|
-
|
116
|
+
# Use new FastFileManager instead of QTreeView
|
117
|
+
self.file_manager = FastFileManager()
|
118
|
+
layout.addWidget(self.file_manager)
|
119
|
+
|
120
|
+
# Keep file_tree reference for compatibility
|
121
|
+
self.file_tree = QTreeView() # Hidden, for backward compatibility
|
122
|
+
self.file_tree.hide()
|
114
123
|
|
115
124
|
splitter.addWidget(file_explorer_widget)
|
116
125
|
|
@@ -195,6 +204,8 @@ class RightPanel(QWidget):
|
|
195
204
|
"""Connect internal signals."""
|
196
205
|
self.btn_open_folder.clicked.connect(self.open_folder_requested)
|
197
206
|
self.file_tree.doubleClicked.connect(self.image_selected)
|
207
|
+
# Connect new file manager signal
|
208
|
+
self.file_manager.fileSelected.connect(self.image_path_selected)
|
198
209
|
self.btn_merge_selection.clicked.connect(self.merge_selection_requested)
|
199
210
|
self.btn_delete_selection.clicked.connect(self.delete_selection_requested)
|
200
211
|
self.segment_table.itemSelectionChanged.connect(self.segments_selection_changed)
|
@@ -276,12 +287,28 @@ class RightPanel(QWidget):
|
|
276
287
|
|
277
288
|
def setup_file_model(self, file_model):
|
278
289
|
"""Setup the file model for the tree view."""
|
290
|
+
# Keep for backward compatibility
|
279
291
|
self.file_tree.setModel(file_model)
|
280
292
|
self.file_tree.setColumnWidth(0, 200)
|
281
293
|
|
282
294
|
def set_folder(self, folder_path, file_model):
|
283
295
|
"""Set the folder for file browsing."""
|
296
|
+
# Keep old tree view for compatibility
|
284
297
|
self.file_tree.setRootIndex(file_model.setRootPath(folder_path))
|
298
|
+
# Use new file manager
|
299
|
+
self.file_manager.setDirectory(Path(folder_path))
|
300
|
+
|
301
|
+
def navigate_next_image(self):
|
302
|
+
"""Navigate to next image in the file manager."""
|
303
|
+
self.file_manager.navigateNext()
|
304
|
+
|
305
|
+
def navigate_previous_image(self):
|
306
|
+
"""Navigate to previous image in the file manager."""
|
307
|
+
self.file_manager.navigatePrevious()
|
308
|
+
|
309
|
+
def select_file(self, file_path: Path):
|
310
|
+
"""Select a specific file in the file manager."""
|
311
|
+
self.file_manager.selectFile(file_path)
|
285
312
|
|
286
313
|
def get_selected_segment_indices(self):
|
287
314
|
"""Get indices of selected segments."""
|