lazylabel-gui 1.1.5__tar.gz → 1.1.6__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.1.5/src/lazylabel_gui.egg-info → lazylabel_gui-1.1.6}/PKG-INFO +2 -1
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/README.md +189 -188
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/pyproject.toml +1 -1
- lazylabel_gui-1.1.6/src/lazylabel/__main__.py +6 -0
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel/config/settings.py +72 -65
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel/core/file_manager.py +123 -122
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel/core/model_manager.py +96 -95
- lazylabel_gui-1.1.6/src/lazylabel/main.py +39 -0
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel/models/sam_model.py +211 -200
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel/ui/control_panel.py +283 -245
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel/ui/hotkey_dialog.py +417 -416
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel/ui/main_window.py +2020 -1882
- lazylabel_gui-1.1.6/src/lazylabel/ui/photo_viewer.py +105 -0
- lazylabel_gui-1.1.6/src/lazylabel/ui/widgets/adjustments_widget.py +372 -0
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel/ui/widgets/settings_widget.py +125 -113
- lazylabel_gui-1.1.6/src/lazylabel/utils/logger.py +45 -0
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6/src/lazylabel_gui.egg-info}/PKG-INFO +2 -1
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel_gui.egg-info/SOURCES.txt +2 -0
- lazylabel_gui-1.1.5/src/lazylabel/main.py +0 -37
- lazylabel_gui-1.1.5/src/lazylabel/ui/photo_viewer.py +0 -51
- lazylabel_gui-1.1.5/src/lazylabel/ui/widgets/adjustments_widget.py +0 -108
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/LICENSE +0 -0
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/setup.cfg +0 -0
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel/__init__.py +0 -0
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel/config/__init__.py +0 -0
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel/config/hotkeys.py +0 -0
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel/config/paths.py +0 -0
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel/core/__init__.py +0 -0
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel/core/segment_manager.py +0 -0
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel/models/__init__.py +0 -0
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel/ui/__init__.py +0 -0
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel/ui/editable_vertex.py +0 -0
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel/ui/hoverable_pixelmap_item.py +0 -0
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel/ui/hoverable_polygon_item.py +0 -0
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel/ui/numeric_table_widget_item.py +0 -0
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel/ui/reorderable_class_table.py +0 -0
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel/ui/right_panel.py +0 -0
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel/ui/widgets/__init__.py +0 -0
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel/ui/widgets/model_selection_widget.py +0 -0
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel/ui/widgets/status_bar.py +0 -0
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel/utils/__init__.py +0 -0
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel/utils/custom_file_system_model.py +0 -0
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel/utils/utils.py +0 -0
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel_gui.egg-info/dependency_links.txt +0 -0
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel_gui.egg-info/entry_points.txt +0 -0
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/src/lazylabel_gui.egg-info/requires.txt +0 -0
- {lazylabel_gui-1.1.5 → lazylabel_gui-1.1.6}/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.1.
|
3
|
+
Version: 1.1.6
|
4
4
|
Summary: An image segmentation GUI for generating ML ready mask tensors and annotations.
|
5
5
|
Author-email: "Deniz N. Cakan" <deniz.n.cakan@gmail.com>
|
6
6
|
License: MIT License
|
@@ -139,6 +139,7 @@ Inspired by [LabelMe](https://github.com/wkentaro/labelme?tab=readme-ov-file#ins
|
|
139
139
|
|---|---|
|
140
140
|
| `1` | Enter **Point Mode** (for AI segmentation). |
|
141
141
|
| `2` | Enter **Polygon Drawing Mode**. |
|
142
|
+
| `3` | Enter **Bounding Box Mode**. |
|
142
143
|
| `E` | Toggle **Selection Mode** to select existing segments. |
|
143
144
|
| `R` | Enter **Edit Mode** for selected polygons (drag shape or vertices). |
|
144
145
|
| `Q` | Toggle **Pan Mode** (click and drag the image). |
|
@@ -1,188 +1,189 @@
|
|
1
|
-
# <img src="https://raw.githubusercontent.com/dnzckn/LazyLabel/main/src/lazylabel/demo_pictures/logo2.png" alt="LazyLabel Logo" style="height:60px; vertical-align:middle;" /> <img src="https://raw.githubusercontent.com/dnzckn/LazyLabel/main/src/lazylabel/demo_pictures/logo_black.png" alt="LazyLabel Cursive" style="height:60px; vertical-align:middle;" />
|
2
|
-
|
3
|
-
LazyLabel is an intuitive, AI-assisted image segmentation tool built with a modern, modular architecture. It uses Meta's Segment Anything Model (SAM) for quick, precise mask generation, alongside advanced polygon editing for fine-tuned control. Features comprehensive model management, customizable hotkeys, and outputs in clean, one-hot encoded `.npz` format for easy machine learning integration.
|
4
|
-
|
5
|
-
Inspired by [LabelMe](https://github.com/wkentaro/labelme?tab=readme-ov-file#installation) and [Segment-Anything-UI](https://github.com/branislavhesko/segment-anything-ui/tree/main).
|
6
|
-
|
7
|
-

|
8
|
-
|
9
|
-
---
|
10
|
-
|
11
|
-
## ✨ Core Features
|
12
|
-
|
13
|
-
### **AI-Powered Segmentation**
|
14
|
-
* Generate masks with simple left-click (positive) and right-click (negative) interactions
|
15
|
-
* Multiple SAM model support with easy switching
|
16
|
-
* Custom model loading from any directory
|
17
|
-
|
18
|
-
### **Advanced Editing Tools**
|
19
|
-
* **Vector Polygon Tool**: Full control to draw, edit, and reshape polygons
|
20
|
-
* **Vertex Editing**: Drag vertices or move entire shapes with precision
|
21
|
-
* **Selection & Merging**: Select, merge, and re-order segments intuitively
|
22
|
-
|
23
|
-
### **Professional Workflow**
|
24
|
-
* **Customizable Hotkeys**: Personalize keyboard shortcuts for all functions
|
25
|
-
* **Advanced Class Management**: Assign multiple segments to single class IDs
|
26
|
-
* **Smart I/O**: Load existing `.npz` masks; save as clean, one-hot encoded outputs
|
27
|
-
* **Interactive UI**: Color-coded segments, sortable lists, and hover highlighting
|
28
|
-
|
29
|
-
### **Modern Architecture**
|
30
|
-
* **Modular Design**: Clean, maintainable codebase with separated concerns
|
31
|
-
* **Model Management**: Dedicated model storage and switching system
|
32
|
-
* **Persistent Settings**: User preferences saved between sessions
|
33
|
-
|
34
|
-
---
|
35
|
-
|
36
|
-
## 🚀 Getting Started
|
37
|
-
|
38
|
-
### Prerequisites
|
39
|
-
**Python 3.10+**
|
40
|
-
|
41
|
-
### Installation
|
42
|
-
|
43
|
-
#### For Users [via PyPI](https://pypi.org/project/lazylabel-gui/)
|
44
|
-
1. Install LazyLabel directly:
|
45
|
-
```bash
|
46
|
-
pip install lazylabel-gui
|
47
|
-
```
|
48
|
-
2. Run the application:
|
49
|
-
```bash
|
50
|
-
lazylabel-gui
|
51
|
-
```
|
52
|
-
|
53
|
-
#### For Developers (from Source)
|
54
|
-
1. Clone the repository:
|
55
|
-
```bash
|
56
|
-
git clone https://github.com/dnzckn/LazyLabel.git
|
57
|
-
cd LazyLabel
|
58
|
-
```
|
59
|
-
2. Install in editable mode:
|
60
|
-
```bash
|
61
|
-
pip install -e .
|
62
|
-
```
|
63
|
-
3. Run the application:
|
64
|
-
```bash
|
65
|
-
lazylabel-gui
|
66
|
-
```
|
67
|
-
|
68
|
-
### Model Management
|
69
|
-
* **Default Storage**: Models are stored in `src/lazylabel/models/` directory
|
70
|
-
* **Custom Models**: Click "Browse Models" to select custom model folders
|
71
|
-
* **Model Switching**: Use the dropdown to switch between available models
|
72
|
-
* **Auto-Detection**: Application automatically detects all `.pth` files in selected directories
|
73
|
-
|
74
|
-
**Note**: On the first run, the application will automatically download the SAM model checkpoint (~2.5 GB) from Meta's repository to the models directory. This is a one-time download.
|
75
|
-
|
76
|
-
---
|
77
|
-
|
78
|
-
## ⌨️ Controls & Keybinds
|
79
|
-
|
80
|
-
> **💡 Tip**: All hotkeys are fully customizable! Click the "Hotkeys" button in the control panel to personalize your shortcuts.
|
81
|
-
|
82
|
-
### Modes
|
83
|
-
| Key | Action |
|
84
|
-
|---|---|
|
85
|
-
| `1` | Enter **Point Mode** (for AI segmentation). |
|
86
|
-
| `2` | Enter **Polygon Drawing Mode**. |
|
87
|
-
| `
|
88
|
-
| `
|
89
|
-
| `
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
| `
|
96
|
-
| `
|
97
|
-
| `Ctrl +
|
98
|
-
| `
|
99
|
-
| `
|
100
|
-
| `
|
101
|
-
| `
|
102
|
-
| `
|
103
|
-
| `
|
104
|
-
| `
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
* `
|
115
|
-
* `
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
* **
|
127
|
-
* **
|
128
|
-
* **
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
* **
|
140
|
-
* **
|
141
|
-
* **
|
142
|
-
* **
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
1
|
+
# <img src="https://raw.githubusercontent.com/dnzckn/LazyLabel/main/src/lazylabel/demo_pictures/logo2.png" alt="LazyLabel Logo" style="height:60px; vertical-align:middle;" /> <img src="https://raw.githubusercontent.com/dnzckn/LazyLabel/main/src/lazylabel/demo_pictures/logo_black.png" alt="LazyLabel Cursive" style="height:60px; vertical-align:middle;" />
|
2
|
+
|
3
|
+
LazyLabel is an intuitive, AI-assisted image segmentation tool built with a modern, modular architecture. It uses Meta's Segment Anything Model (SAM) for quick, precise mask generation, alongside advanced polygon editing for fine-tuned control. Features comprehensive model management, customizable hotkeys, and outputs in clean, one-hot encoded `.npz` format for easy machine learning integration.
|
4
|
+
|
5
|
+
Inspired by [LabelMe](https://github.com/wkentaro/labelme?tab=readme-ov-file#installation) and [Segment-Anything-UI](https://github.com/branislavhesko/segment-anything-ui/tree/main).
|
6
|
+
|
7
|
+

|
8
|
+
|
9
|
+
---
|
10
|
+
|
11
|
+
## ✨ Core Features
|
12
|
+
|
13
|
+
### **AI-Powered Segmentation**
|
14
|
+
* Generate masks with simple left-click (positive) and right-click (negative) interactions
|
15
|
+
* Multiple SAM model support with easy switching
|
16
|
+
* Custom model loading from any directory
|
17
|
+
|
18
|
+
### **Advanced Editing Tools**
|
19
|
+
* **Vector Polygon Tool**: Full control to draw, edit, and reshape polygons
|
20
|
+
* **Vertex Editing**: Drag vertices or move entire shapes with precision
|
21
|
+
* **Selection & Merging**: Select, merge, and re-order segments intuitively
|
22
|
+
|
23
|
+
### **Professional Workflow**
|
24
|
+
* **Customizable Hotkeys**: Personalize keyboard shortcuts for all functions
|
25
|
+
* **Advanced Class Management**: Assign multiple segments to single class IDs
|
26
|
+
* **Smart I/O**: Load existing `.npz` masks; save as clean, one-hot encoded outputs
|
27
|
+
* **Interactive UI**: Color-coded segments, sortable lists, and hover highlighting
|
28
|
+
|
29
|
+
### **Modern Architecture**
|
30
|
+
* **Modular Design**: Clean, maintainable codebase with separated concerns
|
31
|
+
* **Model Management**: Dedicated model storage and switching system
|
32
|
+
* **Persistent Settings**: User preferences saved between sessions
|
33
|
+
|
34
|
+
---
|
35
|
+
|
36
|
+
## 🚀 Getting Started
|
37
|
+
|
38
|
+
### Prerequisites
|
39
|
+
**Python 3.10+**
|
40
|
+
|
41
|
+
### Installation
|
42
|
+
|
43
|
+
#### For Users [via PyPI](https://pypi.org/project/lazylabel-gui/)
|
44
|
+
1. Install LazyLabel directly:
|
45
|
+
```bash
|
46
|
+
pip install lazylabel-gui
|
47
|
+
```
|
48
|
+
2. Run the application:
|
49
|
+
```bash
|
50
|
+
lazylabel-gui
|
51
|
+
```
|
52
|
+
|
53
|
+
#### For Developers (from Source)
|
54
|
+
1. Clone the repository:
|
55
|
+
```bash
|
56
|
+
git clone https://github.com/dnzckn/LazyLabel.git
|
57
|
+
cd LazyLabel
|
58
|
+
```
|
59
|
+
2. Install in editable mode:
|
60
|
+
```bash
|
61
|
+
pip install -e .
|
62
|
+
```
|
63
|
+
3. Run the application:
|
64
|
+
```bash
|
65
|
+
lazylabel-gui
|
66
|
+
```
|
67
|
+
|
68
|
+
### Model Management
|
69
|
+
* **Default Storage**: Models are stored in `src/lazylabel/models/` directory
|
70
|
+
* **Custom Models**: Click "Browse Models" to select custom model folders
|
71
|
+
* **Model Switching**: Use the dropdown to switch between available models
|
72
|
+
* **Auto-Detection**: Application automatically detects all `.pth` files in selected directories
|
73
|
+
|
74
|
+
**Note**: On the first run, the application will automatically download the SAM model checkpoint (~2.5 GB) from Meta's repository to the models directory. This is a one-time download.
|
75
|
+
|
76
|
+
---
|
77
|
+
|
78
|
+
## ⌨️ Controls & Keybinds
|
79
|
+
|
80
|
+
> **💡 Tip**: All hotkeys are fully customizable! Click the "Hotkeys" button in the control panel to personalize your shortcuts.
|
81
|
+
|
82
|
+
### Modes
|
83
|
+
| Key | Action |
|
84
|
+
|---|---|
|
85
|
+
| `1` | Enter **Point Mode** (for AI segmentation). |
|
86
|
+
| `2` | Enter **Polygon Drawing Mode**. |
|
87
|
+
| `3` | Enter **Bounding Box Mode**. |
|
88
|
+
| `E` | Toggle **Selection Mode** to select existing segments. |
|
89
|
+
| `R` | Enter **Edit Mode** for selected polygons (drag shape or vertices). |
|
90
|
+
| `Q` | Toggle **Pan Mode** (click and drag the image). |
|
91
|
+
|
92
|
+
### Actions
|
93
|
+
| Key(s) | Action |
|
94
|
+
|---|---|
|
95
|
+
| `L-Click` | Add positive point (Point Mode) or polygon vertex. |
|
96
|
+
| `R-Click` | Add negative point (Point Mode). |
|
97
|
+
| `Ctrl + Z` | Undo last action. |
|
98
|
+
| `Ctrl + Y` / `Ctrl + Shift + Z` | Redo last action. |
|
99
|
+
| `Spacebar` | Finalize and save current AI segment. |
|
100
|
+
| `Enter` | **Save final mask for the current image to a `.npz` file.** |
|
101
|
+
| `M` | **Merge** selected segments into a single class. |
|
102
|
+
| `V` / `Delete` / `Backspace`| **Delete** selected segments. |
|
103
|
+
| `C` | Clear temporary points/vertices. |
|
104
|
+
| `W/A/S/D` | Pan image. |
|
105
|
+
| `Scroll Wheel` | Zoom-in or -out. |
|
106
|
+
|
107
|
+
---
|
108
|
+
|
109
|
+
## 📦 Output Format
|
110
|
+
|
111
|
+
LazyLabel saves your work as a compressed NumPy array (`.npz`) with the same name as your image file.
|
112
|
+
|
113
|
+
The file contains a single data key, `'mask'`, holding a **one-hot encoded tensor** with the shape `(H, W, C)`:
|
114
|
+
* `H`: Image height.
|
115
|
+
* `W`: Image width.
|
116
|
+
* `C`: Total unique classes.
|
117
|
+
|
118
|
+
Each channel is a binary mask for a class, combining all assigned segments into a clean, ML-ready output.
|
119
|
+
|
120
|
+
---
|
121
|
+
|
122
|
+
## 🏗️ Architecture
|
123
|
+
|
124
|
+
LazyLabel features a modern, modular architecture designed for maintainability and extensibility:
|
125
|
+
|
126
|
+
* **Modular Design**: Clean separation between UI, business logic, and configuration
|
127
|
+
* **Signal-Based Communication**: Loose coupling between components using PyQt signals
|
128
|
+
* **Persistent Configuration**: User settings and preferences saved between sessions
|
129
|
+
* **Extensible Model System**: Easy integration of new SAM models and types
|
130
|
+
|
131
|
+
For detailed technical documentation, see [ARCHITECTURE.md](src/lazylabel/ARCHITECTURE.md).
|
132
|
+
|
133
|
+
---
|
134
|
+
|
135
|
+
## ⌨️ Hotkey Customization
|
136
|
+
|
137
|
+
LazyLabel includes a comprehensive hotkey management system:
|
138
|
+
|
139
|
+
* **Full Customization**: Personalize keyboard shortcuts for all 27+ functions
|
140
|
+
* **Category Organization**: Hotkeys organized by function (Modes, Actions, Navigation, etc.)
|
141
|
+
* **Primary & Secondary Keys**: Set multiple shortcuts for the same action
|
142
|
+
* **Persistent Settings**: Custom hotkeys saved between sessions
|
143
|
+
* **Conflict Prevention**: System prevents duplicate key assignments
|
144
|
+
|
145
|
+
For complete hotkey documentation, see [HOTKEY_FEATURE.md](src/lazylabel/HOTKEY_FEATURE.md).
|
146
|
+
|
147
|
+
## Development
|
148
|
+
|
149
|
+
### Code Quality
|
150
|
+
This project uses Ruff for linting and formatting:
|
151
|
+
|
152
|
+
```bash
|
153
|
+
# Activate virtual environment first
|
154
|
+
& e:\venv\lazylabel\Scripts\Activate.ps1
|
155
|
+
|
156
|
+
# Run linter
|
157
|
+
ruff check .
|
158
|
+
|
159
|
+
# Fix auto-fixable issues
|
160
|
+
ruff check --fix .
|
161
|
+
|
162
|
+
# Format code
|
163
|
+
ruff format .
|
164
|
+
|
165
|
+
# Check if code is properly formatted
|
166
|
+
ruff format --check .
|
167
|
+
```
|
168
|
+
|
169
|
+
### Testing
|
170
|
+
|
171
|
+
Run tests using pytest:
|
172
|
+
|
173
|
+
```bash
|
174
|
+
# Run all tests
|
175
|
+
python -m pytest
|
176
|
+
|
177
|
+
# Run tests with coverage
|
178
|
+
python -m pytest --cov=lazylabel --cov-report=html --cov-report=term-missing
|
179
|
+
|
180
|
+
# Run specific test file
|
181
|
+
python -m pytest tests/unit/ui/test_undo_redo.py -v
|
182
|
+
```
|
183
|
+
|
184
|
+
The HTML coverage report will be generated in `htmlcov/` directory.
|
185
|
+
|
186
|
+
---
|
187
|
+
|
188
|
+
## ☕ Support LazyLabel
|
189
|
+
[If you found LazyLabel helpful, consider supporting the project!](https://buymeacoffee.com/dnzckn)
|
@@ -1,65 +1,72 @@
|
|
1
|
-
"""Application settings and configuration."""
|
2
|
-
|
3
|
-
import json
|
4
|
-
import os
|
5
|
-
from dataclasses import asdict, dataclass
|
6
|
-
|
7
|
-
|
8
|
-
@dataclass
|
9
|
-
class Settings:
|
10
|
-
"""Application settings with defaults."""
|
11
|
-
|
12
|
-
# UI Settings
|
13
|
-
window_width: int = 1600
|
14
|
-
window_height: int = 900
|
15
|
-
left_panel_width: int = 250
|
16
|
-
right_panel_width: int = 350
|
17
|
-
|
18
|
-
# Annotation Settings
|
19
|
-
point_radius: float = 0.3
|
20
|
-
line_thickness: float = 0.5
|
21
|
-
pan_multiplier: float = 1.0
|
22
|
-
polygon_join_threshold: int = 2
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
#
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
def
|
46
|
-
"""
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
return cls()
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
1
|
+
"""Application settings and configuration."""
|
2
|
+
|
3
|
+
import json
|
4
|
+
import os
|
5
|
+
from dataclasses import asdict, dataclass
|
6
|
+
|
7
|
+
|
8
|
+
@dataclass
|
9
|
+
class Settings:
|
10
|
+
"""Application settings with defaults."""
|
11
|
+
|
12
|
+
# UI Settings
|
13
|
+
window_width: int = 1600
|
14
|
+
window_height: int = 900
|
15
|
+
left_panel_width: int = 250
|
16
|
+
right_panel_width: int = 350
|
17
|
+
|
18
|
+
# Annotation Settings
|
19
|
+
point_radius: float = 0.3
|
20
|
+
line_thickness: float = 0.5
|
21
|
+
pan_multiplier: float = 1.0
|
22
|
+
polygon_join_threshold: int = 2
|
23
|
+
fragment_threshold: int = 0
|
24
|
+
|
25
|
+
# Image Adjustment Settings
|
26
|
+
brightness: float = 0.0
|
27
|
+
contrast: float = 0.0
|
28
|
+
gamma: float = 1.0
|
29
|
+
|
30
|
+
# Model Settings
|
31
|
+
default_model_type: str = "vit_h"
|
32
|
+
default_model_filename: str = "sam_vit_h_4b8939.pth"
|
33
|
+
operate_on_view: bool = False
|
34
|
+
|
35
|
+
# Save Settings
|
36
|
+
auto_save: bool = True
|
37
|
+
save_npz: bool = True
|
38
|
+
save_txt: bool = True
|
39
|
+
save_class_aliases: bool = False
|
40
|
+
yolo_use_alias: bool = True
|
41
|
+
|
42
|
+
# UI State
|
43
|
+
annotation_size_multiplier: float = 1.0
|
44
|
+
|
45
|
+
def save_to_file(self, filepath: str) -> None:
|
46
|
+
"""Save settings to JSON file."""
|
47
|
+
os.makedirs(os.path.dirname(filepath), exist_ok=True)
|
48
|
+
with open(filepath, "w") as f:
|
49
|
+
json.dump(asdict(self), f, indent=4)
|
50
|
+
|
51
|
+
@classmethod
|
52
|
+
def load_from_file(cls, filepath: str) -> "Settings":
|
53
|
+
"""Load settings from JSON file."""
|
54
|
+
if not os.path.exists(filepath):
|
55
|
+
return cls()
|
56
|
+
|
57
|
+
try:
|
58
|
+
with open(filepath) as f:
|
59
|
+
data = json.load(f)
|
60
|
+
return cls(**data)
|
61
|
+
except (json.JSONDecodeError, TypeError):
|
62
|
+
return cls()
|
63
|
+
|
64
|
+
def update(self, **kwargs) -> None:
|
65
|
+
"""Update settings with new values."""
|
66
|
+
for key, value in kwargs.items():
|
67
|
+
if hasattr(self, key):
|
68
|
+
setattr(self, key, value)
|
69
|
+
|
70
|
+
|
71
|
+
# Default settings instance
|
72
|
+
DEFAULT_SETTINGS = Settings()
|