descriptron-vision 2.0.1__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 (21) hide show
  1. descriptron_vision-2.0.1/.gitignore +56 -0
  2. descriptron_vision-2.0.1/LICENSE +201 -0
  3. descriptron_vision-2.0.1/NOTICE +52 -0
  4. descriptron_vision-2.0.1/PKG-INFO +68 -0
  5. descriptron_vision-2.0.1/README.md +38 -0
  6. descriptron_vision-2.0.1/pyproject.toml +64 -0
  7. descriptron_vision-2.0.1/src/descriptron_vision/__init__.py +0 -0
  8. descriptron_vision-2.0.1/src/descriptron_vision/cli.py +66 -0
  9. descriptron_vision-2.0.1/src/descriptron_vision/tools/biosyslit_rag_retrieval.py +4285 -0
  10. descriptron_vision-2.0.1/src/descriptron_vision/tools/dinov3_landmark_transfer_v51.py +903 -0
  11. descriptron_vision-2.0.1/src/descriptron_vision/tools/measurement_script_to_try_after_kpts_prediction_measure_kpts_V35.py +2049 -0
  12. descriptron_vision-2.0.1/src/descriptron_vision/tools/sam2_pal_batch_v21.py +3307 -0
  13. descriptron_vision-2.0.1/src/descriptron_vision/tools/torchvision_det/README.md +108 -0
  14. descriptron_vision-2.0.1/src/descriptron_vision/tools/torchvision_det/d2_predict_fold_v1.py +99 -0
  15. descriptron_vision-2.0.1/src/descriptron_vision/tools/torchvision_det/fix_coco_image_sizes_v1.py +95 -0
  16. descriptron_vision-2.0.1/src/descriptron_vision/tools/torchvision_det/render_detections_v1.py +179 -0
  17. descriptron_vision-2.0.1/src/descriptron_vision/tools/torchvision_det/run_20k_comparison.sh +90 -0
  18. descriptron_vision-2.0.1/src/descriptron_vision/tools/torchvision_det/tv_coco_dataset.py +405 -0
  19. descriptron_vision-2.0.1/src/descriptron_vision/tools/torchvision_det/tv_predict_v1.py +253 -0
  20. descriptron_vision-2.0.1/src/descriptron_vision/tools/torchvision_det/tv_sweep_v1.py +331 -0
  21. descriptron_vision-2.0.1/src/descriptron_vision/tools/torchvision_det/tv_train_v1.py +283 -0
@@ -0,0 +1,56 @@
1
+ # This tree holds a 116 GB conda installation, a 10 GB tarball, 12 GB of demo
2
+ # imagery and years of run outputs. Exclude everything, then re-include the code.
3
+ *
4
+
5
+ !.gitignore
6
+ !README.md
7
+ !LICENSE
8
+ !CITATION.cff
9
+ !docs/
10
+ !docs/**
11
+ !docker/
12
+ !docker/**
13
+ !environments/
14
+ !environments/**
15
+ !packages/
16
+ !packages/**
17
+
18
+ # the Descriptron programs themselves
19
+ !segment-anything-2/
20
+ segment-anything-2/*
21
+ !segment-anything-2/gui/
22
+ segment-anything-2/gui/*
23
+ !segment-anything-2/gui/*.py
24
+ !segment-anything-2/gui/*.sh
25
+ !segment-anything-2/gui/measure/
26
+ segment-anything-2/gui/measure/*
27
+ !segment-anything-2/gui/measure/*.py
28
+ !segment-anything-2/gui/measure/*.sh
29
+ !segment-anything-2/gui/measure/biorag_prompts/
30
+ !segment-anything-2/gui/measure/biorag_prompts/**
31
+ !segment-anything-2/gui/measure/tests/
32
+ !segment-anything-2/gui/measure/tests/*.py
33
+ !segment-anything-2/gui/torchvision_det/
34
+ !segment-anything-2/gui/torchvision_det/**
35
+ !segment-anything-2/gui/detectron2/
36
+ segment-anything-2/gui/detectron2/*
37
+ !segment-anything-2/gui/detectron2/*.py
38
+ !segment-anything-2/gui/icons/
39
+ !segment-anything-2/gui/icons/**
40
+ !segment-anything-2/gui/marmot.jpg
41
+
42
+ # never, whatever the rules above say
43
+ **/__pycache__/
44
+ **/*.pyc
45
+ **/*.bak*
46
+ **/.ipynb_checkpoints/
47
+ **/*.pth
48
+ **/*.pt
49
+ **/*.ckpt
50
+ **/*.onnx
51
+ **/*.log
52
+ **/dist/
53
+ **/build/
54
+ **/*.egg-info/
55
+ packages/*/src/*/tools/
56
+ packages/*/src/*/data/
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,52 @@
1
+ Descriptron
2
+ Copyright 2024-2026 Alex R. Van Dam (ORCID 0000-0002-1966-0338)
3
+
4
+ This product includes software developed by Alex R. Van Dam
5
+ https://github.com/alexrvandam/Descriptron
6
+
7
+ Licensed under the Apache License, Version 2.0 (see LICENSE). Under Section
8
+ 4(d) of that licence, this NOTICE file must be included with any
9
+ redistribution of this software or of any work derived from it.
10
+
11
+ REQUIRED CITATION
12
+ -----------------
13
+ Anyone who uses Descriptron, or any software derived from it (including
14
+ descriptron-core, descriptron-vision, descriptron-gui and descriptron-mcp), in
15
+ work that is published, presented or distributed must cite:
16
+
17
+ 1. The software (Descriptron v2):
18
+ Van Dam, A. R. Descriptron (version used). GitHub repository.
19
+ https://github.com/alexrvandam/Descriptron
20
+
21
+ 2. The first Descriptron paper:
22
+ Van Dam, A. R. & Štarhová Serbina, L. (2026). Descriptron: Artificial
23
+ intelligence for automating taxonomic species descriptions with a
24
+ user-friendly software package. Systematic Entomology, 51(1), e70005.
25
+ https://doi.org/10.1111/syen.70005
26
+
27
+ 3. Once it is published, the Descriptron v2 paper as well. Its reference
28
+ will be added here and in CITATION.cff on publication.
29
+
30
+ BibTeX:
31
+
32
+ @misc{vandam_descriptron_software,
33
+ author = {Van Dam, Alex R.},
34
+ title = {Descriptron},
35
+ howpublished = {GitHub repository},
36
+ url = {https://github.com/alexrvandam/Descriptron}
37
+ }
38
+
39
+ @article{vandam2026descriptron,
40
+ author = {Van Dam, Alex R. and Štarhová Serbina, Liliya},
41
+ title = {Descriptron: Artificial intelligence for automating taxonomic species
42
+ descriptions with a user-friendly software package},
43
+ journal = {Systematic Entomology},
44
+ volume = {51},
45
+ number = {1},
46
+ pages = {e70005},
47
+ year = {2026},
48
+ doi = {10.1111/syen.70005}
49
+ }
50
+
51
+ The same information is in CITATION.cff, which GitHub shows as
52
+ "Cite this repository".
@@ -0,0 +1,68 @@
1
+ Metadata-Version: 2.5
2
+ Name: descriptron-vision
3
+ Version: 2.0.1
4
+ Summary: Mask and landmark prediction for Descriptron: torchvision detectors, SAM2-PAL propagation, DINOv3 landmark transfer
5
+ Project-URL: Homepage, https://github.com/alexrvandam/Descriptron
6
+ Author: Alex R. Van Dam
7
+ License: Apache-2.0
8
+ License-File: LICENSE
9
+ License-File: NOTICE
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Topic :: Scientific/Engineering :: Image Recognition
15
+ Requires-Python: >=3.9
16
+ Requires-Dist: descriptron-core==2.0.1
17
+ Requires-Dist: einops>=0.7
18
+ Requires-Dist: timm>=0.9
19
+ Requires-Dist: torch>=2.3
20
+ Requires-Dist: torchvision>=0.18
21
+ Requires-Dist: tqdm>=4.65
22
+ Requires-Dist: transformers>=4.38
23
+ Provides-Extra: dev
24
+ Requires-Dist: build>=1; extra == 'dev'
25
+ Requires-Dist: pytest>=7; extra == 'dev'
26
+ Requires-Dist: twine>=5; extra == 'dev'
27
+ Provides-Extra: ocr
28
+ Requires-Dist: easyocr>=1.7; extra == 'ocr'
29
+ Description-Content-Type: text/markdown
30
+
31
+ # descriptron-vision
32
+
33
+ Mask and landmark prediction for [Descriptron](https://github.com/alexrvandam/Descriptron):
34
+ torchvision detectors, SAM2-PAL propagation and DINOv3 landmark transfer.
35
+
36
+ ```bash
37
+ pip install descriptron-vision
38
+ descriptron-train --task masks --coco-json annotations.json --img-dir images/ \
39
+ --output-dir out/ --total-iters 20000
40
+ descriptron-predict --checkpoint out/model_final_*.pth --coco-json annotations.json \
41
+ --img-dir images/ --annotations_out predictions.json
42
+ ```
43
+
44
+ **No compiler required.** torch and torchvision are ordinary wheels on Linux,
45
+ macOS and Windows. For CUDA, install torch from PyTorch's own index first:
46
+
47
+ ```bash
48
+ pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121
49
+ pip install descriptron-vision
50
+ ```
51
+
52
+ On a Mac the detectors can use the Apple GPU through PyTorch's MPS device, which
53
+ is why this backend exists: Detectron2 has no macOS wheels and no Apple Silicon
54
+ support.
55
+
56
+ ## Two optional dependencies that cannot be declared
57
+
58
+ PyPI rejects a git dependency in package metadata, so neither **SAM2** nor
59
+ **Detectron2** is listed. Both are imported lazily, and the error names the
60
+ command to install them. The Docker image carries both ready to run.
61
+
62
+ ## Choosing a backbone
63
+
64
+ `--arch v1` (default) is `maskrcnn_resnet50_fpn`; `--arch v2` is
65
+ `maskrcnn_resnet50_fpn_v2`. v2 scores higher on COCO, but on a few hundred
66
+ training images v1 won on 3 of 3 folds of a grouped species hold-out — its
67
+ lighter two-FC box head converges further in the same budget. Measured on the
68
+ data, not assumed from the model zoo.
@@ -0,0 +1,38 @@
1
+ # descriptron-vision
2
+
3
+ Mask and landmark prediction for [Descriptron](https://github.com/alexrvandam/Descriptron):
4
+ torchvision detectors, SAM2-PAL propagation and DINOv3 landmark transfer.
5
+
6
+ ```bash
7
+ pip install descriptron-vision
8
+ descriptron-train --task masks --coco-json annotations.json --img-dir images/ \
9
+ --output-dir out/ --total-iters 20000
10
+ descriptron-predict --checkpoint out/model_final_*.pth --coco-json annotations.json \
11
+ --img-dir images/ --annotations_out predictions.json
12
+ ```
13
+
14
+ **No compiler required.** torch and torchvision are ordinary wheels on Linux,
15
+ macOS and Windows. For CUDA, install torch from PyTorch's own index first:
16
+
17
+ ```bash
18
+ pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121
19
+ pip install descriptron-vision
20
+ ```
21
+
22
+ On a Mac the detectors can use the Apple GPU through PyTorch's MPS device, which
23
+ is why this backend exists: Detectron2 has no macOS wheels and no Apple Silicon
24
+ support.
25
+
26
+ ## Two optional dependencies that cannot be declared
27
+
28
+ PyPI rejects a git dependency in package metadata, so neither **SAM2** nor
29
+ **Detectron2** is listed. Both are imported lazily, and the error names the
30
+ command to install them. The Docker image carries both ready to run.
31
+
32
+ ## Choosing a backbone
33
+
34
+ `--arch v1` (default) is `maskrcnn_resnet50_fpn`; `--arch v2` is
35
+ `maskrcnn_resnet50_fpn_v2`. v2 scores higher on COCO, but on a few hundred
36
+ training images v1 won on 3 of 3 folds of a grouped species hold-out — its
37
+ lighter two-FC box head converges further in the same budget. Measured on the
38
+ data, not assumed from the model zoo.
@@ -0,0 +1,64 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "descriptron-vision"
7
+ version = "2.0.1"
8
+ description = "Mask and landmark prediction for Descriptron: torchvision detectors, SAM2-PAL propagation, DINOv3 landmark transfer"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = { text = "Apache-2.0" }
12
+ authors = [{ name = "Alex R. Van Dam" }]
13
+ classifiers = [
14
+ "Programming Language :: Python :: 3",
15
+ "Topic :: Scientific/Engineering :: Image Recognition",
16
+ "Intended Audience :: Science/Research",
17
+ "License :: OSI Approved :: Apache Software License",
18
+ "Operating System :: OS Independent",
19
+ ]
20
+
21
+ # torch and torchvision are ordinary wheels on Linux, macOS and Windows, so this
22
+ # installs without a compiler. On a Mac the torchvision detectors can use the
23
+ # Apple GPU through PyTorch's MPS device; Detectron2 cannot, which is why the
24
+ # torchvision backend exists.
25
+ #
26
+ # For CUDA, install torch from PyTorch's own index FIRST, then this package:
27
+ # pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121
28
+ dependencies = [
29
+ "descriptron-core==2.0.1",
30
+ # Capped deliberately. Unbounded, pip installs torch 2.14 with ~3 GB of CUDA 13
31
+ # wheels — not the torch 2.4.0+cu121 this system was validated on, and a version
32
+ # in which the AMP calls below are already deprecated. Raise the cap only after
33
+ # testing, not before.
34
+ "torch>=2.3", # torch.amp.GradScaler("cuda") in tv_train_v1 needs 2.3
35
+ "torchvision>=0.18",
36
+ "transformers>=4.38", # Florence-2 scale-bar reading
37
+ "timm>=0.9",
38
+ "einops>=0.7",
39
+ "tqdm>=4.65",
40
+ ]
41
+
42
+ [project.optional-dependencies]
43
+ # SAM2 is not on PyPI and PyPI rejects a git dependency in package metadata, so
44
+ # it cannot be declared here. It is imported lazily and the error message gives
45
+ # the install command:
46
+ # pip install git+https://github.com/facebookresearch/segment-anything-2
47
+ # Detectron2 is the same story, and additionally needs a compiler; see the
48
+ # Docker image if you would rather not build it.
49
+ ocr = ["easyocr>=1.7"]
50
+ dev = ["pytest>=7", "build>=1", "twine>=5"]
51
+
52
+ [project.scripts]
53
+ descriptron-train = "descriptron_vision.cli:train"
54
+ descriptron-predict = "descriptron_vision.cli:predict"
55
+ descriptron-sweep = "descriptron_vision.cli:sweep"
56
+ descriptron-sam2pal = "descriptron_vision.cli:sam2_pal"
57
+ descriptron-dinoland = "descriptron_vision.cli:dinoland"
58
+ descriptron-measure = "descriptron_vision.cli:measure"
59
+
60
+ [project.urls]
61
+ Homepage = "https://github.com/alexrvandam/Descriptron"
62
+
63
+ [tool.hatch.build.targets.wheel]
64
+ packages = ["src/descriptron_vision"]
@@ -0,0 +1,66 @@
1
+ """
2
+ descriptron_vision.cli — detectors, propagation and landmark transfer
3
+ =====================================================================
4
+
5
+ Same dispatch as `descriptron_core.cli`. The two dependencies that are not on
6
+ PyPI — SAM2 and Detectron2 — are not declared anywhere: PyPI rejects a git
7
+ dependency in package metadata. They are imported lazily by the programs that
8
+ need them, and `require()` below turns the resulting ImportError into the exact
9
+ command to run.
10
+ """
11
+ from __future__ import annotations
12
+
13
+ import sys
14
+
15
+ from descriptron_core.cli import run as _run_core # noqa: F401 (shared behaviour)
16
+ from descriptron_core.cli import data_path # noqa: F401
17
+
18
+ import os
19
+ import runpy
20
+ from importlib.resources import files
21
+ from pathlib import Path
22
+
23
+ INSTALL_HINTS = {
24
+ "sam2": ("SAM2 is not on PyPI, so it cannot be a declared dependency.\n"
25
+ " pip install git+https://github.com/facebookresearch/segment-anything-2"),
26
+ "detectron2": ("Detectron2 is not on PyPI and must be compiled:\n"
27
+ " pip install git+https://github.com/facebookresearch/detectron2\n"
28
+ "It needs a C++/CUDA toolchain and has no macOS wheels. If you would\n"
29
+ "rather not build it, the Docker image carries it ready to run, and the\n"
30
+ "torchvision backend needs none of this."),
31
+ }
32
+
33
+
34
+ def require(module: str):
35
+ """Import an optional heavyweight dependency, or explain how to get it."""
36
+ try:
37
+ return __import__(module)
38
+ except ImportError as exc:
39
+ hint = INSTALL_HINTS.get(module, f" pip install {module}")
40
+ raise SystemExit(f"{module} is required for this step but is not installed.\n"
41
+ f"{hint}\n\n(original error: {exc})") from exc
42
+
43
+
44
+ def tools_dir() -> Path:
45
+ return Path(str(files("descriptron_vision") / "tools"))
46
+
47
+
48
+ def _run(script: str, argv: list[str], subdir: str | None = None) -> None:
49
+ base = tools_dir() / subdir if subdir else tools_dir()
50
+ path = base / script
51
+ if not path.exists():
52
+ raise SystemExit(f"{path} is missing — was sync_sources.py run before building?")
53
+ sys.path.insert(0, str(path.parent))
54
+ sys.path.insert(0, str(tools_dir()))
55
+ os.environ.setdefault("DESCRIPTRON_DATA", str(data_path()))
56
+ sys.argv = [str(path), *argv]
57
+ runpy.run_path(str(path), run_name="__main__")
58
+
59
+
60
+ def train(): _run("tv_train_v1.py", sys.argv[1:], "torchvision_det")
61
+ def predict(): _run("tv_predict_v1.py", sys.argv[1:], "torchvision_det")
62
+ def sweep(): _run("tv_sweep_v1.py", sys.argv[1:], "torchvision_det")
63
+ def sam2_pal(): _run("sam2_pal_batch_v21.py", sys.argv[1:])
64
+ def dinoland(): _run("dinov3_landmark_transfer_v51.py", sys.argv[1:])
65
+ def measure():
66
+ _run("measurement_script_to_try_after_kpts_prediction_measure_kpts_V35.py", sys.argv[1:])