simple-napari-cci-annotator 0.0.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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 LECLERC Simon
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,168 @@
1
+ Metadata-Version: 2.4
2
+ Name: simple-napari-cci-annotator
3
+ Version: 0.0.2
4
+ Summary: Plugin to easly test a yolo model and retrain it
5
+ Author: Simon Leclerc
6
+ Author-email: simon.leclerc@gu.se
7
+ License: MIT License
8
+
9
+ Copyright (c) 2026 LECLERC Simon
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
28
+
29
+ Classifier: Development Status :: 2 - Pre-Alpha
30
+ Classifier: Framework :: napari
31
+ Classifier: Intended Audience :: Developers
32
+ Classifier: Operating System :: OS Independent
33
+ Classifier: Programming Language :: Python
34
+ Classifier: Programming Language :: Python :: 3
35
+ Classifier: Programming Language :: Python :: 3 :: Only
36
+ Classifier: Programming Language :: Python :: 3.10
37
+ Classifier: Programming Language :: Python :: 3.11
38
+ Classifier: Programming Language :: Python :: 3.12
39
+ Classifier: Topic :: Scientific/Engineering :: Image Processing
40
+ Requires-Python: >=3.9
41
+ Description-Content-Type: text/markdown
42
+ License-File: LICENSE
43
+ Requires-Dist: numpy
44
+ Requires-Dist: qtpy
45
+ Requires-Dist: ultralytics
46
+ Requires-Dist: pillow
47
+ Provides-Extra: all
48
+ Requires-Dist: napari[all]; extra == "all"
49
+ Provides-Extra: testing
50
+ Requires-Dist: tox; extra == "testing"
51
+ Requires-Dist: pytest; extra == "testing"
52
+ Requires-Dist: pytest-cov; extra == "testing"
53
+ Requires-Dist: pytest-qt; extra == "testing"
54
+ Requires-Dist: napari; extra == "testing"
55
+ Requires-Dist: pyqt5; extra == "testing"
56
+ Dynamic: license-file
57
+
58
+
59
+ [![License MIT](https://img.shields.io/badge/license-MIT-green)](https://github.com/CCI-GU-Sweden/simple-napari-cci-annotator/blob/main/LICENSE)
60
+ [![Python 3.10–3.12](https://img.shields.io/badge/python-3.10%20|%203.11%20|%203.12-blue)](https://python.org)
61
+ [![tests](https://github.com/CCI-GU-Sweden/simple-napari-cci-annotator/workflows/tests/badge.svg)](https://github.com/CCI-GU-Sweden/simple-napari-cci-annotator/actions)
62
+
63
+ # Simple napari annotator
64
+
65
+ Minimal napari plugin for YOLO bbox detection + quick correction + retraining.
66
+
67
+ No dataset browser, no extra workflow logic. User provides the image in napari.
68
+
69
+ ## UI flow
70
+
71
+ 1. Path to model (`.pt`) or model folder
72
+ 2. `Load model`
73
+ 3. `Predict`
74
+ 4. Optional destination folder for retrained model (browse or type)
75
+ 5. Edit boxes in napari shapes layer (`yolo_bboxes`)
76
+ 6. `Add correction`
77
+ 7. `Retrain`
78
+
79
+ ![UI](assets/Plugin_UI.png)
80
+
81
+ ## Starting from scratch
82
+
83
+ The model input supports either:
84
+
85
+ - A `.pt` model file, or
86
+ - A folder path.
87
+
88
+ Folder behavior on `Load model`:
89
+
90
+ - If the folder already contains one or more `.pt` files, the first one is loaded.
91
+ - If the folder contains no `.pt` file, the plugin copies the bundled `yolov8n.pt` into that folder and loads it.
92
+ - Empty model input is invalid and will show an error.
93
+
94
+ If you do not have a model yet, start from a pretrained YOLOv8 nano checkpoint and use it as your initial file:
95
+
96
+ - Direct download: <https://github.com/ultralytics/assets/releases/latest/download/yolov8n.pt>
97
+ - Model overview: <https://docs.ultralytics.com/models/yolov8/>
98
+
99
+ After downloading, select that `yolov8n.pt` file in the Model field and continue with the correction/retrain loop.
100
+
101
+ ![Loading a model](assets/Loading_model.png)
102
+
103
+ ## Assumptions
104
+
105
+ - Input image is already RGB 8-bit (or compatible with clipping/conversion).
106
+ - Single class (`0: LABEL`) for now.
107
+ - Exactly one image layer should be present when using `Add correction`.
108
+
109
+ ![Predicting label](assets/Predicting_label.png)
110
+
111
+ ## Folder behavior
112
+
113
+ Given a model path like:
114
+
115
+ `.../my_model/best.pt`
116
+
117
+ The plugin uses `.../my_model` as root.
118
+
119
+ ### Add correction
120
+
121
+ Each click saves:
122
+
123
+ - Image to `my_model/corrections/<image_name>_<timestamp>.png`
124
+ - Labels to `my_model/corrections/<image_name>_<timestamp>.txt`
125
+ - Training config to `my_model/corrections/training_config.json` (created/updated)
126
+
127
+ Image layer behavior:
128
+
129
+ - If no image layer exists, `Add correction` shows an error.
130
+ - If more than one image layer exists, `Add correction` shows an error.
131
+ - If exactly one image layer exists, that image layer is used for saving correction image data.
132
+
133
+ `training_config.json` defaults:
134
+
135
+ - `image_size`: prefilled from the current image size using `max(height, width)`
136
+ - `batch`: `8`
137
+ - `epochs`: `100`
138
+ - `patience`: `30`
139
+
140
+ You can edit this file before clicking `Retrain`.
141
+
142
+ Label format is YOLO detection:
143
+
144
+ `class x_center y_center width height`
145
+
146
+ normalized to `[0, 1]`.
147
+
148
+ ### Retrain
149
+
150
+ Each click creates:
151
+
152
+ - `<retrain_root>/dataset/`
153
+ - `images/train`, `images/val`
154
+ - `labels/train`, `labels/val`
155
+ - `dataset.yaml`
156
+ - Trains YOLO from those corrections
157
+ - Copies best model to:
158
+ - `<retrain_root>/best.pt`
159
+ - Deletes training traces folder after extracting `best.pt`
160
+
161
+ `<retrain_root>` resolution:
162
+
163
+ - If destination field is set, retraining outputs there.
164
+ - Otherwise it defaults to `my_model/retrained_<timestamp>`.
165
+
166
+ So the retrained folder keeps a clean dataset + final model, without run artifacts.
167
+
168
+ Warning: Data labeled will be equally divided between traning and validation (50%).
@@ -0,0 +1,111 @@
1
+
2
+ [![License MIT](https://img.shields.io/badge/license-MIT-green)](https://github.com/CCI-GU-Sweden/simple-napari-cci-annotator/blob/main/LICENSE)
3
+ [![Python 3.10–3.12](https://img.shields.io/badge/python-3.10%20|%203.11%20|%203.12-blue)](https://python.org)
4
+ [![tests](https://github.com/CCI-GU-Sweden/simple-napari-cci-annotator/workflows/tests/badge.svg)](https://github.com/CCI-GU-Sweden/simple-napari-cci-annotator/actions)
5
+
6
+ # Simple napari annotator
7
+
8
+ Minimal napari plugin for YOLO bbox detection + quick correction + retraining.
9
+
10
+ No dataset browser, no extra workflow logic. User provides the image in napari.
11
+
12
+ ## UI flow
13
+
14
+ 1. Path to model (`.pt`) or model folder
15
+ 2. `Load model`
16
+ 3. `Predict`
17
+ 4. Optional destination folder for retrained model (browse or type)
18
+ 5. Edit boxes in napari shapes layer (`yolo_bboxes`)
19
+ 6. `Add correction`
20
+ 7. `Retrain`
21
+
22
+ ![UI](assets/Plugin_UI.png)
23
+
24
+ ## Starting from scratch
25
+
26
+ The model input supports either:
27
+
28
+ - A `.pt` model file, or
29
+ - A folder path.
30
+
31
+ Folder behavior on `Load model`:
32
+
33
+ - If the folder already contains one or more `.pt` files, the first one is loaded.
34
+ - If the folder contains no `.pt` file, the plugin copies the bundled `yolov8n.pt` into that folder and loads it.
35
+ - Empty model input is invalid and will show an error.
36
+
37
+ If you do not have a model yet, start from a pretrained YOLOv8 nano checkpoint and use it as your initial file:
38
+
39
+ - Direct download: <https://github.com/ultralytics/assets/releases/latest/download/yolov8n.pt>
40
+ - Model overview: <https://docs.ultralytics.com/models/yolov8/>
41
+
42
+ After downloading, select that `yolov8n.pt` file in the Model field and continue with the correction/retrain loop.
43
+
44
+ ![Loading a model](assets/Loading_model.png)
45
+
46
+ ## Assumptions
47
+
48
+ - Input image is already RGB 8-bit (or compatible with clipping/conversion).
49
+ - Single class (`0: LABEL`) for now.
50
+ - Exactly one image layer should be present when using `Add correction`.
51
+
52
+ ![Predicting label](assets/Predicting_label.png)
53
+
54
+ ## Folder behavior
55
+
56
+ Given a model path like:
57
+
58
+ `.../my_model/best.pt`
59
+
60
+ The plugin uses `.../my_model` as root.
61
+
62
+ ### Add correction
63
+
64
+ Each click saves:
65
+
66
+ - Image to `my_model/corrections/<image_name>_<timestamp>.png`
67
+ - Labels to `my_model/corrections/<image_name>_<timestamp>.txt`
68
+ - Training config to `my_model/corrections/training_config.json` (created/updated)
69
+
70
+ Image layer behavior:
71
+
72
+ - If no image layer exists, `Add correction` shows an error.
73
+ - If more than one image layer exists, `Add correction` shows an error.
74
+ - If exactly one image layer exists, that image layer is used for saving correction image data.
75
+
76
+ `training_config.json` defaults:
77
+
78
+ - `image_size`: prefilled from the current image size using `max(height, width)`
79
+ - `batch`: `8`
80
+ - `epochs`: `100`
81
+ - `patience`: `30`
82
+
83
+ You can edit this file before clicking `Retrain`.
84
+
85
+ Label format is YOLO detection:
86
+
87
+ `class x_center y_center width height`
88
+
89
+ normalized to `[0, 1]`.
90
+
91
+ ### Retrain
92
+
93
+ Each click creates:
94
+
95
+ - `<retrain_root>/dataset/`
96
+ - `images/train`, `images/val`
97
+ - `labels/train`, `labels/val`
98
+ - `dataset.yaml`
99
+ - Trains YOLO from those corrections
100
+ - Copies best model to:
101
+ - `<retrain_root>/best.pt`
102
+ - Deletes training traces folder after extracting `best.pt`
103
+
104
+ `<retrain_root>` resolution:
105
+
106
+ - If destination field is set, retraining outputs there.
107
+ - Otherwise it defaults to `my_model/retrained_<timestamp>`.
108
+
109
+ So the retrained folder keeps a clean dataset + final model, without run artifacts.
110
+
111
+ Warning: Data labeled will be equally divided between traning and validation (50%).
@@ -0,0 +1,110 @@
1
+ [project]
2
+ name = "simple-napari-cci-annotator"
3
+ dynamic = ["version"]
4
+ description = "Plugin to easly test a yolo model and retrain it"
5
+ readme = "README.md"
6
+ license = {file = "LICENSE"}
7
+ authors = [
8
+ {name = "Simon Leclerc"},
9
+ {email = "simon.leclerc@gu.se"},
10
+ ]
11
+ classifiers = [
12
+ "Development Status :: 2 - Pre-Alpha",
13
+ "Framework :: napari",
14
+ "Intended Audience :: Developers",
15
+ "Operating System :: OS Independent",
16
+ "Programming Language :: Python",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3 :: Only",
19
+ "Programming Language :: Python :: 3.10",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Topic :: Scientific/Engineering :: Image Processing",
23
+ ]
24
+ requires-python = ">=3.9"
25
+ dependencies = [
26
+ "numpy",
27
+ "qtpy",
28
+ "ultralytics",
29
+ "pillow",
30
+ ]
31
+
32
+ [project.optional-dependencies]
33
+ all = ["napari[all]"]
34
+
35
+ testing = [
36
+ "tox",
37
+ "pytest", # https://docs.pytest.org/en/latest/contents.html
38
+ "pytest-cov", # https://pytest-cov.readthedocs.io/en/latest/
39
+ "pytest-qt", # https://pytest-qt.readthedocs.io/en/latest/
40
+ "napari",
41
+ "pyqt5",
42
+ ]
43
+
44
+ [project.entry-points."napari.manifest"]
45
+ simple-napari-cci-annotator = "simple_napari_cci_annotator:napari.yaml"
46
+
47
+ [build-system]
48
+ requires = ["setuptools>=42.0.0", "wheel"]
49
+ build-backend = "setuptools.build_meta"
50
+
51
+ [tool.setuptools]
52
+ include-package-data = true
53
+
54
+ [tool.setuptools.packages.find]
55
+ where = ["src"]
56
+
57
+ [tool.setuptools.package-data]
58
+ "*" = ["*.yaml"]
59
+
60
+ [tool.setuptools.dynamic]
61
+ version = {attr = "simple_napari_cci_annotator.__init__.__version__"}
62
+
63
+ [tool.black]
64
+ line-length = 79
65
+ target-version = ['py310', 'py311', 'py312']
66
+
67
+ [tool.ruff]
68
+ line-length = 79
69
+ lint.select = [
70
+ "E", "F", "W", #flake8
71
+ "UP", # pyupgrade
72
+ "I", # isort
73
+ "BLE", # flake8-blind-exception
74
+ "B", # flake8-bugbear
75
+ "A", # flake8-builtins
76
+ "C4", # flake8-comprehensions
77
+ "ISC", # flake8-implicit-str-concat
78
+ "G", # flake8-logging-format
79
+ "PIE", # flake8-pie
80
+ "SIM", # flake8-simplify
81
+ ]
82
+ lint.ignore = [
83
+ "E501", # line too long. let black handle this
84
+ "SIM117",
85
+ ]
86
+
87
+ exclude = [
88
+ ".bzr",
89
+ ".direnv",
90
+ ".eggs",
91
+ ".git",
92
+ ".mypy_cache",
93
+ ".pants.d",
94
+ ".ruff_cache",
95
+ ".svn",
96
+ ".tox",
97
+ ".venv",
98
+ "__pypackages__",
99
+ "_build",
100
+ "buck-out",
101
+ "build",
102
+ "dist",
103
+ "node_modules",
104
+ "venv",
105
+ "*vendored*",
106
+ "*_vendor*",
107
+ ]
108
+
109
+ target-version = "py312"
110
+ fix = true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,7 @@
1
+ from ._widget import SimpleCciAnnotatorQWidget
2
+
3
+ __version__ = "0.0.2"
4
+
5
+ __all__ = [
6
+ "SimpleCciAnnotatorQWidget",
7
+ ]