bd commited on
Commit
f6d09c1
·
0 Parent(s):
Files changed (19) hide show
  1. .gitattributes +2 -0
  2. .gitignore +17 -0
  3. .python-version +1 -0
  4. LICENSE +21 -0
  5. LICENSE-APACHE-2.0.txt +202 -0
  6. LICENSE-DINOv3.md +66 -0
  7. NOTICE.md +47 -0
  8. README.md +166 -0
  9. assets/demo.webp +3 -0
  10. data.py +648 -0
  11. models.py +64 -0
  12. predict_onnx.py +96 -0
  13. pyproject.toml +30 -0
  14. targets.py +33 -0
  15. test_training.py +610 -0
  16. train.py +1108 -0
  17. uv.lock +659 -0
  18. weights/grid16.onnx +3 -0
  19. weights/grid9.onnx +3 -0
.gitattributes ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ *.onnx filter=lfs diff=lfs merge=lfs -text
2
+ *.webp filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .DS_Store
2
+ .venv/
3
+ __pycache__/
4
+ dataset1/
5
+ dataset2/
6
+ dataset3/
7
+ dataset4/
8
+ runs/
9
+ .cache/
10
+ *.pt
11
+ data/
12
+ .idea/
13
+ .ruff_cache/
14
+ .env
15
+ .env.*
16
+ !.env.example
17
+ :memory:.ses
.python-version ADDED
@@ -0,0 +1 @@
 
 
1
+ 3.11
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2026 RC1 contributors
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.
LICENSE-APACHE-2.0.txt ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
LICENSE-DINOv3.md ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # DINOv3 License
2
+
3
+ *Last Updated: August 19, 2025*
4
+
5
+ **“Agreement”** means the terms and conditions for use, reproduction, distribution and modification of the DINO Materials set forth herein.
6
+
7
+ **“DINO Materials”** means, collectively, Documentation and the models, software and algorithms, including machine-learning model code, trained model weights, inference-enabling code, training-enabling code, fine-tuning enabling code, and other elements of the foregoing distributed by Meta and made available under this Agreement.
8
+
9
+ **“Documentation”** means the specifications, manuals and documentation accompanying
10
+ DINO Materials distributed by Meta.
11
+
12
+ **“Licensee”** or **“you”** means you, or your employer or any other person or entity (if you are entering into this Agreement on such person or entity’s behalf), of the age required under applicable laws, rules or regulations to provide legal consent and that has legal authority to bind your employer or such other person or entity if you are entering in this Agreement on their behalf.
13
+
14
+ **“Meta”** or **“we”** means Meta Platforms Ireland Limited (if you are located in or, if you are an entity, your principal place of business is in the EEA or Switzerland) or Meta Platforms, Inc. (if you are located outside of the EEA or Switzerland).
15
+
16
+ **“Sanctions”** means any economic or trade sanctions or restrictions administered or enforced by the United States (including the Office of Foreign Assets Control of the U.S. Department of the Treasury (“OFAC”), the U.S. Department of State and the U.S. Department of Commerce), the United Nations, the European Union, or the United Kingdom.
17
+
18
+ **“Trade Controls”** means any of the following: Sanctions and applicable export and import controls.
19
+
20
+ By clicking “I Accept” below or by using or distributing any portion or element of the DINO Materials, you agree to be bound by this Agreement.
21
+
22
+ ## 1. License Rights and Redistribution.
23
+
24
+ a. <ins>Grant of Rights</ins>. You are granted a non-exclusive, worldwide, non-transferable and royalty-free limited license under Meta’s intellectual property or other rights owned by Meta embodied in the DINO Materials to use, reproduce, distribute, copy, create derivative works of, and make modifications to the DINO Materials.
25
+
26
+ b. <ins>Redistribution and Use</ins>.
27
+
28
+ i. Distribution of DINO Materials, and any derivative works thereof, are subject to the terms of this Agreement. If you distribute or make the DINO Materials, or any derivative works thereof, available to a third party, you may only do so under the terms of this Agreement and you shall provide a copy of this Agreement with any such DINO Materials.
29
+
30
+ ii. If you submit for publication the results of research you perform on, using, or otherwise in connection with DINO Materials, you must acknowledge the use of DINO Materials in your publication.
31
+
32
+ iii. Your use of the DINO Materials must comply with applicable laws and regulations, including Trade Control Laws and applicable privacy and data protection laws.
33
+
34
+ iv. Your use of the DINO Materials will not involve or encourage others to reverse engineer, decompile or discover the underlying components of the DINO Materials.
35
+
36
+ v. You are not the target of Trade Controls and your use of DINO Materials must comply with Trade Controls. You agree not to use, or permit others to use, DINO Materials for any activities subject to the International Traffic in Arms Regulations (ITAR) or end uses prohibited by Trade Controls, including those related to military or warfare purposes, nuclear industries or applications, espionage, or the development or use of guns or illegal weapons.
37
+
38
+ ## 2. User Support.
39
+
40
+ Your use of the DINO Materials is done at your own discretion; Meta does not process any information nor provide any service in relation to such use. Meta is under no obligation to provide any support services for the DINO Materials. Any support provided is “as is”, “with all faults”, and without warranty of any kind.
41
+
42
+ ## 3. Disclaimer of Warranty.
43
+
44
+ UNLESS REQUIRED BY APPLICABLE LAW, THE DINO MATERIALS AND ANY OUTPUT AND RESULTS THEREFROM ARE PROVIDED ON AN “AS IS” BASIS, WITHOUT WARRANTIES OF ANY KIND, AND META DISCLAIMS ALL WARRANTIES OF ANY KIND, BOTH EXPRESS AND IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. YOU ARE SOLELY RESPONSIBLE FOR DETERMINING THE APPROPRIATENESS OF USING OR REDISTRIBUTING THE DINO MATERIALS AND ASSUME ANY RISKS ASSOCIATED WITH YOUR USE OF THE DINO MATERIALS AND ANY OUTPUT AND RESULTS.
45
+
46
+ ## 4. Limitation of Liability.
47
+
48
+ IN NO EVENT WILL META OR ITS AFFILIATES BE LIABLE UNDER ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, TORT, NEGLIGENCE, PRODUCTS LIABILITY, OR OTHERWISE, ARISING OUT OF THIS AGREEMENT, FOR ANY LOST PROFITS OR ANY DIRECT OR INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL, EXEMPLARY OR PUNITIVE DAMAGES, EVEN IF META OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF ANY OF THE FOREGOING.
49
+
50
+ ## 5. Intellectual Property.
51
+
52
+ a. Subject to Meta’s ownership of DINO Materials and derivatives made by or for Meta, with respect to any derivative works and modifications of the DINO Materials that are made by you, as between you and Meta, you are and will be the owner of such derivative works and modifications.
53
+
54
+ b. If you institute litigation or other proceedings against Meta or any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the DINO Materials, outputs or results, or any portion of any of the foregoing, constitutes infringement of intellectual property or other rights owned or licensable by you, then any licenses granted to you under this Agreement shall terminate as of the date such litigation or claim is filed or instituted. You will indemnify and hold harmless Meta from and against any claim by any third party arising out of or related to your use or distribution of the DINO Materials.
55
+
56
+ ## 6. Term and Termination.
57
+
58
+ The term of this Agreement will commence upon your acceptance of this Agreement or access to the DINO Materials and will continue in full force and effect until terminated in accordance with the terms and conditions herein. Meta may terminate this Agreement if you are in breach of any term or condition of this Agreement. Upon termination of this Agreement, you shall delete and cease use of the DINO Materials. Sections 3, 4 and 7 shall survive the termination of this Agreement.
59
+
60
+ ## 7. Governing Law and Jurisdiction.
61
+
62
+ This Agreement will be governed and construed under the laws of the State of California without regard to choice of law principles, and the UN Convention on Contracts for the International Sale of Goods does not apply to this Agreement. The courts of California shall have exclusive jurisdiction of any dispute arising out of this Agreement.
63
+
64
+ ## 8. Modifications and Amendments.
65
+
66
+ Meta may modify this Agreement from time to time; provided that they are similar in spirit to the current version of the Agreement, but may differ in detail to address new problems or concerns. All such changes will be effective immediately. Your continued use of the DINO Materials after any modification to this Agreement constitutes your agreement to such modification. Except as provided in this Agreement, no modification or addition to any provision of this Agreement will be binding unless it is in writing and signed by an authorized representative of both you and Meta.
NOTICE.md ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Licenses and notices
2
+
3
+ RC1 contains files under three different licenses. Check which one applies to
4
+ the file you use.
5
+
6
+ | Files | License | License text |
7
+ | --- | --- | --- |
8
+ | Source code (`*.py`), documentation and other repository files, except those listed below | MIT | [LICENSE](LICENSE) |
9
+ | `weights/grid9.onnx` | MIT for RC1's fine-tuning, plus Apache-2.0 for the pretrained backbone it was fine-tuned from | [LICENSE](LICENSE), [LICENSE-APACHE-2.0.txt](LICENSE-APACHE-2.0.txt) |
10
+ | `weights/grid16.onnx` | DINOv3 License | [LICENSE-DINOv3.md](LICENSE-DINOv3.md) |
11
+ | Third-party imagery in `assets/demo.webp` | Excluded from RC1’s license grants | — |
12
+
13
+ ## `weights/grid16.onnx`: built with DINOv3
14
+
15
+ `weights/grid16.onnx` is a fine-tuned derivative of
16
+ [`timm/convnext_tiny.dinov3_lvd1689m`](https://huggingface.co/timm/convnext_tiny.dinov3_lvd1689m),
17
+ which is a DINOv3 model released by Meta. Under the DINOv3 License, it is
18
+ distributed **only under the terms of the DINOv3 License**, not the MIT
19
+ License. A copy of that license is in [LICENSE-DINOv3.md](LICENSE-DINOv3.md).
20
+
21
+ If you use or redistribute `grid16.onnx`, the DINOv3 License applies to you.
22
+ Among other terms, it requires that you:
23
+
24
+ - Include a copy of the DINOv3 License with anything you distribute.
25
+ - Acknowledge the use of DINOv3 in any research publications.
26
+ - Comply with applicable laws, including trade controls, and not use it for
27
+ the prohibited end uses listed in the license.
28
+
29
+ The bullets above are a summary; the license text is what governs.
30
+
31
+ DINOv3 is licensed under the DINOv3 License, Copyright © Meta Platforms, Inc.
32
+ All Rights Reserved.
33
+
34
+ ## `weights/grid9.onnx`: MobileNetV4 backbone
35
+
36
+ `weights/grid9.onnx` is fine-tuned from
37
+ [`timm/mobilenetv4_conv_medium.e250_r384_in12k_ft_in1k`](https://huggingface.co/timm/mobilenetv4_conv_medium.e250_r384_in12k_ft_in1k),
38
+ a MobileNetV4 checkpoint trained and published by the
39
+ [timm](https://github.com/huggingface/pytorch-image-models) project under the
40
+ Apache License 2.0. A copy of that license is in
41
+ [LICENSE-APACHE-2.0.txt](LICENSE-APACHE-2.0.txt). RC1 modified the weights by
42
+ fine-tuning them for reCAPTCHA v2 grid cells and replacing the classifier head.
43
+
44
+ ## Training data
45
+
46
+ None of these licenses cover the source images in the training dataset,
47
+ [recaptcha-67k](https://huggingface.co/datasets/bxding/recaptcha-67k).
README.md ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: mit-apache-2.0-dinov3
4
+ license_link: https://huggingface.co/bxding/RC1/blob/main/NOTICE.md
5
+ library_name: onnx
6
+ pipeline_tag: image-classification
7
+ base_model:
8
+ - timm/mobilenetv4_conv_medium.e250_r384_in12k_ft_in1k
9
+ - timm/convnext_tiny.dinov3_lvd1689m
10
+ datasets:
11
+ - bxding/recaptcha-67k
12
+ tags:
13
+ - computer-vision
14
+ - image-classification
15
+ - onnx
16
+ ---
17
+
18
+ # recaptcha-classifier (RC1)
19
+
20
+ RC1 is a pair of small, fast image recognition models that select the matching
21
+ cells in reCAPTCHA v2 image grids. The 3×3 model classifies each of the nine
22
+ cells separately, while the 4×4 model processes the whole grid at once. Both
23
+ run locally on a CPU with ONNX Runtime. On my $2 VPS, the 3×3 model processes
24
+ about **9 grids per second** using two CPU threads.
25
+
26
+ ![Example predictions](assets/demo.webp)
27
+
28
+ *Inference in this demo ran on my $2 VPS. The left window shows a 4×4 grid and
29
+ the right window shows a 3×3 grid.*
30
+
31
+ ## Models
32
+
33
+ | Model | Backbone | Input | Supported targets |
34
+ | --- | --- | --- | --- |
35
+ | `grid9.onnx` | MobileNetV4 (`mobilenetv4_conv_medium.e250_r384_in12k_ft_in1k`) | Nine cells from a 3×3 grid, each resized to 224×224 | bicycle, bus, car, crosswalk, fire hydrant, motorcycle\*, parking meter\*, stairs\*, traffic light\* |
36
+ | `grid16.onnx` | ConvNeXt Tiny (`convnext_tiny.dinov3_lvd1689m`) | One 4×4 grid image, resized to 448×448 | bicycle, bus, chimney\*, crosswalk, fire hydrant, motorcycle, parking meter\*, stairs, taxi\*, tractor, traffic light |
37
+
38
+ `grid16.onnx` is built with DINOv3 and is distributed under the
39
+ [DINOv3 License](LICENSE-DINOv3.md), not the MIT License. See [License](#license).
40
+
41
+ \* These targets are rare. Across all splits, the 3×3 dataset has 14 grids
42
+ for motorcycle, 7 for traffic light, 2 for parking meter, and 1 for stairs.
43
+ The 4×4 dataset has 7 grids for parking meter, 13 for chimney, and 108 for taxi.
44
+
45
+ Each model outputs a probability for every cell. The inference script selects
46
+ the cells at or above one tuned threshold per model: 0.475 for `grid9.onnx`
47
+ and 0.45 for `grid16.onnx`. The threshold is stored in the model file.
48
+
49
+ ## Evaluation
50
+
51
+ Accuracy of the released ONNX models on
52
+ [recaptcha-67k](https://huggingface.co/datasets/bxding/recaptcha-67k).
53
+ *Exact* means every cell prediction matched the reference label.
54
+
55
+ | Model | Split | Grids | Exact | Cell precision | Cell recall | Cell F1 |
56
+ | --- | --- | ---: | ---: | ---: | ---: | ---: |
57
+ | `grid9.onnx` | `review` | 300 | 81.0% | 0.978 | 0.948 | 0.963 |
58
+ | `grid9.onnx` | `test` (random 600) | 600 | 82.5% | 0.976 | 0.958 | 0.967 |
59
+ | `grid16.onnx` | `review` | 282 | 63.5% | 0.915 | 0.939 | 0.927 |
60
+ | `grid16.onnx` | `test` (random 600) | 600 | 65.7% | 0.944 | 0.948 | 0.946 |
61
+
62
+ These numbers measure agreement with model-generated labels, not live
63
+ challenge pass rates:
64
+
65
+ - The `test` labels come from the same labelers RC1 was trained on: Qwen for
66
+ 3×3 and SAM 3 for 4×4.
67
+ - The `review` labels were checked by Claude Opus 5.5, not by humans.
68
+ - The original machine labels exactly matched Claude’s review on 81.3% of
69
+ 3×3 grids and 70.6% of 4×4 grids.
70
+
71
+ Among 4×4 targets with at least 10 reviewed grids, exact agreement was lowest
72
+ for stairs (10/18), traffic lights (29/48), and motorcycles (52/86).
73
+
74
+ ## Running inference
75
+
76
+ Requires Python 3.11 or newer. From this directory, install the dependencies
77
+ and run the prediction script:
78
+
79
+ ```sh
80
+ python -m pip install onnxruntime numpy pillow
81
+ python predict_onnx.py --model weights/grid16.onnx --image challenge.jpg --target buses
82
+ ```
83
+
84
+ Use `weights/grid9.onnx` for 3×3 grids and `weights/grid16.onnx` for 4×4 grids.
85
+
86
+ The script prints JSON with a probability for each cell and a `selected_cells`
87
+ list. Cells are numbered from 0, left to right and then top to bottom.
88
+
89
+ To limit the number of CPU threads, pass `--threads`. For all options, run
90
+ `python predict_onnx.py --help`.
91
+
92
+ ## Benchmarks
93
+
94
+ Approximate CPU throughput once the model is loaded. Times include image
95
+ loading and preprocessing.
96
+
97
+ | Machine | CPU threads | 3×3 grids/sec | 4×4 grids/sec |
98
+ | --- | ---: | ---: | ---: |
99
+ | Apple M2 Pro | 4 | ~10 | ~7 |
100
+ | $2 VPS | 2 | ~9 | ~4 |
101
+
102
+ ## Training and export
103
+
104
+ Training requires Python 3.11, [uv](https://docs.astral.sh/uv/), and a local
105
+ copy of the recaptcha-67k dataset. From this directory:
106
+
107
+ ```sh
108
+ # Install dependencies
109
+ uv sync --locked
110
+
111
+ # Prepare the dataset
112
+ uv run python train.py prepare --data /path/to/recaptcha-67k --output runs/rc
113
+
114
+ # Train the 3×3 and 4×4 models
115
+ uv run python train.py train --manifest runs/rc/split.json --output runs/rc --tiles 9
116
+ uv run python train.py train --manifest runs/rc/split.json --output runs/rc --tiles 16 --backbone convnext_tiny.dinov3_lvd1689m
117
+
118
+ # Export to ONNX
119
+ uv run --group export python train.py export --checkpoint runs/rc/grid9/best.pt
120
+
121
+ # Run tests
122
+ uv run --group export python -m unittest test_training
123
+ ```
124
+
125
+ Notes:
126
+
127
+ - Training uses a GPU if one is available. On CUDA, add `--amp` to reduce
128
+ memory usage.
129
+ - The `prepare` step keeps the dataset's existing splits and leaves out the
130
+ `excluded` split.
131
+ - All training outputs are written locally to `runs/`.
132
+ - For dataset and training options, run `python train.py --help` or add
133
+ `--help` to any subcommand.
134
+
135
+ ## Roadmap
136
+
137
+ - Improve 4×4 accuracy, which trails both the 3×3 model and the SAM 3 labels
138
+ it was trained on.
139
+ - Improve chimney and parking meter recognition with more training data.
140
+ - Add training data and model support for bridges.
141
+
142
+ ## Disclaimer
143
+
144
+ RC1 was created for educational and research purposes. It is not affiliated
145
+ with or endorsed by Google or reCAPTCHA. Users are responsible for complying
146
+ with all applicable laws and terms of service.
147
+
148
+ ## License
149
+
150
+ RC1's files are under three licenses. [NOTICE.md](NOTICE.md) has the details.
151
+
152
+ | Files | License |
153
+ | --- | --- |
154
+ | Source code and documentation | [MIT](LICENSE) |
155
+ | `weights/grid9.onnx` | [MIT](LICENSE), plus [Apache-2.0](LICENSE-APACHE-2.0.txt) for its pretrained [MobileNetV4 backbone](https://huggingface.co/timm/mobilenetv4_conv_medium.e250_r384_in12k_ft_in1k) |
156
+ | `weights/grid16.onnx` | [DINOv3 License](LICENSE-DINOv3.md) only |
157
+
158
+ `grid16.onnx` is fine-tuned from Meta's
159
+ [DINOv3 ConvNeXt Tiny](https://huggingface.co/timm/convnext_tiny.dinov3_lvd1689m)
160
+ (built with DINOv3). The DINOv3 License requires derivatives to be distributed
161
+ under its own terms, so the MIT License does not apply to this file. Anyone who
162
+ uses or redistributes it must follow the DINOv3 License, including its trade
163
+ control and use restrictions.
164
+
165
+ Third-party imagery in the training dataset and demo is outside the scope of
166
+ these licenses.
assets/demo.webp ADDED

Git LFS Details

  • SHA256: ee9bc21b121b990703929989e14eb105374a0cfe08190265db91848e751f2c6f
  • Pointer size: 132 Bytes
  • Size of remote file: 6.84 MB
data.py ADDED
@@ -0,0 +1,648 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Validate examples, group duplicates, and load target-specific labels."""
2
+
3
+ import hashlib
4
+ import json
5
+ import os
6
+ import random
7
+ import re
8
+ from collections import Counter, defaultdict
9
+ from functools import partial
10
+ from multiprocessing import Pool
11
+ from pathlib import Path
12
+
13
+ import torch
14
+ from PIL import Image
15
+ from torch.utils.data import Dataset
16
+ from torchvision import transforms as T
17
+
18
+ from targets import ALIASES, BACKGROUND, target_name # noqa: F401 (re-exported)
19
+
20
+
21
+ def read_rgb(path):
22
+ with Image.open(path) as image:
23
+ return image.convert("RGB")
24
+
25
+
26
+ def pixel_hash(path):
27
+ image = read_rgb(path)
28
+ return hashlib.sha256(str(image.size).encode() + image.tobytes()).hexdigest()
29
+
30
+
31
+ def average_hash(path):
32
+ """Survives rescaling and pixel noise, so noisy copies of a tile group together."""
33
+ with Image.open(path) as image:
34
+ return _average_hash(image)
35
+
36
+
37
+ def _average_hash(image):
38
+ pixels = image.convert("L").resize((8, 8), Image.Resampling.BOX).tobytes()
39
+ mean = sum(pixels) / 64
40
+ return "a" + format(int("".join("1" if v > mean else "0" for v in pixels), 2), "016x")
41
+
42
+
43
+ GRID_SIZES = {"3x3": 9, "4x4": 16}
44
+ IMAGE_NAMES = ("image.jpg", "image.jpeg", "image.png", "image.webp")
45
+
46
+
47
+ def grid_boxes(width, height, tiles):
48
+ """Cell boxes, left to right then top to bottom, with edges rounded like the labeling tools."""
49
+ n = int(tiles**0.5)
50
+ xs = [round(width * i / n) for i in range(n + 1)]
51
+ ys = [round(height * i / n) for i in range(n + 1)]
52
+ return [(xs[c], ys[r], xs[c + 1], ys[r + 1]) for r in range(n) for c in range(n)]
53
+
54
+
55
+ def image_hash(image):
56
+ return hashlib.sha256(str(image.size).encode() + image.tobytes()).hexdigest()
57
+
58
+
59
+ def record_image_path(root, record):
60
+ """Locate a full image from either a published dataset or a legacy manifest."""
61
+ if "image_path" in record:
62
+ return Path(root) / record["image_path"]
63
+ return Path(root) / record["id"] / record.get("image", "full_images.png")
64
+
65
+
66
+ def prepare_jsonl(root, output):
67
+ """Import the published dataset's existing splits without reshuffling them."""
68
+ root = Path(root).resolve()
69
+ data = root / "data" if (root / "data" / "3x3").is_dir() else root
70
+ records, counts = [], Counter()
71
+ for grid, tiles in GRID_SIZES.items():
72
+ for split in ("train", "validation", "test", "review", "excluded"):
73
+ metadata = data / grid / split / "metadata.jsonl"
74
+ if not metadata.is_file():
75
+ raise ValueError(f"Missing dataset metadata: {metadata}")
76
+ with metadata.open() as source:
77
+ for line_number, line in enumerate(source, 1):
78
+ try:
79
+ row = json.loads(line)
80
+ if row["grid"] != grid or not isinstance(row["target"], str):
81
+ raise ValueError("invalid grid or target")
82
+ answers, uncertain = row["correct_answers"], row["uncertain_cells"]
83
+ if any(not isinstance(x, list) for x in (answers, uncertain)) or any(
84
+ type(i) is not int or not 0 <= i < tiles for i in answers + uncertain
85
+ ):
86
+ raise ValueError("invalid cell indices")
87
+ path = (metadata.parent / row["file_name"]).resolve()
88
+ if not path.is_relative_to(metadata.parent.resolve()) or not path.is_file():
89
+ raise ValueError("invalid or missing image")
90
+ counts[split] += 1
91
+ if split == "excluded":
92
+ continue
93
+ record = {
94
+ "id": row["id"], "tiles": tiles,
95
+ "target": target_name(row["target"]),
96
+ "answers": sorted(set(answers)), "uncertain": sorted(set(uncertain)),
97
+ "image_path": str(path.relative_to(data)), "tile_files": False,
98
+ "label_source": row.get("label_source"),
99
+ "split": "val" if split == "validation" else split,
100
+ }
101
+ if split == "review" and isinstance(row.get("machine_answers"), list):
102
+ record["labeler_answers"] = row["machine_answers"]
103
+ records.append(record)
104
+ except (KeyError, TypeError, ValueError, json.JSONDecodeError) as exc:
105
+ raise ValueError(f"Invalid record in {metadata}:{line_number}: {exc}") from exc
106
+ if not records:
107
+ raise ValueError(f"No labeled examples in {data}")
108
+ manifest = {"root": str(data), "records": records}
109
+ output = Path(output)
110
+ output.mkdir(parents=True, exist_ok=True)
111
+ (output / "split.json").write_text(json.dumps(manifest, indent=2) + "\n")
112
+ summary = {"splits": dict(counts), "uncertain_cells": sum(len(r["uncertain"]) for r in records)}
113
+ (output / "data_summary.json").write_text(json.dumps(summary, indent=2) + "\n")
114
+ return manifest, summary
115
+
116
+
117
+ def _scan_labeled(directory, sam=False):
118
+ """One <item>/{image.jpg, metadata.json} folder: (record, None) or (None, reason).
119
+ With sam, 4x4 answers come from <item>/sam.json instead."""
120
+ try:
121
+ info = json.loads((directory / "metadata.json").read_text())
122
+ except (OSError, json.JSONDecodeError):
123
+ return None, "unreadable metadata.json"
124
+ if not isinstance(info, dict):
125
+ return None, "invalid metadata.json"
126
+ if not isinstance(info.get("target"), str) or not info["target"].strip():
127
+ return None, "invalid target"
128
+ n = GRID_SIZES.get(str(info.get("grid", "")).lower())
129
+ if n is None:
130
+ return None, "unknown grid"
131
+ if sam and n == 16:
132
+ try:
133
+ label = json.loads((directory / "sam.json").read_text())
134
+ except (OSError, json.JSONDecodeError):
135
+ return None, "no sam.json"
136
+ if not isinstance(label, dict) or not {"correct_answers", "model"} <= label.keys():
137
+ return None, "invalid sam.json"
138
+ # SAM gives no uncertain cells; its cutoffs were tuned on reference grids.
139
+ info = {
140
+ **info,
141
+ "correct_answers": label["correct_answers"],
142
+ "uncertain_cells": [],
143
+ "label_source": f"{label['model']}:sam",
144
+ }
145
+ if "correct_answers" not in info:
146
+ return None, "not labeled"
147
+ answers, uncertain = info["correct_answers"], info.get("uncertain_cells", [])
148
+ if (
149
+ not isinstance(answers, list)
150
+ or not isinstance(uncertain, list)
151
+ or any(type(i) is not int or not 0 <= i < n for i in answers + uncertain)
152
+ ):
153
+ return None, "invalid answers"
154
+ path = next((directory / name for name in IMAGE_NAMES if (directory / name).exists()), None)
155
+ if path is None:
156
+ return None, "no image"
157
+ try:
158
+ image = read_rgb(path)
159
+ except OSError:
160
+ return None, "unreadable image"
161
+ hashes = [image_hash(image)]
162
+ if n == 9:
163
+ # Separate photos get reused across grids; hashing each keeps reused photos in one split.
164
+ hashes += [image_hash(image.crop(box)) for box in grid_boxes(*image.size, n)]
165
+ return {
166
+ "id": directory.name,
167
+ "tiles": n,
168
+ "target": target_name(info["target"]),
169
+ "answers": sorted(set(answers)),
170
+ "uncertain": sorted(set(uncertain)),
171
+ "image": path.name,
172
+ "tile_files": False,
173
+ "label_source": info.get("label_source"),
174
+ "hashes": hashes,
175
+ }, None
176
+
177
+
178
+ def scan(root, workers=8, sam=False):
179
+ """Answer-key folders (info.json + full_images.png + tile_N.png) and labeled
180
+ <item>/{image.jpg, metadata.json} folders. Returns (records, {skip reason: count})."""
181
+ if workers < 1:
182
+ raise ValueError("Scanning workers must be positive")
183
+ directories = sorted(
184
+ p for p in Path(root).iterdir() if p.is_dir() and not p.name.startswith(".")
185
+ )
186
+ labeled = [d for d in directories if not (d / "info.json").exists()]
187
+ records, skipped = [], Counter()
188
+ if labeled:
189
+ with Pool(workers) as pool:
190
+ for record, reason in pool.imap(partial(_scan_labeled, sam=sam), labeled, chunksize=64):
191
+ if record:
192
+ records.append(record)
193
+ else:
194
+ skipped[reason] += 1
195
+ for directory in directories:
196
+ if not (directory / "info.json").exists():
197
+ continue
198
+ info = json.loads((directory / "info.json").read_text())
199
+ indices = sorted(int(p.stem.split("_")[1]) for p in directory.glob("tile_*.png"))
200
+ n = len(indices)
201
+ if n not in (9, 16) or indices != list(range(n)):
202
+ raise ValueError(f"Invalid tiles: {directory}")
203
+ answers = info["correct_answers"]
204
+ if (
205
+ not isinstance(answers, list)
206
+ or any(type(i) is not int or not 0 <= i < n for i in answers)
207
+ or len(set(answers)) != len(answers)
208
+ ):
209
+ raise ValueError(f"Invalid answers: {directory}")
210
+ paths = [directory / "full_images.png"] + [directory / f"tile_{i}.png" for i in range(n)]
211
+ records.append(
212
+ {
213
+ "id": directory.name,
214
+ "tiles": n,
215
+ "target": target_name(info["keyword"]),
216
+ "answers": sorted(answers),
217
+ "hashes": [pixel_hash(p) for p in paths],
218
+ }
219
+ )
220
+ if not records:
221
+ raise ValueError(f"No labeled examples in {root} ({dict(skipped)})")
222
+ records.sort(key=lambda r: r["id"])
223
+ return records, dict(skipped)
224
+
225
+
226
+ def split_records(records, seed, holdouts=("val", "test"), review=()):
227
+ """Records whose id is in review go to a "review" split; unreviewed records sharing an image
228
+ or tile with them get split "dropped" so nothing they show leaks into training."""
229
+ # Connected components prevent leakage even when only one tile is repeated.
230
+ review = set(review)
231
+ parent = list(range(len(records)))
232
+
233
+ def find(i):
234
+ while parent[i] != i:
235
+ parent[i] = parent[parent[i]]
236
+ i = parent[i]
237
+ return i
238
+
239
+ seen = {}
240
+ for i, record in enumerate(records):
241
+ for digest in record["hashes"]:
242
+ if digest in seen:
243
+ parent[find(i)] = find(seen[digest])
244
+ seen[digest] = i
245
+ groups = defaultdict(list)
246
+ for i, record in enumerate(records):
247
+ groups[find(i)].append(record)
248
+ strata = defaultdict(list)
249
+ for group in groups.values():
250
+ if review and any(r.get("id") in review for r in group):
251
+ for record in group:
252
+ record["split"] = "review" if record.get("id") in review else "dropped"
253
+ continue
254
+ strata[tuple(sorted({(r["tiles"], r["target"]) for r in group}))].append(group)
255
+ rng = random.Random(seed)
256
+ for key in sorted(strata):
257
+ items = strata[key]
258
+ rng.shuffle(items)
259
+ # Fewer than three independent examples cannot support three splits.
260
+ holdout = max(1, round(len(items) * 0.1)) if len(items) >= len(holdouts) + 1 else 0
261
+ for i, group in enumerate(items):
262
+ split = holdouts[i // holdout] if i < holdout * len(holdouts) else "train"
263
+ for record in group:
264
+ record["split"] = split
265
+ return records
266
+
267
+
268
+ def prepare(root, output, seed=42, workers=8, sam=False, review_keys=()):
269
+ """review_keys: reference answer files ({"items": {id: {"answers": [...]}}}). Those grids
270
+ get the reviewed answers and their own "review" split, never used for training or selection."""
271
+ output = Path(output)
272
+ output.mkdir(parents=True, exist_ok=True)
273
+ records, skipped = scan(root, workers, sam)
274
+ review = {}
275
+ for path in review_keys:
276
+ review.update(json.loads(Path(path).read_text())["items"])
277
+ for record in records:
278
+ if record["id"] in review:
279
+ # Keep the machine label so evaluation can score the labeler on the same grids.
280
+ record.update(
281
+ labeler_answers=record["answers"],
282
+ answers=review[record["id"]]["answers"],
283
+ uncertain=[],
284
+ label_source="review",
285
+ )
286
+ # Quarantine contradictory answer keys without changing source files.
287
+ duplicates = defaultdict(list)
288
+ for record in records:
289
+ if record["id"] in review:
290
+ continue
291
+ key = (record["hashes"][0], record["target"], record["tiles"])
292
+ duplicates[key].append(record)
293
+ excluded = [
294
+ r
295
+ for group in duplicates.values()
296
+ if len({tuple(r["answers"]) for r in group}) > 1
297
+ for r in group
298
+ ]
299
+ excluded_ids = {r["id"] for r in excluded}
300
+ records = split_records(
301
+ [r for r in records if r["id"] not in excluded_ids], seed, review=review
302
+ )
303
+ dropped = sum(r["split"] == "dropped" for r in records)
304
+ records = [r for r in records if r["split"] != "dropped"]
305
+ manifest = {
306
+ "seed": seed,
307
+ "root": str(Path(root).resolve()),
308
+ "records": records,
309
+ "excluded_conflicting_labels": excluded,
310
+ }
311
+ (output / "label_conflicts.json").write_text(json.dumps(excluded, indent=2) + "\n")
312
+ (output / "split.json").write_text(json.dumps(manifest, indent=2) + "\n")
313
+ counts = {}
314
+ for n in (9, 16):
315
+ counts[str(n)] = {
316
+ target: dict(
317
+ Counter(r["split"] for r in records if r["tiles"] == n and r["target"] == target)
318
+ )
319
+ for target in sorted({r["target"] for r in records if r["tiles"] == n})
320
+ }
321
+ counts["skipped"] = skipped
322
+ counts["excluded_conflicting_labels"] = len(excluded)
323
+ counts["dropped_sharing_images_with_review"] = dropped
324
+ counts["uncertain_cells"] = sum(len(r.get("uncertain", [])) for r in records)
325
+ (output / "data_summary.json").write_text(json.dumps(counts, indent=2) + "\n")
326
+ return manifest, counts
327
+
328
+
329
+ def _file_hashes(path):
330
+ with Image.open(path) as image:
331
+ width, height = image.size
332
+ thumbnail = image.convert("L").resize((32, 32), Image.Resampling.BOX).tobytes()
333
+ return str(path), pixel_hash(path), average_hash(path), max(width, height), thumbnail
334
+
335
+
336
+ def _held_out_hashes(item):
337
+ root, record = item
338
+ directory = root / record["id"]
339
+ image = read_rgb(record_image_path(root, record))
340
+ pictures = [image]
341
+ if record.get("tile_files", True):
342
+ pictures.extend(read_rgb(directory / f"tile_{i}.png") for i in range(record["tiles"]))
343
+ else:
344
+ pictures.extend(image.crop(box) for box in grid_boxes(*image.size, record["tiles"]))
345
+ return [
346
+ (
347
+ _average_hash(picture),
348
+ picture.convert("L").resize((32, 32), Image.Resampling.BOX).tobytes(),
349
+ )
350
+ for picture in pictures
351
+ ]
352
+
353
+
354
+ def same_picture(a, b, tolerance=12):
355
+ """Average hashes collide for similar layouts; confirm with a 32x32 mean absolute difference."""
356
+ return sum(abs(x - y) for x, y in zip(a, b)) / len(a) < tolerance
357
+
358
+
359
+ IMAGE_SUFFIXES = (".png", ".jpg", ".jpeg", ".webp")
360
+ # One YOLO box: class id, then centre x/y and width/height with six decimals. Some files
361
+ # lost their line breaks, gluing the next class id onto the previous number.
362
+ BOX = re.compile(r"(\d+)\s*(\d\.\d{6})\s+(\d\.\d{6})\s+(\d\.\d{6})\s+(\d\.\d{6})")
363
+
364
+
365
+ def label_file(path):
366
+ """YOLO layout: <root>/images/<Class>/x.png pairs with <root>/labels/<Class>/x.txt."""
367
+ parts = path.parts
368
+ if "images" not in parts:
369
+ return None
370
+ i = len(parts) - 1 - parts[::-1].index("images")
371
+ candidate = Path(*parts[:i], "labels", *parts[i + 1 :]).with_suffix(".txt")
372
+ return candidate if candidate.exists() else None
373
+
374
+
375
+ def box_classes(path):
376
+ return sorted({int(match[0]) for match in BOX.findall(path.read_text())})
377
+
378
+
379
+ def scan_folders(roots):
380
+ """Images labeled by their parent folder; <split>/ and images/ levels are ignored.
381
+
382
+ YOLO class ids are mapped to the folder where each id appears most often, so boxes
383
+ for other classes add those targets to an image.
384
+ """
385
+ paths, labels, boxes = [], [], []
386
+ for root in roots:
387
+ for path in sorted(Path(root).rglob("*")):
388
+ if path.suffix.lower() in IMAGE_SUFFIXES and not path.name.startswith("."):
389
+ paths.append(path)
390
+ labels.append(target_name(path.parent.name))
391
+ label = label_file(path)
392
+ boxes.append(box_classes(label) if label else [])
393
+ votes = defaultdict(Counter)
394
+ for label, ids in zip(labels, boxes):
395
+ for i in ids:
396
+ votes[i][label] += 1
397
+ id_names = {i: counts.most_common(1)[0][0] for i, counts in votes.items()}
398
+ targets = [sorted({label, *(id_names[i] for i in ids)}) for label, ids in zip(labels, boxes)]
399
+ return paths, targets, {str(i): name for i, name in sorted(id_names.items())}
400
+
401
+
402
+ def prepare_folders(roots, old_manifest, output, seed=42, workers=8):
403
+ """Merge exact copies, group near-copies, and re-split one or more class-folder datasets.
404
+
405
+ The folders' own train/val divisions are ignored because many images appear in both.
406
+ Images resembling held-out grids of the old dataset are dropped.
407
+ """
408
+ roots = [Path(r).resolve() for r in ([roots] if isinstance(roots, (str, Path)) else roots)]
409
+ base = Path(os.path.commonpath(roots)) if len(roots) > 1 else roots[0]
410
+ output = Path(output)
411
+ output.mkdir(parents=True, exist_ok=True)
412
+ paths, path_targets, id_names = scan_folders(roots)
413
+ old = json.loads(Path(old_manifest).read_text())
414
+ old_root = Path(old["root"])
415
+ held_out = [(old_root, record) for record in old["records"] if record["split"] != "train"]
416
+ with Pool(workers) as pool:
417
+ hashed = pool.map(_file_hashes, paths, chunksize=64)
418
+ held_out_hashes = defaultdict(list)
419
+ for pictures in pool.map(_held_out_hashes, held_out, chunksize=64):
420
+ for ahash, thumbnail in pictures:
421
+ held_out_hashes[ahash].append(thumbnail)
422
+ by_pixels, thumbnails = {}, {}
423
+ sources = Counter()
424
+ for path, labels, (_, digest, ahash, side, thumbnail) in zip(paths, path_targets, hashed):
425
+ thumbnails[digest] = thumbnail
426
+ relative = path.relative_to(base)
427
+ if digest not in by_pixels:
428
+ sources[relative.parts[0] if len(roots) > 1 else roots[0].name] += 1
429
+ record = by_pixels.setdefault(
430
+ digest,
431
+ {
432
+ "path": str(relative),
433
+ "targets": [],
434
+ "kind": "full" if side >= 400 else "tile",
435
+ "tiles": "full" if side >= 400 else "tile",
436
+ "hashes": [digest, ahash],
437
+ },
438
+ )
439
+ record["targets"].extend(t for t in labels if t not in record["targets"])
440
+ records, leaked, conflicts = [], [], []
441
+ for record in by_pixels.values():
442
+ record["targets"].sort()
443
+ if any(
444
+ same_picture(thumbnails[record["hashes"][0]], other)
445
+ for other in held_out_hashes.get(record["hashes"][1], [])
446
+ ):
447
+ leaked.append(record["path"])
448
+ else:
449
+ if BACKGROUND in record["targets"] and len(record["targets"]) > 1:
450
+ # Images moved out of "Other" into a target folder mostly do show that target.
451
+ conflicts.append(record["path"])
452
+ record["targets"].remove(BACKGROUND)
453
+ record["target"] = record["targets"][0]
454
+ records.append(record)
455
+ if not records:
456
+ raise ValueError("No folder images remain after excluding held-out images")
457
+ split_records(records, seed, holdouts=("val",))
458
+ for record in records:
459
+ del record["target"], record["tiles"]
460
+ summary = {
461
+ "roots": [str(r) for r in roots],
462
+ "files": len(paths),
463
+ "unique_images": len(by_pixels),
464
+ "unique_images_by_first_source": dict(sources),
465
+ "yolo_class_ids": id_names,
466
+ "exact_duplicates_merged": len(paths) - len(by_pixels),
467
+ "multi_label_images": sum(len(r["targets"]) > 1 for r in records),
468
+ "dropped_matching_old_heldout": len(leaked),
469
+ "background_label_overridden_by_target": len(conflicts),
470
+ "largest_near_duplicate_group": max(Counter(r["hashes"][1] for r in records).values()),
471
+ "counts": {
472
+ kind: {
473
+ target: dict(
474
+ Counter(
475
+ r["split"] for r in records if r["kind"] == kind and target in r["targets"]
476
+ )
477
+ )
478
+ for target in sorted({t for r in records for t in r["targets"]})
479
+ }
480
+ for kind in ("tile", "full")
481
+ },
482
+ }
483
+ manifest = {
484
+ "seed": seed,
485
+ "root": str(base),
486
+ "sources": [str(r) for r in roots],
487
+ "old_manifest": str(Path(old_manifest).resolve()),
488
+ "records": records,
489
+ "dropped_matching_old_heldout": leaked,
490
+ "background_label_overridden_by_target": conflicts,
491
+ }
492
+ (output / "folders.json").write_text(json.dumps(manifest, indent=2) + "\n")
493
+ (output / "folders_summary.json").write_text(json.dumps(summary, indent=2) + "\n")
494
+ return manifest, summary
495
+
496
+
497
+ class AddNoise:
498
+ """Some real tiles carry heavy pixel noise."""
499
+
500
+ def __init__(self, probability=0.3, max_std=0.15):
501
+ self.probability, self.max_std = probability, max_std
502
+
503
+ def __call__(self, image):
504
+ if random.random() >= self.probability:
505
+ return image
506
+ return (image + torch.randn_like(image) * random.uniform(0.02, self.max_std)).clamp(0, 1)
507
+
508
+
509
+ def transform(size, training=False, noise=False):
510
+ operations = [T.Resize((size, size), interpolation=T.InterpolationMode.BILINEAR)]
511
+ if training:
512
+ operations.append(T.ColorJitter(brightness=0.15, contrast=0.15, saturation=0.1))
513
+ operations.append(T.ToTensor())
514
+ if training and noise:
515
+ operations.append(AddNoise())
516
+ return T.Compose(operations + [T.Normalize((0.485, 0.456, 0.406), (0.229, 0.224, 0.225))])
517
+
518
+
519
+ class GridDataset(Dataset):
520
+ def __init__(
521
+ self,
522
+ root,
523
+ records,
524
+ classes,
525
+ size,
526
+ training=False,
527
+ tiles=False,
528
+ tile_grids=False,
529
+ include_full_images=False,
530
+ ):
531
+ self.root = Path(root)
532
+ self.records = records
533
+ self.classes = classes
534
+ self.transform = transform(size, training)
535
+ self.tiles = tiles
536
+ self.tile_grids = tile_grids
537
+ self.items = [(r, i) for r in records for i in (range(r["tiles"]) if tiles else [None])]
538
+ if include_full_images:
539
+ if not tiles:
540
+ raise ValueError("Whole-image classification examples require tile training")
541
+ self.items += [(r, -1) for r in records if r["tiles"] == 16]
542
+
543
+ def __len__(self):
544
+ return len(self.items)
545
+
546
+ def full_image(self, record):
547
+ return read_rgb(record_image_path(self.root, record))
548
+
549
+ def tile_images(self, record, indices):
550
+ if record.get("tile_files", True):
551
+ return [read_rgb(self.root / record["id"] / f"tile_{i}.png") for i in indices]
552
+ image = self.full_image(record)
553
+ boxes = grid_boxes(*image.size, record["tiles"])
554
+ return [image.crop(boxes[i]) for i in indices]
555
+
556
+ def __getitem__(self, index):
557
+ record, tile = self.items[index]
558
+ label = torch.tensor([float(i in record["answers"]) for i in range(record["tiles"])])
559
+ if tile == -1:
560
+ image = self.transform(self.full_image(record))
561
+ label = label.any().float()
562
+ elif tile is not None:
563
+ image = self.transform(self.tile_images(record, [tile])[0])
564
+ label = label[tile]
565
+ elif record["tiles"] == 9 or self.tile_grids:
566
+ image = torch.stack(
567
+ [self.transform(t) for t in self.tile_images(record, range(record["tiles"]))]
568
+ )
569
+ else:
570
+ image = self.transform(self.full_image(record))
571
+ return image, self.classes.index(record["target"]), label
572
+
573
+
574
+ def supervision(classes, cells, target, cell_labels=None, any_label=None):
575
+ """Labels and weights for (classes, cells) logits; zero weight means unknown."""
576
+ labels, weights = torch.zeros(len(classes), cells), torch.zeros(len(classes), cells)
577
+ any_labels, any_weights = torch.zeros(len(classes)), torch.zeros(len(classes))
578
+ if cell_labels is not None:
579
+ labels[target], weights[target] = cell_labels, 1
580
+ if any_label is not None:
581
+ any_labels[target], any_weights[target] = any_label, 1
582
+ return labels, weights, any_labels, any_weights
583
+
584
+
585
+ class SupervisedGrids(Dataset):
586
+ """Answer-key items in the per-class format: only the queried target is known.
587
+ Cells listed as uncertain get zero weight unless keep_uncertain is set."""
588
+
589
+ def __init__(self, grids, cells, keep_uncertain=False, flip=False):
590
+ self.grids, self.cells, self.keep_uncertain, self.flip = grids, cells, keep_uncertain, flip
591
+
592
+ def __len__(self):
593
+ return len(self.grids)
594
+
595
+ def __getitem__(self, index):
596
+ record, tile = self.grids.items[index]
597
+ image, target, label = self.grids[index]
598
+ if tile == -1:
599
+ return (image, *supervision(self.grids.classes, self.cells, target, any_label=label))
600
+ uncertain = [] if self.keep_uncertain else record.get("uncertain", [])
601
+ if self.flip and random.random() < 0.5:
602
+ # Mirror left-right; a whole grid also mirrors its cell numbers.
603
+ image = image.flip(-1)
604
+ if tile is None:
605
+ n = int(label.numel() ** 0.5)
606
+ label = label.view(n, n).flip(-1).flatten()
607
+ uncertain = [c - c % n + n - 1 - c % n for c in uncertain]
608
+ labels, weights, any_labels, any_weights = supervision(
609
+ self.grids.classes, self.cells, target, cell_labels=label
610
+ )
611
+ if tile is not None:
612
+ if tile in uncertain:
613
+ weights.zero_()
614
+ else:
615
+ for cell in uncertain:
616
+ weights[target, cell] = 0
617
+ return image, labels, weights, any_labels, any_weights
618
+
619
+
620
+ class FolderDataset(Dataset):
621
+ """Single-label folder images: present for named targets, others assumed absent at low weight.
622
+
623
+ A folder label says the image contains that target. Another target may also be visible,
624
+ so absence is only weakly supervised, except for background images, which contain none.
625
+ """
626
+
627
+ def __init__(self, root, records, classes, size, cells=1, training=False, negative_weight=0.2):
628
+ self.root = Path(root)
629
+ self.records = records
630
+ self.classes = classes
631
+ self.cells = cells
632
+ self.negative_weight = negative_weight
633
+ self.transform = transform(size, training, noise=True)
634
+
635
+ def __len__(self):
636
+ return len(self.records)
637
+
638
+ def __getitem__(self, index):
639
+ record = self.records[index]
640
+ image = self.transform(read_rgb(self.root / record["path"]))
641
+ background = BACKGROUND in record["targets"]
642
+ any_weights = torch.full((len(self.classes),), 1.0 if background else self.negative_weight)
643
+ any_labels = torch.zeros(len(self.classes))
644
+ for target in record["targets"]:
645
+ if target in self.classes:
646
+ any_labels[self.classes.index(target)] = any_weights[self.classes.index(target)] = 1
647
+ empty = torch.zeros(len(self.classes), self.cells)
648
+ return image, empty, empty.clone(), any_labels, any_weights
models.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Small pretrained models for independent tiles and continuous grids."""
2
+
3
+ import timm
4
+ from torch import nn
5
+
6
+ BACKBONE = "mobilenetv4_conv_medium.e250_r384_in12k_ft_in1k"
7
+
8
+
9
+ class GridModel(nn.Module):
10
+ def __init__(self, tiles, classes, pretrained=True, backbone=BACKBONE):
11
+ super().__init__()
12
+ if tiles not in (9, 16):
13
+ raise ValueError("Grid size must be 9 or 16 tiles")
14
+ self.tiles = tiles
15
+ if tiles == 9:
16
+ self.backbone = timm.create_model(backbone, pretrained=pretrained)
17
+ self.backbone.reset_classifier(0)
18
+ channels = self.backbone.head_hidden_size
19
+ self.head = nn.Linear(channels, classes)
20
+ else:
21
+ # The stride-16 stage: 448 px input gives a 28x28 map, 7x7 per cell.
22
+ stage = (
23
+ timm.create_model(backbone, features_only=True).feature_info.reduction().index(16)
24
+ )
25
+ self.backbone = timm.create_model(
26
+ backbone, pretrained=pretrained, features_only=True, out_indices=(stage,)
27
+ )
28
+ channels = self.backbone.feature_info.channels()[0]
29
+ self.head = nn.Sequential(
30
+ nn.Conv2d(channels, 128, 3, padding=1),
31
+ nn.ReLU(),
32
+ nn.Conv2d(128, classes, 1),
33
+ # Max, not mean: any part of the target selects the cell.
34
+ nn.AdaptiveMaxPool2d((4, 4)),
35
+ )
36
+
37
+ def forward(self, images):
38
+ features = self.backbone(images)
39
+ return self.head(features if self.tiles == 9 else features[0])
40
+
41
+ def freeze_backbone(self, frozen):
42
+ for parameter in self.backbone.parameters():
43
+ parameter.requires_grad_(not frozen)
44
+
45
+
46
+ def select_target(logits, targets):
47
+ """Only the requested target is supervised; other targets are unknown."""
48
+ import torch
49
+
50
+ return logits[torch.arange(logits.shape[0], device=logits.device), targets]
51
+
52
+
53
+ def transfer_backbone(model, state):
54
+ """Copy matching backbone weights, e.g. from a tile classifier into the 4x4 feature extractor."""
55
+ source = {k.removeprefix("backbone."): v for k, v in state.items() if k.startswith("backbone.")}
56
+ target = model.backbone.state_dict()
57
+ matched = {k: v for k, v in source.items() if k in target and target[k].shape == v.shape}
58
+ missing = sorted(set(target) - set(matched))
59
+ if missing:
60
+ raise ValueError(
61
+ f"Backbone weights missing for {len(missing)} parameters, e.g. {missing[:3]}"
62
+ )
63
+ model.backbone.load_state_dict(matched)
64
+ return len(matched)
predict_onnx.py ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Predict with an exported ONNX model. Needs only onnxruntime, numpy, and Pillow (no PyTorch).
2
+
3
+ python predict_onnx.py --model weights/grid9.onnx --image challenge.png --target bicycles
4
+ """
5
+
6
+ import argparse
7
+ import json
8
+ from pathlib import Path
9
+
10
+ import numpy as np
11
+ import onnxruntime as ort
12
+ from PIL import Image
13
+
14
+ from targets import target_name
15
+
16
+ MEAN = np.array([0.485, 0.456, 0.406], dtype=np.float32)
17
+ STD = np.array([0.229, 0.224, 0.225], dtype=np.float32)
18
+ IMAGE_NAMES = ("image.jpg", "image.jpeg", "image.png", "image.webp")
19
+
20
+
21
+ def preprocess(image, size):
22
+ """Matches torchvision Resize (bilinear, PIL), ToTensor and Normalize."""
23
+ image = image.convert("RGB").resize((size, size), Image.Resampling.BILINEAR)
24
+ return ((np.asarray(image, dtype=np.float32) / 255 - MEAN) / STD).transpose(2, 0, 1)
25
+
26
+
27
+ class GridPredictor:
28
+ def __init__(self, model, threads=None):
29
+ if threads is not None and threads < 1:
30
+ raise ValueError("CPU threads must be positive")
31
+ options = ort.SessionOptions()
32
+ if threads:
33
+ options.intra_op_num_threads = threads
34
+ self.session = ort.InferenceSession(str(model), options, providers=["CPUExecutionProvider"])
35
+ self.info = json.loads(self.session.get_modelmeta().custom_metadata_map["grid_vision"])
36
+
37
+ def inputs(self, source):
38
+ """Model input for a challenge image, or a dataset item folder holding image.jpg."""
39
+ source, size, tiles = Path(source), self.info["size"], self.info["tiles"]
40
+ if source.is_dir():
41
+ found = next((source / name for name in IMAGE_NAMES if (source / name).is_file()), None)
42
+ if found is None:
43
+ raise ValueError(f"No image in {source} (expected one of {IMAGE_NAMES})")
44
+ source = found
45
+ with Image.open(source) as opened:
46
+ image = opened.convert("RGB")
47
+ if tiles == 9:
48
+ # Same rounding as training's grid_boxes.
49
+ w, h = image.size
50
+ xs, ys = [round(w * i / 3) for i in range(4)], [round(h * i / 3) for i in range(4)]
51
+ return np.stack(
52
+ [
53
+ preprocess(image.crop((xs[c], ys[r], xs[c + 1], ys[r + 1])), size)
54
+ for r in range(3)
55
+ for c in range(3)
56
+ ]
57
+ )
58
+ return preprocess(image, size)[None]
59
+
60
+ def probabilities(self, inputs):
61
+ """Per-class probabilities, shaped (classes, cells)."""
62
+ output = self.session.run(None, {self.session.get_inputs()[0].name: inputs})[0]
63
+ return output.T if self.info["tiles"] == 9 else output[0]
64
+
65
+ def predict(self, source, target):
66
+ name = target_name(target)
67
+ if name not in self.info["classes"]:
68
+ raise ValueError(f"Unknown target {name!r}; supported: {self.info['classes']}")
69
+ probabilities = self.probabilities(self.inputs(source))[self.info["classes"].index(name)]
70
+ cutoff = self.info["thresholds"].get(name, self.info["threshold"])
71
+ return {
72
+ "target": name,
73
+ "threshold": cutoff,
74
+ "selected_cells": [int(i) for i in np.flatnonzero(probabilities >= cutoff)],
75
+ "probabilities": probabilities.tolist(),
76
+ }
77
+
78
+
79
+ def main():
80
+ parser = argparse.ArgumentParser(
81
+ description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
82
+ )
83
+ parser.add_argument("--model", required=True)
84
+ parser.add_argument("--image", required=True, help="Challenge image, or a dataset item folder")
85
+ parser.add_argument("--target", required=True)
86
+ parser.add_argument("--threads", type=int, help="CPU threads (default: onnxruntime's choice)")
87
+ args = parser.parse_args()
88
+ print(
89
+ json.dumps(
90
+ GridPredictor(args.model, args.threads).predict(args.image, args.target), indent=2
91
+ )
92
+ )
93
+
94
+
95
+ if __name__ == "__main__":
96
+ main()
pyproject.toml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "rc1"
3
+ version = "0.1.0"
4
+ description = "Image models for reCAPTCHA v2 grids"
5
+ readme = "README.md"
6
+ requires-python = ">=3.11,<3.12"
7
+ dependencies = [
8
+ "torch==2.8.0",
9
+ "torchvision==0.23.0",
10
+ "timm==1.0.20",
11
+ "huggingface-hub==0.34.4",
12
+ "Pillow==11.3.0",
13
+ "numpy==2.2.6",
14
+ ]
15
+
16
+ [tool.uv]
17
+ package = false
18
+
19
+ [dependency-groups]
20
+ export = [
21
+ "onnx>=1.23.2",
22
+ "onnxruntime>=1.30.0",
23
+ ]
24
+
25
+ [tool.ruff]
26
+ target-version = "py311"
27
+ line-length = 100
28
+
29
+ [tool.ruff.lint]
30
+ select = ["E4", "E7", "E9", "F", "I"]
targets.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Target names shared by training and torch-free inference."""
2
+
3
+ ALIASES = {
4
+ "bicycles": "bicycle",
5
+ "motorcycles": "motorcycle",
6
+ "cars": "car",
7
+ "bus": "bus",
8
+ "buses": "bus",
9
+ "crosswalks": "crosswalk",
10
+ "a fire hydrant": "fire hydrant",
11
+ "fire hydrants": "fire hydrant",
12
+ "stairs": "stairs",
13
+ "traffic lights": "traffic light",
14
+ "bridges": "bridge",
15
+ "tractors": "tractor",
16
+ "taxis": "taxi",
17
+ "hydrant": "fire hydrant",
18
+ "stair": "stairs",
19
+ "palm": "palm tree",
20
+ "palm trees": "palm tree",
21
+ "chimneys": "chimney",
22
+ "parking meters": "parking meter",
23
+ "mountains": "mountain",
24
+ "mountains or hills": "mountain",
25
+ "tlight": "traffic light",
26
+ }
27
+ # Folder images of this class contain none of the targets.
28
+ BACKGROUND = "other"
29
+
30
+
31
+ def target_name(value):
32
+ value = value.strip().lower()
33
+ return ALIASES.get(value, value)
test_training.py ADDED
@@ -0,0 +1,610 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Small checks for mistakes that would invalidate training or evaluation."""
2
+
3
+ import json
4
+ import tempfile
5
+ import unittest
6
+ from pathlib import Path
7
+
8
+ import torch
9
+ from PIL import Image
10
+
11
+ from data import (
12
+ FolderDataset,
13
+ GridDataset,
14
+ SupervisedGrids,
15
+ prepare,
16
+ prepare_folders,
17
+ prepare_jsonl,
18
+ split_records,
19
+ target_name,
20
+ transform,
21
+ )
22
+ from models import GridModel, select_target, transfer_backbone
23
+ from train import (
24
+ auxiliary_records,
25
+ choose_threshold,
26
+ grid_logits,
27
+ metrics,
28
+ partial_loss,
29
+ thresholds_for,
30
+ )
31
+
32
+
33
+ class TrainingTests(unittest.TestCase):
34
+ def test_jsonl_dataset_preserves_splits_and_loads_images(self):
35
+ with tempfile.TemporaryDirectory() as temporary:
36
+ root = Path(temporary) / "dataset"
37
+ for grid in ("3x3", "4x4"):
38
+ for split in ("train", "validation", "test", "review", "excluded"):
39
+ folder = root / "data" / grid / split
40
+ (folder / "images").mkdir(parents=True)
41
+ Image.new("RGB", (30, 30), "red").save(folder / "images" / "grid.jpg")
42
+ row = {"id": f"{grid}-{split}", "grid": grid, "target": "buses",
43
+ "file_name": "images/grid.jpg", "correct_answers": [0],
44
+ "uncertain_cells": [1], "machine_answers": [2]}
45
+ (folder / "metadata.jsonl").write_text(json.dumps(row) + "\n")
46
+ manifest, summary = prepare_jsonl(root, Path(temporary) / "output")
47
+ self.assertEqual(len(manifest["records"]), 8)
48
+ self.assertEqual(summary["splits"]["excluded"], 2)
49
+ record = next(r for r in manifest["records"] if r["id"] == "3x3-validation")
50
+ self.assertEqual((record["split"], record["target"], record["uncertain"]),
51
+ ("val", "bus", [1]))
52
+ sample = GridDataset(manifest["root"], [record], ["bus"], 16)[0]
53
+ self.assertEqual(tuple(sample[0].shape), (9, 3, 16, 16))
54
+ review = next(r for r in manifest["records"] if r["id"] == "4x4-review")
55
+ self.assertEqual(review["labeler_answers"], [2])
56
+
57
+ def test_enlarged_views_apply_only_to_requested_targets(self):
58
+ class MeanModel(torch.nn.Module):
59
+ tiles = 9
60
+ crop_target_ids = [0]
61
+
62
+ def forward(self, images):
63
+ mean = images.mean((1, 2, 3))
64
+ return torch.stack([mean, mean], dim=1)
65
+
66
+ images = torch.zeros(2, 1, 3, 8, 8)
67
+ images[:, :, :, :4, :4] = 1
68
+ output = grid_logits(MeanModel(), images, torch.tensor([0, 1]))
69
+ self.assertTrue(torch.equal(output, torch.tensor([[1.0], [0.25]])))
70
+
71
+ def test_auxiliary_training_and_validation_stay_separate(self):
72
+ records = [
73
+ {"id": str(i), "tiles": 16, "target": "motorcycle", "split": split}
74
+ for i, split in enumerate(["train", "val", "test"])
75
+ ]
76
+ self.assertEqual(
77
+ [r["id"] for r in auxiliary_records({"records": records}, ["motorcycle"], "train")],
78
+ ["0"],
79
+ )
80
+ self.assertEqual(auxiliary_records({"records": records}, ["bus"], "train"), [])
81
+
82
+ def test_auxiliary_crops_and_full_image_labels(self):
83
+ with tempfile.TemporaryDirectory() as root:
84
+ directory = Path(root) / "example"
85
+ directory.mkdir()
86
+ for name in ["full_images.png"] + [f"tile_{i}.png" for i in range(16)]:
87
+ Image.new("RGB", (16, 16), "blue").save(directory / name)
88
+ records = [{"id": "example", "tiles": 16, "target": "motorcycle", "answers": [0, 15]}]
89
+ training = GridDataset(
90
+ root, records, ["motorcycle"], 16, tiles=True, include_full_images=True
91
+ )
92
+ self.assertEqual(len(training), 17)
93
+ self.assertEqual([training[i][2].item() for i in [0, 1, 15, 16]], [1, 0, 1, 1])
94
+ validation = GridDataset(root, records, ["motorcycle"], 16, tile_grids=True)
95
+ self.assertEqual(tuple(validation[0][0].shape), (16, 3, 16, 16))
96
+ self.assertEqual(validation[0][2].sum().item(), 2)
97
+
98
+ def test_per_target_cutoffs_and_legacy_checkpoint(self):
99
+ checkpoint = {
100
+ "classes": ["bus", "motorcycle"],
101
+ "threshold": 0.5,
102
+ "thresholds": {"motorcycle": 0.3},
103
+ }
104
+ cutoffs = thresholds_for(checkpoint, torch.tensor([0, 1]))
105
+ result = metrics(torch.tensor([[0.4], [0.4]]), torch.tensor([[False], [True]]), cutoffs)
106
+ self.assertEqual(result["exact_grid_accuracy"], 1.0)
107
+ checkpoint.pop("thresholds")
108
+ self.assertTrue(
109
+ torch.equal(
110
+ thresholds_for(checkpoint, torch.tensor([0, 1])), torch.tensor([[0.5], [0.5]])
111
+ )
112
+ )
113
+
114
+ def test_conflicting_duplicates_are_excluded_without_editing_labels(self):
115
+ with tempfile.TemporaryDirectory() as temporary:
116
+ root = Path(temporary) / "dataset"
117
+ for i in range(3):
118
+ directory = root / str(i)
119
+ directory.mkdir(parents=True)
120
+ info = {"keyword": "buses", "correct_answers": [i]}
121
+ (directory / "info.json").write_text(json.dumps(info))
122
+ Image.new("RGB", (30, 30), "red" if i < 2 else "blue").save(
123
+ directory / "full_images.png"
124
+ )
125
+ for tile in range(9):
126
+ Image.new("RGB", (10, 10), (i * 70, tile * 20, 0)).save(
127
+ directory / f"tile_{tile}.png"
128
+ )
129
+ manifest, _ = prepare(root, Path(temporary) / "output")
130
+ self.assertEqual([r["id"] for r in manifest["records"]], ["2"])
131
+ self.assertEqual(len(manifest["excluded_conflicting_labels"]), 2)
132
+ self.assertEqual(
133
+ json.loads((root / "0" / "info.json").read_text())["correct_answers"], [0]
134
+ )
135
+ (root / "2" / "info.json").write_text(
136
+ json.dumps({"keyword": "bus", "correct_answers": [9]})
137
+ )
138
+ with self.assertRaisesRegex(ValueError, "Invalid answers"):
139
+ prepare(root, Path(temporary) / "output")
140
+
141
+ def test_transitive_duplicate_groups_never_leak(self):
142
+ records = [
143
+ {"id": str(i), "tiles": 9, "target": "bus", "hashes": [str(i)]} for i in range(30)
144
+ ]
145
+ records[0]["hashes"].append("shared-a")
146
+ records[1]["hashes"].extend(["shared-a", "shared-b"])
147
+ records[2]["hashes"].append("shared-b")
148
+ split_records(records, 42)
149
+ self.assertEqual(len({r["split"] for r in records[:3]}), 1)
150
+ self.assertEqual({r["split"] for r in records}, {"train", "val", "test"})
151
+ before = [r["split"] for r in records]
152
+ split_records(records, 42)
153
+ self.assertEqual(before, [r["split"] for r in records])
154
+
155
+ def test_singleton_is_training_only(self):
156
+ records = [{"tiles": 16, "target": "tractor", "hashes": ["x"]}]
157
+ self.assertEqual(split_records(records, 42)[0]["split"], "train")
158
+
159
+ def test_aliases(self):
160
+ self.assertEqual(target_name("buses"), target_name("bus"))
161
+ self.assertEqual(target_name("a fire hydrant"), target_name("fire hydrants"))
162
+
163
+ def test_unknown_targets_have_no_gradient(self):
164
+ logits = torch.zeros(2, 3, requires_grad=True)
165
+ loss = torch.nn.functional.binary_cross_entropy_with_logits(
166
+ select_target(logits, torch.tensor([0, 2])), torch.tensor([1.0, 0.0])
167
+ )
168
+ loss.backward()
169
+ self.assertTrue(
170
+ torch.equal(
171
+ logits.grad != 0, torch.tensor([[True, False, False], [False, False, True]])
172
+ )
173
+ )
174
+
175
+ def test_exact_grid_requires_every_cell_correct(self):
176
+ probabilities = torch.tensor([[0.9, 0.1], [0.9, 0.8]])
177
+ truth = torch.tensor([[True, False], [True, False]])
178
+ result = metrics(probabilities, truth, 0.5)
179
+ self.assertEqual(result["exact_grid_accuracy"], 0.5)
180
+ self.assertEqual(result["cell_accuracy"], 0.75)
181
+ self.assertGreater(choose_threshold(probabilities, truth), 0.8)
182
+
183
+ def test_row_major_target_selection(self):
184
+ logits = torch.arange(2 * 3 * 4 * 4).reshape(2, 3, 4, 4)
185
+ selected = select_target(logits.flatten(2), torch.tensor([1, 2]))
186
+ self.assertEqual(selected[0].tolist(), list(range(16, 32)))
187
+ self.assertEqual(selected[1].tolist(), list(range(80, 96)))
188
+
189
+ def test_models_have_expected_shapes(self):
190
+ torch.set_num_threads(2)
191
+ with torch.no_grad():
192
+ for tiles, size in [(9, 224), (16, 384)]:
193
+ model = GridModel(tiles, 3, pretrained=False).eval()
194
+ shape = (1, 9, 3, size, size) if tiles == 9 else (1, 3, size, size)
195
+ self.assertEqual(
196
+ tuple(grid_logits(model, torch.zeros(shape), torch.tensor([1])).shape),
197
+ (1, tiles),
198
+ )
199
+ if tiles == 9:
200
+ self.assertEqual(
201
+ tuple(
202
+ grid_logits(
203
+ model, torch.zeros(1, 16, 3, size, size), torch.tensor([1])
204
+ ).shape
205
+ ),
206
+ (1, 16),
207
+ )
208
+
209
+
210
+ class FolderDataTests(unittest.TestCase):
211
+ def test_folder_names_map_to_targets(self):
212
+ self.assertEqual(target_name("Hydrant"), "fire hydrant")
213
+ self.assertEqual(target_name("Traffic Light"), "traffic light")
214
+ self.assertEqual(target_name("Stair"), "stairs")
215
+ self.assertEqual(target_name("Palm"), target_name("palm trees"))
216
+
217
+ def test_folders_merge_copies_group_near_copies_and_drop_old_heldout(self):
218
+ with tempfile.TemporaryDirectory() as temporary:
219
+ temporary = Path(temporary)
220
+ old = temporary / "dataset" / "grid"
221
+ old.mkdir(parents=True)
222
+ held_out = Image.linear_gradient("L").convert("RGB").resize((64, 64))
223
+ for name in ["full_images.png"] + [f"tile_{i}.png" for i in range(9)]:
224
+ held_out.save(old / name)
225
+ (temporary / "split.json").write_text(
226
+ json.dumps(
227
+ {
228
+ "root": str(temporary / "dataset"),
229
+ "records": [{"id": "grid", "tiles": 9, "split": "test"}],
230
+ }
231
+ )
232
+ )
233
+ root = temporary / "folders"
234
+ for split in ("train", "val"):
235
+ for name in ("Bus", "Car", "Other"):
236
+ (root / split / name).mkdir(parents=True)
237
+ Image.new("RGB", (100, 100), "red").save(root / "train" / "Bus" / "a.png")
238
+ Image.new("RGB", (100, 100), "red").save(root / "val" / "Bus" / "copy.png")
239
+ Image.new("RGB", (100, 100), "red").save(root / "train" / "Car" / "also.png")
240
+ held_out.resize((120, 120)).rotate(180).rotate(180).save(
241
+ root / "train" / "Car" / "old.png"
242
+ )
243
+ for i in range(20):
244
+ image = Image.new("RGB", (100, 100), (0, 0, 0))
245
+ image.paste((255, 255, 255), (0, 0, 5 * (i + 1), 100))
246
+ image.save(root / "train" / "Car" / f"{i}.png")
247
+ image.resize((101, 101)).save(root / "val" / "Car" / f"near{i}.png")
248
+ Image.new("RGB", (450, 450), "blue").save(root / "train" / "Other" / "full.png")
249
+ manifest, summary = prepare_folders(
250
+ root, temporary / "split.json", temporary / "out", workers=2
251
+ )
252
+ self.assertEqual(summary["exact_duplicates_merged"], 2)
253
+ self.assertEqual(manifest["dropped_matching_old_heldout"], ["train/Car/old.png"])
254
+ merged = [r for r in manifest["records"] if len(r["targets"]) > 1]
255
+ self.assertEqual([r["targets"] for r in merged], [["bus", "car"]])
256
+ splits = {}
257
+ for record in manifest["records"]:
258
+ splits.setdefault(record["hashes"][1], set()).add(record["split"])
259
+ self.assertTrue(all(len(v) == 1 for v in splits.values()))
260
+ self.assertEqual({r["split"] for r in manifest["records"]}, {"train", "val"})
261
+ self.assertEqual(
262
+ [r["kind"] for r in manifest["records"] if r["targets"] == ["other"]], ["full"]
263
+ )
264
+
265
+ def test_three_folder_layouts_and_glued_yolo_lines(self):
266
+ with tempfile.TemporaryDirectory() as temporary:
267
+ temporary = Path(temporary)
268
+ (temporary / "split.json").write_text(
269
+ json.dumps({"root": str(temporary), "records": []})
270
+ )
271
+ images = {
272
+ "a/train/Bus/1.png": (10, 0, 0),
273
+ "a/val/TLight/2.png": (0, 10, 0),
274
+ "b/Stair/3.png": (0, 0, 10),
275
+ "b/Bus/1.png": (10, 0, 0),
276
+ "c/images/Chimney/4.png": (50, 0, 0),
277
+ "c/images/Stair/5.png": (0, 50, 0),
278
+ "c/images/Stair/6.png": (0, 0, 50),
279
+ }
280
+ for name, color in images.items():
281
+ (temporary / name).parent.mkdir(parents=True, exist_ok=True)
282
+ Image.new("RGB", (100, 100), color).save(temporary / name)
283
+ labels = temporary / "c" / "labels"
284
+ (labels / "Chimney").mkdir(parents=True)
285
+ (labels / "Stair").mkdir(parents=True)
286
+ (labels / "Chimney" / "4.txt").write_text(
287
+ "1 0.500000 0.500000 0.100000 0.1000002 0.300000 0.300000 0.200000 0.200000\n"
288
+ )
289
+ (labels / "Stair" / "5.txt").write_text("2 0.500000 0.500000 0.100000 0.100000\n")
290
+ (labels / "Stair" / "6.txt").write_text("2 0.400000 0.500000 0.100000 0.100000\n")
291
+ manifest, summary = prepare_folders(
292
+ [temporary / "a", temporary / "b", temporary / "c"],
293
+ temporary / "split.json",
294
+ temporary / "out",
295
+ workers=2,
296
+ )
297
+ targets = {r["path"]: r["targets"] for r in manifest["records"]}
298
+ self.assertEqual(targets["a/val/TLight/2.png"], ["traffic light"])
299
+ self.assertEqual(targets["c/images/Chimney/4.png"], ["chimney", "stairs"])
300
+ self.assertEqual(targets["c/images/Stair/6.png"], ["stairs"])
301
+ self.assertEqual(summary["yolo_class_ids"], {"1": "chimney", "2": "stairs"})
302
+ self.assertEqual(summary["exact_duplicates_merged"], 1)
303
+ self.assertEqual(summary["unique_images_by_first_source"], {"a": 2, "b": 1, "c": 3})
304
+ self.assertTrue(all((temporary / path).exists() for path in targets))
305
+
306
+ def test_folder_labels_are_weak_negatives_except_background(self):
307
+ with tempfile.TemporaryDirectory() as root:
308
+ Image.new("RGB", (8, 8)).save(Path(root) / "x.png")
309
+ records = [
310
+ {"path": "x.png", "targets": ["bus"]},
311
+ {"path": "x.png", "targets": ["other"]},
312
+ ]
313
+ dataset = FolderDataset(root, records, ["bus", "car"], 8, cells=16, negative_weight=0.2)
314
+ _, _, cell_weights, labels, weights = dataset[0]
315
+ self.assertEqual(labels.tolist(), [1, 0])
316
+ self.assertEqual([round(w, 3) for w in weights.tolist()], [1, 0.2])
317
+ self.assertEqual(cell_weights.sum().item(), 0)
318
+ self.assertEqual(tuple(cell_weights.shape), (2, 16))
319
+ _, _, _, labels, weights = dataset[1]
320
+ self.assertEqual((labels.tolist(), weights.tolist()), ([0, 0], [1, 1]))
321
+
322
+ def test_answer_key_items_supervise_only_the_queried_target(self):
323
+ with tempfile.TemporaryDirectory() as root:
324
+ directory = Path(root) / "example"
325
+ directory.mkdir()
326
+ for name in ["full_images.png"] + [f"tile_{i}.png" for i in range(16)]:
327
+ Image.new("RGB", (16, 16), "blue").save(directory / name)
328
+ records = [{"id": "example", "tiles": 16, "target": "car", "answers": [0, 15]}]
329
+ grids = SupervisedGrids(GridDataset(root, records, ["bus", "car"], 16), 16)
330
+ _, labels, weights, _, any_weights = grids[0]
331
+ self.assertEqual(weights.sum(1).tolist(), [0, 16])
332
+ self.assertEqual(labels[1].nonzero().flatten().tolist(), [0, 15])
333
+ self.assertEqual(any_weights.sum().item(), 0)
334
+ tiles = SupervisedGrids(GridDataset(root, records, ["bus", "car"], 16, tiles=True), 1)
335
+ self.assertEqual(
336
+ (tiles[15][1].tolist(), tiles[15][2].tolist()), ([[0], [1]], [[0], [1]])
337
+ )
338
+
339
+ def test_partial_loss_matches_old_loss_and_ignores_unknowns(self):
340
+ logits = torch.randn(2, 3, 16, requires_grad=True)
341
+ labels, weights = torch.zeros(2, 3, 16), torch.zeros(2, 3, 16)
342
+ labels[0, 1, :4], weights[0, 1], weights[1, 2] = 1, 1, 1
343
+ zero = torch.zeros(2, 3)
344
+ loss, count = partial_loss(logits, labels, weights, zero, zero)
345
+ expected = torch.nn.functional.binary_cross_entropy_with_logits(
346
+ select_target(logits, torch.tensor([1, 2])), labels[[0, 1], [1, 2]]
347
+ )
348
+ self.assertTrue(torch.allclose(loss, expected))
349
+ self.assertEqual(count.item(), 32)
350
+ loss.backward()
351
+ self.assertTrue(
352
+ torch.equal(
353
+ (logits.grad != 0).any(-1),
354
+ torch.tensor([[False, True, False], [False, False, True]]),
355
+ )
356
+ )
357
+
358
+ def test_image_level_label_trains_only_the_strongest_cell(self):
359
+ logits = torch.zeros(1, 2, 16)
360
+ logits[0, 0, 5] = 2
361
+ logits.requires_grad_()
362
+ empty = torch.zeros(1, 2, 16)
363
+ loss, _ = partial_loss(
364
+ logits, empty, empty, torch.tensor([[1.0, 0.0]]), torch.tensor([[1.0, 0.0]])
365
+ )
366
+ loss.backward()
367
+ self.assertEqual(logits.grad.nonzero().tolist(), [[0, 0, 5]])
368
+
369
+ def test_tile_backbone_initializes_grid_model(self):
370
+ tile_model, grid_model = (
371
+ GridModel(9, 3, pretrained=False),
372
+ GridModel(16, 5, pretrained=False),
373
+ )
374
+ transfer_backbone(grid_model, tile_model.state_dict())
375
+ for name, value in grid_model.backbone.state_dict().items():
376
+ self.assertTrue(torch.equal(value, tile_model.backbone.state_dict()[name]), name)
377
+
378
+ def test_torch_free_preprocessing_matches_training(self):
379
+ try:
380
+ from predict_onnx import preprocess
381
+ except ImportError:
382
+ self.skipTest("onnxruntime is not installed (uv sync --group export)")
383
+ image = Image.effect_mandelbrot((97, 97), (-2, -1.5, 1, 1.5), 50).convert("RGB")
384
+ expected = transform(64)(image).numpy()
385
+ self.assertLess(abs(preprocess(image, 64) - expected).max(), 1e-5)
386
+
387
+
388
+ class LabeledLayoutTests(unittest.TestCase):
389
+ def test_invalid_metadata_and_sam_files_are_skipped(self):
390
+ from data import scan
391
+
392
+ with tempfile.TemporaryDirectory() as root:
393
+ self.make(root, "valid", "3x3", [0])
394
+ self.make(root, "bad-target", "3x3", [0])
395
+ self.make(root, "bad-metadata", "3x3", [0])
396
+ self.make(root, "bad-sam", "4x4", [0])
397
+ (Path(root) / "bad-target" / "metadata.json").write_text(
398
+ json.dumps({"target": None, "grid": "3x3", "correct_answers": [0]})
399
+ )
400
+ (Path(root) / "bad-metadata" / "metadata.json").write_text("[]")
401
+ (Path(root) / "bad-sam" / "sam.json").write_text("{}")
402
+ records, skipped = scan(root, workers=2, sam=True)
403
+ self.assertEqual([record["id"] for record in records], ["valid"])
404
+ self.assertEqual(
405
+ skipped,
406
+ {
407
+ "invalid target": 1,
408
+ "invalid metadata.json": 1,
409
+ "invalid sam.json": 1,
410
+ },
411
+ )
412
+
413
+ def test_folder_preparation_excludes_tiles_from_labeled_holdouts(self):
414
+ from data import grid_boxes, read_rgb, scan
415
+
416
+ with tempfile.TemporaryDirectory() as temporary:
417
+ root = Path(temporary)
418
+ data = root / "data"
419
+ data.mkdir()
420
+ self.make(data, "holdout", "3x3", [0])
421
+ records, _ = scan(data, workers=2)
422
+ records[0]["split"] = "test"
423
+ manifest = root / "split.json"
424
+ manifest.write_text(json.dumps({"root": str(data), "records": records}))
425
+ folder = root / "folders" / "bus"
426
+ folder.mkdir(parents=True)
427
+ image = read_rgb(data / "holdout" / "image.jpg")
428
+ image.crop(grid_boxes(*image.size, 9)[0]).save(folder / "reused.png")
429
+ Image.effect_mandelbrot((100, 100), (-2, -1.5, 1, 1.5), 50).save(folder / "new.png")
430
+ prepared, summary = prepare_folders(
431
+ root / "folders",
432
+ manifest,
433
+ root / "out",
434
+ workers=2,
435
+ )
436
+ self.assertEqual(summary["dropped_matching_old_heldout"], 1)
437
+ self.assertEqual([record["path"] for record in prepared["records"]], ["bus/new.png"])
438
+
439
+ def make(self, root, name, grid, answers=None, uncertain=(), colors=None, size=300):
440
+ folder = Path(root) / name
441
+ folder.mkdir()
442
+ n = 3 if grid == "3x3" else 4
443
+ image = Image.new("RGB", (size, size))
444
+ for i, color in enumerate(colors or [(i * 20, 0, 0) for i in range(n * n)]):
445
+ r, c = divmod(i, n)
446
+ image.paste(
447
+ color, (c * size // n, r * size // n, (c + 1) * size // n, (r + 1) * size // n)
448
+ )
449
+ image.save(folder / "image.jpg", quality=100)
450
+ info = {"target": "buses", "grid": grid}
451
+ if answers is not None:
452
+ info.update(correct_answers=answers, uncertain_cells=list(uncertain))
453
+ (folder / "metadata.json").write_text(json.dumps(info))
454
+
455
+ def test_labeled_items_are_scanned_and_unlabeled_skipped(self):
456
+ from data import scan
457
+
458
+ with tempfile.TemporaryDirectory() as root:
459
+ self.make(root, "a", "3x3", [1, 4], [4])
460
+ self.make(root, "b", "4x4", [5], size=450)
461
+ self.make(root, "c", "3x3")
462
+ records, skipped = scan(root, workers=2)
463
+ self.assertEqual(
464
+ [(r["id"], r["tiles"], r["target"], r["answers"], r["uncertain"]) for r in records],
465
+ [("a", 9, "bus", [1, 4], [4]), ("b", 16, "bus", [5], [])],
466
+ )
467
+ self.assertEqual(skipped, {"not labeled": 1})
468
+ self.assertEqual(len(records[0]["hashes"]), 10)
469
+
470
+ def test_tiles_come_from_the_single_image_and_uncertain_cells_are_ignored(self):
471
+ from data import scan
472
+
473
+ with tempfile.TemporaryDirectory() as root:
474
+ colors = [(250, 0, 0), (0, 250, 0), (0, 0, 250)] + [(0, 0, 0)] * 6
475
+ self.make(root, "a", "3x3", [1], [2], colors=colors)
476
+ self.make(root, "b", "4x4", [5, 6], [6], size=450)
477
+ records, _ = scan(root, workers=2)
478
+ tiles = GridDataset(root, [records[0]], ["bus"], 8, tiles=True)
479
+ self.assertEqual(len(tiles), 9)
480
+ self.assertGreater(
481
+ tiles[1][0][1].mean().item(), tiles[1][0][0].mean().item()
482
+ ) # green tile
483
+ items = SupervisedGrids(tiles, 1)
484
+ self.assertEqual(items[1][1].tolist(), [[1.0]])
485
+ self.assertEqual(items[2][2].sum().item(), 0) # uncertain tile: no weight
486
+ self.assertEqual(items[0][2].sum().item(), 1)
487
+ grid = SupervisedGrids(GridDataset(root, [records[1]], ["bus"], 32), 16)
488
+ _, labels, weights, _, _ = grid[0]
489
+ self.assertEqual(labels[0].nonzero().flatten().tolist(), [5, 6])
490
+ self.assertEqual(weights[0].tolist(), [1.0] * 6 + [0.0] + [1.0] * 9)
491
+ kept = SupervisedGrids(
492
+ GridDataset(root, [records[1]], ["bus"], 32), 16, keep_uncertain=True
493
+ )
494
+ self.assertEqual(kept[0][2].sum().item(), 16)
495
+
496
+ def test_sam_labels_replace_4x4_answers_only(self):
497
+ from data import scan
498
+
499
+ with tempfile.TemporaryDirectory() as root:
500
+ self.make(root, "a", "3x3", [1, 4], [4])
501
+ self.make(root, "b", "4x4", [5], [6], size=450)
502
+ self.make(root, "c", "4x4", size=450) # Qwen never labeled it; SAM did
503
+ self.make(root, "d", "4x4", [2], size=450) # no sam.json
504
+ for name, cells in (("b", [5, 6, 9]), ("c", [0])):
505
+ (Path(root) / name / "sam.json").write_text(
506
+ json.dumps({"model": "facebook/sam3", "correct_answers": cells})
507
+ )
508
+ records, skipped = scan(root, workers=2, sam=True)
509
+ self.assertEqual(
510
+ [(r["id"], r["answers"], r["uncertain"], r["label_source"]) for r in records],
511
+ [
512
+ ("a", [1, 4], [4], None),
513
+ ("b", [5, 6, 9], [], "facebook/sam3:sam"),
514
+ ("c", [0], [], "facebook/sam3:sam"),
515
+ ],
516
+ )
517
+ self.assertEqual(skipped, {"no sam.json": 1})
518
+ records, _ = scan(root, workers=2)
519
+ self.assertEqual([r["answers"] for r in records], [[1, 4], [5], [2]])
520
+
521
+ def test_reviewed_grids_are_held_out_with_their_reviewed_answers(self):
522
+ from data import prepare
523
+
524
+ with tempfile.TemporaryDirectory() as root, tempfile.TemporaryDirectory() as out:
525
+ for i in range(20):
526
+ # g01 is a copy of the reviewed g00, so it must not reach training.
527
+ j = 0 if i == 1 else i
528
+ colors = [((j * 37 + k * 11) % 256, (k * 23) % 256, j % 256) for k in range(9)]
529
+ self.make(root, f"g{i:02d}", "3x3", [0], colors=colors)
530
+ key = Path(out) / "key.json"
531
+ key.write_text(json.dumps({"items": {"g00": {"answers": [0, 8]}}}))
532
+ manifest, counts = prepare(root, out, workers=2, review_keys=[key])
533
+ by_id = {r["id"]: r for r in manifest["records"]}
534
+ self.assertEqual(
535
+ (by_id["g00"]["split"], by_id["g00"]["answers"], by_id["g00"]["labeler_answers"]),
536
+ ("review", [0, 8], [0]),
537
+ )
538
+ self.assertNotIn("g01", by_id)
539
+ self.assertEqual(counts["dropped_sharing_images_with_review"], 1)
540
+ self.assertNotIn(
541
+ "review", {r["split"] for r in manifest["records"] if r["id"] != "g00"}
542
+ )
543
+
544
+ def test_flip_mirrors_4x4_cells_and_uncertain_cells(self):
545
+ import random
546
+
547
+ from data import scan
548
+
549
+ with tempfile.TemporaryDirectory() as root:
550
+ colors = [(250, 0, 0)] + [(0, 0, 0)] * 15
551
+ self.make(root, "b", "4x4", [0, 5], [1], colors=colors, size=448)
552
+ records, _ = scan(root, workers=2)
553
+ grids = GridDataset(root, records, ["bus"], 32)
554
+ plain = SupervisedGrids(grids, 16)[0]
555
+ seed = next(
556
+ s for s in range(50) if random.Random(s).random() < 0.5
557
+ ) # a seed whose first draw flips
558
+ random.seed(seed)
559
+ flipped = SupervisedGrids(grids, 16, flip=True)[0]
560
+ _, labels, weights, _, _ = flipped
561
+ self.assertEqual(labels[0].nonzero().flatten().tolist(), [3, 6])
562
+ self.assertEqual(
563
+ weights[0].tolist(), [1.0] * 2 + [0.0] + [1.0] * 13
564
+ ) # uncertain 1 -> 2
565
+ self.assertTrue(torch.equal(flipped[0], plain[0].flip(-1)))
566
+
567
+ def test_reused_tiles_keep_grids_in_one_split(self):
568
+ from data import scan
569
+
570
+ with tempfile.TemporaryDirectory() as root:
571
+ for i in range(40):
572
+ colors = [((i * 37 + k * 11) % 256, (k * 23) % 256, i % 256) for k in range(9)]
573
+ if i in (0, 1):
574
+ colors[4] = (255, 255, 255) # the same photo reused in two grids
575
+ self.make(root, f"g{i:02d}", "3x3", [0], colors=colors)
576
+ records, _ = scan(root, workers=2)
577
+ split_records(records, 42)
578
+ self.assertEqual(records[0]["split"], records[1]["split"])
579
+
580
+
581
+ class LayoutTests(unittest.TestCase):
582
+ def test_folder_metadata_takes_priority_over_image_size(self):
583
+ from train import layout
584
+
585
+ with tempfile.TemporaryDirectory() as temporary:
586
+ root = Path(temporary)
587
+ Image.new("RGB", (300, 300)).save(root / "image.jpg")
588
+ (root / "metadata.json").write_text(json.dumps({"grid": "4x4"}))
589
+ self.assertEqual(layout(root), 16)
590
+
591
+ def test_layout_from_size_or_seams(self):
592
+ from train import layout
593
+
594
+ with tempfile.TemporaryDirectory() as root:
595
+ root = Path(root)
596
+ Image.linear_gradient("L").convert("RGB").resize((300, 300)).save(root / "a.png")
597
+ Image.linear_gradient("L").convert("RGB").resize((450, 450)).save(root / "b.png")
598
+ tiles = Image.new("RGB", (600, 600))
599
+ for i in range(9):
600
+ tiles.paste(
601
+ (i * 28, 255 - i * 28, (i * 90) % 256),
602
+ ((i % 3) * 200, (i // 3) * 200, (i % 3 + 1) * 200, (i // 3 + 1) * 200),
603
+ )
604
+ tiles.save(root / "c.png")
605
+ Image.linear_gradient("L").convert("RGB").resize((600, 600)).save(root / "d.png")
606
+ self.assertEqual([layout(root / f"{n}.png") for n in "abcd"], [9, 16, 9, 16])
607
+
608
+
609
+ if __name__ == "__main__":
610
+ unittest.main()
train.py ADDED
@@ -0,0 +1,1108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Prepare, train, evaluate, and predict. See README.md for commands."""
2
+
3
+ import argparse
4
+ import json
5
+ import os
6
+ import random
7
+ import time
8
+ from pathlib import Path
9
+
10
+ # Keep downloaded weights with the project, not in a global cache.
11
+ os.environ.setdefault("HF_HOME", str(Path(".cache/huggingface").resolve()))
12
+
13
+ import numpy as np
14
+ import torch
15
+ from torch import nn
16
+ from torch.utils.data import ConcatDataset, DataLoader, RandomSampler, WeightedRandomSampler
17
+
18
+ from data import (
19
+ BACKGROUND,
20
+ IMAGE_NAMES,
21
+ FolderDataset,
22
+ GridDataset,
23
+ SupervisedGrids,
24
+ grid_boxes,
25
+ prepare,
26
+ prepare_folders,
27
+ prepare_jsonl,
28
+ read_rgb,
29
+ record_image_path,
30
+ target_name,
31
+ transform,
32
+ )
33
+ from models import BACKBONE, GridModel, select_target, transfer_backbone
34
+
35
+
36
+ def save_json(path, value):
37
+ Path(path).write_text(json.dumps(value, indent=2) + "\n")
38
+
39
+
40
+ def device_for(name):
41
+ if name == "auto":
42
+ name = (
43
+ "cuda"
44
+ if torch.cuda.is_available()
45
+ else "mps"
46
+ if torch.backends.mps.is_available()
47
+ else "cpu"
48
+ )
49
+ if name == "mps" and not torch.backends.mps.is_available():
50
+ raise RuntimeError(
51
+ "MPS is unavailable. Run in a terminal with Apple GPU access; use --device cpu only intentionally."
52
+ )
53
+ if name == "cuda" and not torch.cuda.is_available():
54
+ raise RuntimeError("CUDA is unavailable on this machine.")
55
+ return torch.device(name)
56
+
57
+
58
+ def empty_cache(device):
59
+ if device.type == "mps":
60
+ torch.mps.empty_cache()
61
+ elif device.type == "cuda":
62
+ torch.cuda.empty_cache()
63
+
64
+
65
+ def seed_everything(seed):
66
+ random.seed(seed)
67
+ np.random.seed(seed)
68
+ torch.manual_seed(seed)
69
+ torch.set_num_threads(4)
70
+
71
+
72
+ def records_for(manifest, tiles, split):
73
+ return [r for r in manifest["records"] if r["tiles"] == tiles and r["split"] == split]
74
+
75
+
76
+ def auxiliary_records(manifest, targets, split):
77
+ return [r for r in records_for(manifest, 16, split) if r["target"] in targets]
78
+
79
+
80
+ def folder_records(folders, kind, split):
81
+ return (
82
+ [r for r in folders["records"] if r["kind"] == kind and r["split"] == split]
83
+ if folders
84
+ else []
85
+ )
86
+
87
+
88
+ def cell_logits(model, images):
89
+ """Logits shaped (batch, classes, cells); a separate tile is one cell."""
90
+ output = model(images)
91
+ return output.unsqueeze(-1) if model.tiles == 9 else output.flatten(2)
92
+
93
+
94
+ def partial_loss(logits, labels, weights, any_labels, any_weights):
95
+ """Weighted BCE on known cells, plus presence anywhere (max over cells) for image-level labels."""
96
+ cells = nn.functional.binary_cross_entropy_with_logits(
97
+ logits, labels, weight=weights, reduction="sum"
98
+ )
99
+ anywhere = nn.functional.binary_cross_entropy_with_logits(
100
+ logits.amax(-1), any_labels, weight=any_weights, reduction="sum"
101
+ )
102
+ total = weights.sum() + any_weights.sum()
103
+ return (cells + anywhere) / total.clamp(min=1), total
104
+
105
+
106
+ @torch.inference_mode()
107
+ def evaluate_folders(model, loader, device):
108
+ model.eval()
109
+ loss, total, probabilities, labels, weights = 0.0, 0.0, [], [], []
110
+ for images, *supervision in loader:
111
+ supervision = [x.to(device) for x in supervision]
112
+ logits = cell_logits(model, images.to(device)).float()
113
+ batch_loss, batch_total = partial_loss(logits, *supervision)
114
+ loss += batch_loss.item() * batch_total.item()
115
+ total += batch_total.item()
116
+ probabilities.append(logits.amax(-1).sigmoid().cpu())
117
+ labels.append(supervision[2].cpu())
118
+ weights.append(supervision[3].cpu())
119
+ return (
120
+ loss / max(total, 1),
121
+ torch.cat(probabilities),
122
+ torch.cat(labels).bool(),
123
+ torch.cat(weights),
124
+ )
125
+
126
+
127
+ def folder_report(probabilities, labels, weights, classes, threshold):
128
+ """Single-label folder images: recall per class, and how often each class fires on other classes' images."""
129
+ predicted = probabilities >= threshold
130
+ background = (weights == 1).all(1) & ~labels.any(1)
131
+ report = {
132
+ "threshold": threshold,
133
+ "images": len(labels),
134
+ "per_class": {},
135
+ "background_images": int(background.sum()),
136
+ "background_any_selected": float(predicted[background].any(1).float().mean())
137
+ if background.any()
138
+ else None,
139
+ }
140
+ for i, name in enumerate(classes):
141
+ positive, others = labels[:, i], ~labels[:, i] & labels.any(1)
142
+ report["per_class"][name] = {
143
+ "positives": int(positive.sum()),
144
+ "recall": float(predicted[positive, i].float().mean()) if positive.any() else None,
145
+ "fires_on_other_classes": float(predicted[others, i].float().mean())
146
+ if others.any()
147
+ else None,
148
+ }
149
+ return report
150
+
151
+
152
+ def thresholds_for(checkpoint, targets):
153
+ return torch.tensor(
154
+ [
155
+ checkpoint.get("thresholds", {}).get(
156
+ checkpoint["classes"][int(i)], checkpoint["threshold"]
157
+ )
158
+ for i in targets
159
+ ]
160
+ ).unsqueeze(1)
161
+
162
+
163
+ def grid_logits(model, images, targets):
164
+ if model.tiles == 9:
165
+ batch, cells = images.shape[:2]
166
+ logits = model(images.flatten(0, 1)).reshape(batch, cells, -1).transpose(1, 2)
167
+ else:
168
+ logits = model(images).flatten(2)
169
+ selected = select_target(logits, targets)
170
+ # Presence in any enlarged subregion counts as presence in the tile.
171
+ for target_id in getattr(model, "crop_target_ids", []):
172
+ mask = targets == target_id
173
+ if not mask.any():
174
+ continue
175
+ tile_images = images[mask].flatten(0, 1)
176
+ height, width = tile_images.shape[-2:]
177
+ crop_h, crop_w = height // 2, width // 2
178
+ positions = [
179
+ (0, 0),
180
+ (0, width - crop_w),
181
+ (height - crop_h, 0),
182
+ (height - crop_h, width - crop_w),
183
+ ((height - crop_h) // 2, (width - crop_w) // 2),
184
+ ]
185
+ scores = selected[mask]
186
+ for top, left in positions:
187
+ crop = tile_images[:, :, top : top + crop_h, left : left + crop_w]
188
+ crop = nn.functional.interpolate(
189
+ crop, size=(height, width), mode="bilinear", align_corners=False
190
+ )
191
+ enlarged = model(crop)[:, target_id].reshape_as(scores)
192
+ scores = torch.maximum(scores, enlarged)
193
+ selected[mask] = scores
194
+ return selected
195
+
196
+
197
+ @torch.inference_mode()
198
+ def evaluate_loader(model, loader, device):
199
+ model.eval()
200
+ predictions, labels, targets = [], [], []
201
+ loss, total = 0.0, 0
202
+ for images, target, truth in loader:
203
+ logits = grid_logits(model, images.to(device), target.to(device))
204
+ loss += nn.functional.binary_cross_entropy_with_logits(
205
+ logits, truth.to(device), reduction="sum"
206
+ ).item()
207
+ total += truth.numel()
208
+ predictions.append(logits.sigmoid().cpu())
209
+ labels.append(truth)
210
+ targets.append(target)
211
+ if not total:
212
+ raise ValueError("Evaluation split is empty")
213
+ return loss / total, torch.cat(predictions), torch.cat(labels).bool(), torch.cat(targets)
214
+
215
+
216
+ def metrics(probabilities, labels, threshold):
217
+ predicted = probabilities >= threshold
218
+ tp = int((predicted & labels).sum())
219
+ fp = int((predicted & ~labels).sum())
220
+ fn = int((~predicted & labels).sum())
221
+ return {
222
+ "grids": len(labels),
223
+ "exact_grid_accuracy": float((predicted == labels).all(1).float().mean()),
224
+ "cell_accuracy": float((predicted == labels).float().mean()),
225
+ "cell_precision": tp / max(tp + fp, 1),
226
+ "cell_recall": tp / max(tp + fn, 1),
227
+ "cell_f1": 2 * tp / max(2 * tp + fp + fn, 1),
228
+ "tp": tp,
229
+ "fp": fp,
230
+ "fn": fn,
231
+ }
232
+
233
+
234
+ def choose_threshold(probabilities, labels):
235
+ candidates = [round(0.1 + 0.025 * i, 3) for i in range(33)]
236
+
237
+ def rank(threshold):
238
+ result = metrics(probabilities, labels, threshold)
239
+ return result["exact_grid_accuracy"], result["cell_f1"], -abs(threshold - 0.5)
240
+
241
+ return max(candidates, key=rank)
242
+
243
+
244
+ def load_checkpoint(path, device):
245
+ checkpoint = torch.load(path, map_location="cpu", weights_only=True)
246
+ model = GridModel(
247
+ checkpoint["tiles"],
248
+ len(checkpoint["classes"]),
249
+ pretrained=False,
250
+ backbone=checkpoint.get("backbone", BACKBONE),
251
+ )
252
+ model.load_state_dict(checkpoint["model"])
253
+ model.crop_target_ids = [
254
+ checkpoint["classes"].index(name) for name in checkpoint.get("crop_targets", [])
255
+ ]
256
+ if model.crop_target_ids and checkpoint["tiles"] != 9:
257
+ raise ValueError("Crop views are supported only by tile classifiers")
258
+ return model.to(device).eval(), checkpoint
259
+
260
+
261
+ def train_one(args, tiles, manifest, folders=None):
262
+ seed_everything(args.seed)
263
+ device = device_for(args.device)
264
+ output = Path(args.output) / f"grid{tiles}"
265
+ if (output / "best.pt").exists():
266
+ raise ValueError(
267
+ f"{output}/best.pt already exists. Choose a new --output to preserve this run."
268
+ )
269
+ output.mkdir(parents=True, exist_ok=True)
270
+ cells = 1 if tiles == 9 else 16
271
+ kind = "tile" if tiles == 9 else "full"
272
+ classes = sorted(
273
+ {r["target"] for r in manifest["records"] if r["tiles"] == tiles}
274
+ | {t for r in folder_records(folders, kind, "train") for t in r["targets"]} - {BACKGROUND}
275
+ )
276
+ aux_targets = sorted({target_name(name) for name in args.aux_targets})
277
+ if aux_targets and (tiles != 9 or not set(aux_targets) <= set(classes)):
278
+ raise ValueError("Auxiliary targets must be existing classes in a 9-tile model")
279
+ # 4x4 photos are 450 px; 448 keeps small slivers at a size divisible by the stride.
280
+ size = args.size or (224 if tiles == 9 else 448)
281
+ backbone_lr = args.backbone_lr if args.backbone_lr is not None else 0.0001
282
+ finetune_head_lr = args.finetune_head_lr if args.finetune_head_lr is not None else 0.0003
283
+ config = {
284
+ "tiles": tiles,
285
+ "classes": classes,
286
+ "size": size,
287
+ "backbone": args.backbone,
288
+ "seed": args.seed,
289
+ "batch_size": args.batch_size,
290
+ "device": str(device),
291
+ "precision": "bfloat16 autocast" if args.amp else "float32",
292
+ "frozen_epochs": args.frozen_epochs,
293
+ "finetune_epochs": args.epochs,
294
+ "patience": args.patience,
295
+ "optimizer": "AdamW",
296
+ "weight_decay": 0.0001,
297
+ "head_lr": args.head_lr,
298
+ "finetune_head_lr": finetune_head_lr,
299
+ "finetune_backbone_lr": backbone_lr,
300
+ "warm_start": args.warm_start,
301
+ "init_backbone": args.init_backbone,
302
+ "aux_targets": aux_targets,
303
+ "folders": args.folders,
304
+ "folder_kind": kind if folders else None,
305
+ "folder_negative_weight": args.negative_weight if folders else None,
306
+ "old_fraction": args.old_fraction if folders else None,
307
+ "epoch_size": args.epoch_size,
308
+ "keep_uncertain": args.keep_uncertain,
309
+ "train_batchnorm": not args.freeze_bn,
310
+ "amp": args.amp,
311
+ "selection": (
312
+ "mean of answer-key and folder validation loss"
313
+ if folders
314
+ else "mean of main and auxiliary validation loss"
315
+ if aux_targets
316
+ else "main validation loss"
317
+ ),
318
+ "torch": str(torch.__version__),
319
+ }
320
+ if args.amp and device.type != "cuda":
321
+ raise ValueError("--amp is supported only with --device cuda")
322
+ if device.type == "cuda":
323
+ torch.backends.cudnn.benchmark = True
324
+ torch.set_float32_matmul_precision("high")
325
+ save_json(output / "config.json", config)
326
+ save_json(output / "classes.json", classes)
327
+ save_json(output / "split.json", manifest)
328
+ training_records = records_for(manifest, tiles, "train") + auxiliary_records(
329
+ manifest, aux_targets, "train"
330
+ )
331
+ training = SupervisedGrids(
332
+ GridDataset(
333
+ manifest["root"],
334
+ training_records,
335
+ classes,
336
+ size,
337
+ training=True,
338
+ tiles=tiles == 9,
339
+ include_full_images=bool(aux_targets),
340
+ ),
341
+ cells,
342
+ keep_uncertain=args.keep_uncertain,
343
+ flip=not args.no_flip,
344
+ )
345
+ validation = GridDataset(manifest["root"], records_for(manifest, tiles, "val"), classes, size)
346
+ workers = {
347
+ "num_workers": args.workers,
348
+ "persistent_workers": args.workers > 0,
349
+ "pin_memory": device.type == "cuda",
350
+ }
351
+ sampler, folder_loader = None, None
352
+ if folders:
353
+ folder_training = FolderDataset(
354
+ folders["root"],
355
+ folder_records(folders, kind, "train"),
356
+ classes,
357
+ size,
358
+ cells,
359
+ training=True,
360
+ negative_weight=args.negative_weight,
361
+ )
362
+ folder_validation = FolderDataset(
363
+ folders["root"],
364
+ folder_records(folders, kind, "val"),
365
+ classes,
366
+ size,
367
+ cells,
368
+ negative_weight=args.negative_weight,
369
+ )
370
+ # Square-root class balancing: rare classes are seen more often without memorizing a few images.
371
+ counts = {}
372
+ for record in folder_training.records:
373
+ counts[record["targets"][0]] = counts.get(record["targets"][0], 0) + 1
374
+ folder_weights = torch.tensor(
375
+ [counts[r["targets"][0]] ** -0.5 for r in folder_training.records]
376
+ )
377
+ folder_weights *= (1 - args.old_fraction) / folder_weights.sum()
378
+ old_weights = torch.full((len(training),), args.old_fraction / len(training))
379
+ sampler = WeightedRandomSampler(
380
+ torch.cat([old_weights, folder_weights]).double(),
381
+ args.epoch_size or len(training) + len(folder_training),
382
+ generator=torch.Generator().manual_seed(args.seed),
383
+ )
384
+ training = ConcatDataset([training, folder_training])
385
+ folder_loader = DataLoader(folder_validation, batch_size=64, **workers)
386
+ elif args.epoch_size:
387
+ sampler = RandomSampler(
388
+ training,
389
+ replacement=True,
390
+ num_samples=args.epoch_size,
391
+ generator=torch.Generator().manual_seed(args.seed),
392
+ )
393
+ train_loader = DataLoader(
394
+ training, batch_size=args.batch_size, shuffle=sampler is None, sampler=sampler, **workers
395
+ )
396
+ val_loader = DataLoader(validation, batch_size=16, **workers)
397
+ aux_loader = None
398
+ if aux_targets:
399
+ aux_validation = GridDataset(
400
+ manifest["root"],
401
+ auxiliary_records(manifest, aux_targets, "val"),
402
+ classes,
403
+ size,
404
+ tile_grids=True,
405
+ )
406
+ if not len(aux_validation):
407
+ raise ValueError("Auxiliary targets need validation examples")
408
+ aux_loader = DataLoader(aux_validation, batch_size=2)
409
+ if args.warm_start:
410
+ model, initial = load_checkpoint(args.warm_start, device)
411
+ config["backbone"] = initial.get("backbone", BACKBONE)
412
+ save_json(output / "config.json", config)
413
+ if initial["tiles"] != tiles or initial["classes"] != classes or initial["size"] != size:
414
+ raise ValueError("Warm-start model must match task, classes, and image size")
415
+ else:
416
+ model = GridModel(tiles, len(classes), backbone=args.backbone).to(device)
417
+ if args.init_backbone:
418
+ source = torch.load(args.init_backbone, map_location="cpu", weights_only=True)
419
+ print(
420
+ f"grid{tiles}: copied {transfer_backbone(model, source['model'])} backbone tensors "
421
+ f"from {args.init_backbone}",
422
+ flush=True,
423
+ )
424
+ model.freeze_backbone(True)
425
+ optimizer = torch.optim.AdamW(model.head.parameters(), lr=args.head_lr, weight_decay=0.0001)
426
+ history, best, stale = [], float("inf"), 0
427
+ start = time.perf_counter()
428
+ print(
429
+ f"grid{tiles}: {len(train_loader.dataset)} training items ({len(train_loader.sampler)} per epoch), "
430
+ f"{len(validation)} validation grids, device={device}",
431
+ flush=True,
432
+ )
433
+ for epoch in range(args.frozen_epochs + args.epochs):
434
+ frozen = epoch < args.frozen_epochs
435
+ if epoch == args.frozen_epochs:
436
+ model.freeze_backbone(False)
437
+ optimizer = torch.optim.AdamW(
438
+ [
439
+ {"params": model.backbone.parameters(), "lr": backbone_lr},
440
+ {"params": model.head.parameters(), "lr": finetune_head_lr},
441
+ ],
442
+ weight_decay=0.0001,
443
+ )
444
+ stale = 0
445
+ model.train()
446
+ if args.freeze_bn:
447
+ # Keep pretrained batch-normalization statistics (for small datasets).
448
+ model.backbone.eval()
449
+ total_loss, supervised = 0.0, 0.0
450
+ epoch_start = time.perf_counter()
451
+ for images, *supervision in train_loader:
452
+ images = images.to(device, non_blocking=True)
453
+ supervision = [x.to(device, non_blocking=True) for x in supervision]
454
+ optimizer.zero_grad(set_to_none=True)
455
+ with torch.autocast("cuda", dtype=torch.bfloat16, enabled=args.amp):
456
+ logits = cell_logits(model, images)
457
+ loss, count = partial_loss(logits.float(), *supervision)
458
+ loss.backward()
459
+ optimizer.step()
460
+ total_loss += loss.item() * count.item()
461
+ supervised += count.item()
462
+ val_loss, probabilities, truth, _ = evaluate_loader(model, val_loader, device)
463
+ aux_loss = evaluate_loader(model, aux_loader, device)[0] if aux_loader is not None else None
464
+ folder_loss = (
465
+ evaluate_folders(model, folder_loader, device)[0] if folder_loader is not None else None
466
+ )
467
+ extra = [x for x in (aux_loss, folder_loss) if x is not None]
468
+ selection_loss = sum([val_loss] + extra) / (1 + len(extra))
469
+ row = {
470
+ "epoch": epoch + 1,
471
+ "phase": "head" if frozen else "finetune",
472
+ "train_loss": total_loss / max(supervised, 1),
473
+ "val_loss": val_loss,
474
+ "aux_val_loss": aux_loss,
475
+ "folder_val_loss": folder_loss,
476
+ "selection_loss": selection_loss,
477
+ "val_exact_at_0.5": metrics(probabilities, truth, 0.5)["exact_grid_accuracy"],
478
+ "seconds": time.perf_counter() - epoch_start,
479
+ }
480
+ history.append(row)
481
+ save_json(output / "history.json", history)
482
+ print(json.dumps({"grid": tiles, **row}), flush=True)
483
+ if selection_loss < best:
484
+ best, stale = selection_loss, 0
485
+ torch.save(
486
+ {
487
+ **config,
488
+ "epoch": epoch + 1,
489
+ "val_loss": val_loss,
490
+ "selection_loss": selection_loss,
491
+ "model": {k: v.detach().cpu().clone() for k, v in model.state_dict().items()},
492
+ },
493
+ output / "best.pt",
494
+ )
495
+ elif not frozen:
496
+ stale += 1
497
+ if not frozen and stale >= args.patience:
498
+ break
499
+ elapsed = time.perf_counter() - start
500
+ del optimizer, model
501
+ empty_cache(device)
502
+ model, checkpoint = load_checkpoint(output / "best.pt", device)
503
+ _, probabilities, truth, val_targets = evaluate_loader(model, val_loader, device)
504
+ threshold = choose_threshold(probabilities, truth)
505
+ checkpoint["threshold"] = threshold
506
+ checkpoint["thresholds"] = {}
507
+ if aux_loader is not None:
508
+ _, aux_probabilities, aux_truth, aux_ids = evaluate_loader(model, aux_loader, device)
509
+ for name in aux_targets:
510
+ mask = aux_ids == classes.index(name)
511
+ if mask.sum() >= 3:
512
+ checkpoint["thresholds"][name] = choose_threshold(
513
+ aux_probabilities[mask], aux_truth[mask]
514
+ )
515
+ save_json(
516
+ output / "aux_validation.json",
517
+ {
518
+ "source": "4x4 crops; proxy only for 3x3 performance",
519
+ "thresholds": checkpoint["thresholds"],
520
+ **metrics(aux_probabilities, aux_truth, thresholds_for(checkpoint, aux_ids)),
521
+ },
522
+ )
523
+ if folder_loader is not None:
524
+ _, folder_probabilities, folder_truth, folder_weights = evaluate_folders(
525
+ model, folder_loader, device
526
+ )
527
+ save_json(
528
+ output / "folder_validation.json",
529
+ {
530
+ "source": f"held-out {kind} images from {args.folders}; single-label, so 'fires_on_other_classes' "
531
+ "includes images where that target is genuinely visible",
532
+ **folder_report(
533
+ folder_probabilities, folder_truth, folder_weights, classes, threshold
534
+ ),
535
+ },
536
+ )
537
+ checkpoint["training_seconds"] = elapsed
538
+ torch.save(checkpoint, output / "best.pt")
539
+ save_json(
540
+ output / "validation.json",
541
+ {
542
+ "threshold": threshold,
543
+ "thresholds": checkpoint["thresholds"],
544
+ **metrics(probabilities, truth, thresholds_for(checkpoint, val_targets)),
545
+ },
546
+ )
547
+ print(
548
+ f"grid{tiles}: saved best epoch {checkpoint['epoch']}; threshold={threshold}; training={elapsed:.1f}s",
549
+ flush=True,
550
+ )
551
+
552
+
553
+ def synchronize(device):
554
+ if device.type == "mps":
555
+ torch.mps.synchronize()
556
+ elif device.type == "cuda":
557
+ torch.cuda.synchronize()
558
+
559
+
560
+ def calibrate_crops(args):
561
+ """Enable enlarged views only after a validation-only comparison."""
562
+ device = device_for(args.device)
563
+ seed_everything(42)
564
+ model, checkpoint = load_checkpoint(args.checkpoint, device)
565
+ name = target_name(args.target)
566
+ if checkpoint["tiles"] != 9 or name not in checkpoint["classes"]:
567
+ raise ValueError("Choose a supported target in a tile classifier")
568
+ if name in checkpoint.get("crop_targets", []):
569
+ raise ValueError("Crop views are already enabled for this target")
570
+ directory = Path(args.checkpoint).parent
571
+ manifest = json.loads((directory / "split.json").read_text())
572
+ records = auxiliary_records(manifest, [name], "val")
573
+ if len(records) < 3:
574
+ raise ValueError("Need at least three auxiliary validation grids")
575
+ dataset = GridDataset(
576
+ manifest["root"], records, checkpoint["classes"], checkpoint["size"], tile_grids=True
577
+ )
578
+ loader = DataLoader(dataset, batch_size=2)
579
+ _, probabilities, truth, _ = evaluate_loader(model, loader, device)
580
+ old_threshold = checkpoint.get("thresholds", {}).get(name, checkpoint["threshold"])
581
+ before = metrics(probabilities, truth, old_threshold)
582
+ model.crop_target_ids.append(checkpoint["classes"].index(name))
583
+ _, probabilities, truth, _ = evaluate_loader(model, loader, device)
584
+ cutoff = choose_threshold(probabilities, truth)
585
+ after = metrics(probabilities, truth, cutoff)
586
+ accepted = (
587
+ after["exact_grid_accuracy"] >= before["exact_grid_accuracy"]
588
+ and after["cell_f1"] > before["cell_f1"]
589
+ )
590
+ report = {
591
+ "target": name,
592
+ "source": "4x4 validation crops; not 3x3 test data",
593
+ "views": "full tile plus center and four corner half-size crops",
594
+ "before": {"threshold": old_threshold, **before},
595
+ "after": {"threshold": cutoff, **after},
596
+ "accepted": accepted,
597
+ }
598
+ if accepted:
599
+ backup = directory / "pre_crop_best.pt"
600
+ if backup.exists():
601
+ raise ValueError(f"Refusing to overwrite {backup}")
602
+ torch.save(checkpoint, backup)
603
+ checkpoint.setdefault("crop_targets", []).append(name)
604
+ checkpoint.setdefault("thresholds", {})[name] = cutoff
605
+ torch.save(checkpoint, args.checkpoint)
606
+ save_json(directory / "crop_calibration.json", report)
607
+ print(json.dumps(report, indent=2))
608
+
609
+
610
+ @torch.inference_mode()
611
+ def benchmark(model, dataset, device):
612
+ images, target, _ = dataset[0]
613
+ images, target = images.unsqueeze(0).to(device), torch.tensor([target], device=device)
614
+ for _ in range(5):
615
+ grid_logits(model, images, target)
616
+ synchronize(device)
617
+ timings = []
618
+ for _ in range(30):
619
+ start = time.perf_counter()
620
+ grid_logits(model, images, target).sigmoid().cpu()
621
+ synchronize(device)
622
+ timings.append((time.perf_counter() - start) * 1000)
623
+ return {
624
+ "median_ms": float(np.median(timings)),
625
+ "p95_ms": float(np.percentile(timings, 95)),
626
+ "scope": "one grid, warm model, includes output transfer; excludes image loading and preprocessing",
627
+ "device": str(device),
628
+ "iterations": len(timings),
629
+ }
630
+
631
+
632
+ def evaluate(args):
633
+ device = device_for(args.device)
634
+ seed_everything(42)
635
+ model, checkpoint = load_checkpoint(args.checkpoint, device)
636
+ directory = Path(args.checkpoint).parent
637
+ manifest = json.loads((directory / "split.json").read_text())
638
+ records = records_for(manifest, checkpoint["tiles"], args.split)
639
+ if not records:
640
+ raise ValueError(
641
+ f"No {args.split} grids in this manifest"
642
+ + (" (run prepare with --review)" if args.split == "review" else "")
643
+ )
644
+ dataset = GridDataset(
645
+ args.data or manifest["root"], records, checkpoint["classes"], checkpoint["size"]
646
+ )
647
+ loss, probabilities, truth, targets = evaluate_loader(
648
+ model, DataLoader(dataset, batch_size=4), device
649
+ )
650
+ threshold = thresholds_for(checkpoint, targets)
651
+ report = {
652
+ "split": args.split,
653
+ "epoch": checkpoint["epoch"],
654
+ "threshold": checkpoint["threshold"],
655
+ "thresholds": checkpoint.get("thresholds", {}),
656
+ "loss": loss,
657
+ "training_seconds": checkpoint["training_seconds"],
658
+ "overall": metrics(probabilities, truth, threshold),
659
+ "per_class": {},
660
+ }
661
+ if args.split == "review":
662
+ # Same grids, answered by the labeler whose output the model was trained on.
663
+ right = [r["labeler_answers"] == r["answers"] for r in records if "labeler_answers" in r]
664
+ report["labeler_exact_grid_accuracy"] = sum(right) / len(right) if right else None
665
+ for i, name in enumerate(checkpoint["classes"]):
666
+ mask = targets == i
667
+ support = {
668
+ split: len(
669
+ [
670
+ r
671
+ for r in records_for(manifest, checkpoint["tiles"], split)
672
+ if r["target"] == name
673
+ ]
674
+ )
675
+ for split in ("train", "val", "test", "review")
676
+ }
677
+ report["per_class"][name] = {
678
+ "support": support,
679
+ "metrics": metrics(probabilities[mask], truth[mask], threshold[mask])
680
+ if mask.any()
681
+ else None,
682
+ }
683
+ report["latency"] = benchmark(model, dataset, device)
684
+ save_json(directory / f"{args.split}_metrics.json", report)
685
+ save_json(
686
+ directory / f"{args.split}_predictions.json",
687
+ [
688
+ {
689
+ "id": r["id"],
690
+ "target": r["target"],
691
+ "answers": r["answers"],
692
+ "selected_cells": (p >= cutoff).nonzero().flatten().tolist(),
693
+ "probabilities": p.tolist(),
694
+ }
695
+ for r, p, cutoff in zip(records, probabilities, threshold)
696
+ ],
697
+ )
698
+ print(json.dumps(report, indent=2))
699
+
700
+
701
+ @torch.inference_mode()
702
+ def predict(args):
703
+ device = device_for(args.device)
704
+ model, checkpoint = load_checkpoint(args.checkpoint, device)
705
+ name = target_name(args.target)
706
+ if name not in checkpoint["classes"]:
707
+ raise ValueError(f"Unknown target {name!r}; supported: {checkpoint['classes']}")
708
+ preprocess = transform(checkpoint["size"])
709
+ image = read_rgb(image_file(args.image))
710
+ if checkpoint["tiles"] == 9:
711
+ images = torch.stack([preprocess(image.crop(box)) for box in grid_boxes(*image.size, 9)])
712
+ else:
713
+ images = preprocess(image)
714
+ target = torch.tensor([checkpoint["classes"].index(name)], device=device)
715
+ probabilities = grid_logits(model, images.unsqueeze(0).to(device), target).sigmoid().cpu()[0]
716
+ cutoff = checkpoint.get("thresholds", {}).get(name, checkpoint["threshold"])
717
+ print(
718
+ json.dumps(
719
+ {
720
+ "target": name,
721
+ "threshold": cutoff,
722
+ "selected_cells": (probabilities >= cutoff).nonzero().flatten().tolist(),
723
+ "probabilities": probabilities.tolist(),
724
+ },
725
+ indent=2,
726
+ )
727
+ )
728
+
729
+
730
+ def export(args):
731
+ """ONNX fp32 plus calibrated int8, checked against PyTorch on the old test grids."""
732
+ import onnx
733
+ from onnxruntime.quantization import (
734
+ CalibrationDataReader,
735
+ CalibrationMethod,
736
+ QuantFormat,
737
+ QuantType,
738
+ quantize_static,
739
+ )
740
+ from onnxruntime.quantization.shape_inference import quant_pre_process
741
+
742
+ from predict_onnx import GridPredictor
743
+
744
+ seed_everything(42)
745
+ model, checkpoint = load_checkpoint(args.checkpoint, torch.device("cpu"))
746
+ if model.crop_target_ids:
747
+ raise ValueError("Enlarged crop views are not supported by the ONNX export")
748
+ tiles, size = checkpoint["tiles"], checkpoint["size"]
749
+ directory = Path(args.checkpoint).parent
750
+ output = Path(args.output or directory / "onnx")
751
+ output.mkdir(parents=True, exist_ok=True)
752
+ manifest = json.loads((directory / "split.json").read_text())
753
+ root = Path(args.data or manifest["root"])
754
+
755
+ class Probabilities(nn.Module):
756
+ def __init__(self):
757
+ super().__init__()
758
+ self.model = model
759
+
760
+ def forward(self, images):
761
+ logits = self.model(images)
762
+ return (logits if tiles == 9 else logits.flatten(2)).sigmoid()
763
+
764
+ info = {
765
+ "tiles": tiles,
766
+ "size": size,
767
+ "classes": checkpoint["classes"],
768
+ "threshold": checkpoint["threshold"],
769
+ "thresholds": checkpoint.get("thresholds", {}),
770
+ "epoch": checkpoint["epoch"],
771
+ }
772
+
773
+ def with_metadata(path):
774
+ exported = onnx.load(path)
775
+ del exported.metadata_props[:]
776
+ exported.metadata_props.add(key="grid_vision", value=json.dumps(info))
777
+ onnx.save(exported, path)
778
+
779
+ fp32, prepared, int8 = (
780
+ output / f"grid{tiles}.onnx",
781
+ output / f"grid{tiles}.pre.onnx",
782
+ output / f"grid{tiles}.int8.onnx",
783
+ )
784
+ for path in (fp32, int8):
785
+ if path.exists():
786
+ raise ValueError(f"{path} already exists. Choose a new --output.")
787
+ torch.onnx.export(
788
+ Probabilities().eval(),
789
+ torch.zeros(9 if tiles == 9 else 1, 3, size, size),
790
+ fp32,
791
+ input_names=["images"],
792
+ output_names=["probabilities"],
793
+ opset_version=17,
794
+ dynamic_axes={"images": {0: "batch"}, "probabilities": {0: "batch"}},
795
+ dynamo=False,
796
+ )
797
+ with_metadata(fp32)
798
+ reference = GridPredictor(fp32)
799
+ calibration = random.Random(0).sample(
800
+ records_for(manifest, tiles, "train"),
801
+ min(args.calibration_grids, len(records_for(manifest, tiles, "train"))),
802
+ )
803
+
804
+ class Calibration(CalibrationDataReader):
805
+ def __init__(self):
806
+ self.batches = iter(reference.inputs(record_image_path(root, r)) for r in calibration)
807
+
808
+ def get_next(self):
809
+ batch = next(self.batches, None)
810
+ return None if batch is None else {"images": batch}
811
+
812
+ quant_pre_process(str(fp32), str(prepared))
813
+ # Percentile ranges and full-precision first/last layers changed the fewest baseline decisions.
814
+ layers = [
815
+ n.name for n in onnx.load(prepared).graph.node if n.op_type in ("Conv", "Gemm", "MatMul")
816
+ ]
817
+ quantize_static(
818
+ str(prepared),
819
+ str(int8),
820
+ Calibration(),
821
+ quant_format=QuantFormat.QDQ,
822
+ per_channel=True,
823
+ activation_type=QuantType.QUInt8,
824
+ weight_type=QuantType.QInt8,
825
+ calibrate_method=CalibrationMethod.Percentile,
826
+ nodes_to_exclude=[layers[0], layers[-1]],
827
+ )
828
+ prepared.unlink()
829
+ with_metadata(int8)
830
+
831
+ records = records_for(manifest, tiles, "test")
832
+ variants = {"fp32": GridPredictor(fp32), "int8": GridPredictor(int8)}
833
+ probabilities = {name: [] for name in ["torch", *variants]}
834
+ labels, cutoffs = [], []
835
+ with torch.inference_mode():
836
+ for record in records:
837
+ inputs = reference.inputs(record_image_path(root, record))
838
+ target = checkpoint["classes"].index(record["target"])
839
+ scores = Probabilities()(torch.from_numpy(inputs)).numpy()
840
+ probabilities["torch"].append(scores.T[target] if tiles == 9 else scores[0, target])
841
+ for name, predictor in variants.items():
842
+ probabilities[name].append(predictor.probabilities(inputs)[target])
843
+ labels.append([i in record["answers"] for i in range(record["tiles"])])
844
+ cutoffs.append(info["thresholds"].get(record["target"], info["threshold"]))
845
+ labels, cutoffs = torch.tensor(labels), torch.tensor(cutoffs).unsqueeze(1)
846
+ tensors = {name: torch.tensor(np.array(values)) for name, values in probabilities.items()}
847
+ selected = {name: values >= cutoffs for name, values in tensors.items()}
848
+ report = {
849
+ "checkpoint": str(args.checkpoint),
850
+ "test_grids": len(records),
851
+ "preprocessing": "predict_onnx.preprocess (Pillow + numpy) for every variant",
852
+ }
853
+ for name, path in [("fp32", fp32), ("int8", int8)]:
854
+ timings = {}
855
+ sample = reference.inputs(record_image_path(root, records[0]))
856
+ for threads in (1, 4):
857
+ predictor = GridPredictor(path, threads)
858
+ for _ in range(5):
859
+ predictor.probabilities(sample)
860
+ runs = []
861
+ for _ in range(50):
862
+ start = time.perf_counter()
863
+ predictor.probabilities(sample)
864
+ runs.append((time.perf_counter() - start) * 1000)
865
+ timings[f"{threads}_thread_median_ms"] = float(np.median(runs))
866
+ report[name] = {
867
+ "file": str(path),
868
+ "megabytes": path.stat().st_size / 1e6,
869
+ "max_abs_difference_from_torch": float((tensors[name] - tensors["torch"]).abs().max()),
870
+ "grids_with_different_selection": int(
871
+ (selected[name] != selected["torch"]).any(1).sum()
872
+ ),
873
+ "test": metrics(tensors[name], labels, cutoffs),
874
+ "cpu_latency_per_grid": {
875
+ **timings,
876
+ "scope": "one grid on this machine's CPU, excludes image loading",
877
+ },
878
+ }
879
+ report["torch_test"] = metrics(tensors["torch"], labels, cutoffs)
880
+ save_json(output / "export.json", report)
881
+ print(json.dumps(report, indent=2))
882
+
883
+
884
+ def seam_ratio(image, parts=3):
885
+ """Separate tiles have sharp seams at the 1/parts lines; one continuous photo usually does not."""
886
+ pixels = np.asarray(image.convert("L"), dtype=np.float32)
887
+ height, width = pixels.shape
888
+ dx, dy = np.abs(np.diff(pixels, axis=1)).mean(0), np.abs(np.diff(pixels, axis=0)).mean(1)
889
+
890
+ def seams(differences, length):
891
+ return max(
892
+ differences[max(0, round(length * j / parts) - 2) : round(length * j / parts) + 1].max()
893
+ for j in range(1, parts)
894
+ )
895
+
896
+ return min(seams(dx, width), seams(dy, height)) / ((np.median(dx) + np.median(dy)) / 2 + 1e-6)
897
+
898
+
899
+ def image_file(source):
900
+ """A challenge image, or the image inside a dataset item folder."""
901
+ source = Path(source)
902
+ if source.is_dir():
903
+ found = next((source / name for name in IMAGE_NAMES if (source / name).exists()), None)
904
+ if found is None:
905
+ raise ValueError(f"No image in {source}")
906
+ return found
907
+ return source
908
+
909
+
910
+ def layout(source):
911
+ """9 or 16 tiles for a challenge image or item folder (300 px = 3x3, 450 px = 4x4)."""
912
+ metadata = Path(source) / "metadata.json"
913
+ if Path(source).is_dir() and metadata.is_file():
914
+ grid = json.loads(metadata.read_text()).get("grid")
915
+ if grid in ("3x3", "4x4"):
916
+ return 9 if grid == "3x3" else 16
917
+ image = read_rgb(image_file(source))
918
+ side = max(image.size)
919
+ if abs(side - 300) <= 30:
920
+ return 9
921
+ if abs(side - 450) <= 45:
922
+ return 16
923
+ return 9 if seam_ratio(image) >= 3 else 16
924
+
925
+
926
+ def solve(args):
927
+ """Detect the layout and use the matching grid model."""
928
+ args.checkpoint = args.grid9 if layout(args.image) == 9 else args.grid16
929
+ predict(args)
930
+
931
+
932
+ def main():
933
+ parser = argparse.ArgumentParser(description=__doc__)
934
+ commands = parser.add_subparsers(dest="command", required=True)
935
+ prep = commands.add_parser("prepare")
936
+ prep.add_argument(
937
+ "--data",
938
+ required=True,
939
+ help="Folder of labeled <item>/{image.jpg, metadata.json} (or answer-key) folders",
940
+ )
941
+ prep.add_argument("--output", default="runs")
942
+ prep.add_argument("--seed", type=int, default=42)
943
+ prep.add_argument(
944
+ "--workers", type=int, default=os.cpu_count() or 1, help="Processes for scanning images"
945
+ )
946
+ prep.add_argument(
947
+ "--sam",
948
+ action="store_true",
949
+ help="Take 4x4 answers from <item>/sam.json (SAM 3) instead of metadata.json",
950
+ )
951
+ prep.add_argument(
952
+ "--review",
953
+ nargs="*",
954
+ default=[],
955
+ help="Reference answer files held out as a 'review' split",
956
+ )
957
+ prep_folders = commands.add_parser("prepare-folders", help="Ingest class-folder image datasets")
958
+ prep_folders.add_argument("--data", nargs="+", required=True, help="Class-folder datasets")
959
+ prep_folders.add_argument(
960
+ "--manifest", default="runs/split.json", help="Old split; its held-out images are excluded"
961
+ )
962
+ prep_folders.add_argument("--output", default="runs")
963
+ prep_folders.add_argument("--seed", type=int, default=42)
964
+ train = commands.add_parser("train")
965
+ train.add_argument("--manifest", default="runs/split.json")
966
+ train.add_argument("--output", default="runs/baseline")
967
+ train.add_argument("--tiles", choices=["9", "16", "both"], default="both")
968
+ train.add_argument("--device", choices=["auto", "cuda", "mps", "cpu"], default="auto")
969
+ train.add_argument("--batch-size", type=int, default=16)
970
+ train.add_argument("--frozen-epochs", type=int, default=3)
971
+ train.add_argument(
972
+ "--epochs", type=int, default=20, help="Maximum fine-tuning epochs after head training"
973
+ )
974
+ train.add_argument("--patience", type=int, default=5)
975
+ train.add_argument("--backbone-lr", type=float, help="Default: 1e-4")
976
+ train.add_argument("--finetune-head-lr", type=float, help="Default: 3e-4")
977
+ train.add_argument("--head-lr", type=float, default=0.001)
978
+ train.add_argument("--warm-start", help="Initialize from a compatible trained checkpoint")
979
+ train.add_argument(
980
+ "--aux-targets",
981
+ nargs="*",
982
+ default=[],
983
+ help="Use these targets' 4x4 crops to train a 9-tile classifier",
984
+ )
985
+ train.add_argument("--seed", type=int, default=42)
986
+ train.add_argument("--size", type=int, help="Input size. Default: 224 for 9 tiles, 448 for 16")
987
+ train.add_argument(
988
+ "--folders", help="Folder manifest from prepare-folders, e.g. runs/folders.json"
989
+ )
990
+ train.add_argument(
991
+ "--negative-weight",
992
+ type=float,
993
+ default=0.2,
994
+ help="Weight for assuming other targets are absent in a single-label folder image",
995
+ )
996
+ train.add_argument(
997
+ "--old-fraction", type=float, default=0.25, help="Share of samples from answer-key grids"
998
+ )
999
+ train.add_argument("--epoch-size", type=int, help="Training samples (tiles or grids) per epoch")
1000
+ train.add_argument(
1001
+ "--keep-uncertain",
1002
+ action="store_true",
1003
+ help="Also train on cells the labeler marked uncertain (ignored by default)",
1004
+ )
1005
+ train.add_argument(
1006
+ "--no-flip", action="store_true", help="Turn off random left-right mirroring"
1007
+ )
1008
+ train.add_argument(
1009
+ "--backbone",
1010
+ default=BACKBONE,
1011
+ help="Any timm model with a stride-16 stage, e.g. convnext_tiny.dinov3_lvd1689m",
1012
+ )
1013
+ train.add_argument(
1014
+ "--init-backbone", help="Copy backbone weights from another checkpoint, e.g. the 3x3 model"
1015
+ )
1016
+ train.add_argument(
1017
+ "--freeze-bn", action="store_true", help="Keep pretrained batch-normalization statistics"
1018
+ )
1019
+ train.add_argument(
1020
+ "--workers",
1021
+ type=int,
1022
+ default=min(16, os.cpu_count() or 1),
1023
+ help="DataLoader worker processes",
1024
+ )
1025
+ train.add_argument("--amp", action="store_true", help="bfloat16 autocast (CUDA only)")
1026
+ test = commands.add_parser("evaluate")
1027
+ test.add_argument("--checkpoint", required=True)
1028
+ test.add_argument(
1029
+ "--split",
1030
+ choices=["test", "review"],
1031
+ default="test",
1032
+ help="review: the reference grids held out by prepare --review",
1033
+ )
1034
+ test.add_argument("--data", help="Override dataset root if moved")
1035
+ test.add_argument("--device", choices=["auto", "cuda", "mps", "cpu"], default="auto")
1036
+ prediction = commands.add_parser("predict")
1037
+ prediction.add_argument("--checkpoint", required=True)
1038
+ prediction.add_argument("--image", required=True, help="Image file or example folder")
1039
+ prediction.add_argument("--target", required=True)
1040
+ prediction.add_argument("--device", choices=["auto", "cuda", "mps", "cpu"], default="auto")
1041
+ onnx_export = commands.add_parser(
1042
+ "export", help="ONNX fp32 and int8 for CPU inference without PyTorch"
1043
+ )
1044
+ onnx_export.add_argument("--checkpoint", required=True)
1045
+ onnx_export.add_argument("--output", help="Default: <checkpoint folder>/onnx")
1046
+ onnx_export.add_argument("--data", help="Override dataset root if moved")
1047
+ onnx_export.add_argument("--calibration-grids", type=int, default=100)
1048
+ solver = commands.add_parser("solve", help="Detect the layout and use the matching model")
1049
+ solver.add_argument("--image", required=True, help="Image file or example folder")
1050
+ solver.add_argument("--target", required=True)
1051
+ solver.add_argument("--grid9", default="runs/baseline/grid9/best.pt")
1052
+ solver.add_argument("--grid16", default="runs/baseline/grid16/best.pt")
1053
+ solver.add_argument("--device", choices=["auto", "cuda", "mps", "cpu"], default="cpu")
1054
+ crops = commands.add_parser("calibrate-crops")
1055
+ crops.add_argument("--checkpoint", required=True)
1056
+ crops.add_argument("--target", required=True)
1057
+ crops.add_argument("--device", choices=["auto", "cuda", "mps", "cpu"], default="auto")
1058
+ args = parser.parse_args()
1059
+ if args.command == "prepare":
1060
+ source = Path(args.data)
1061
+ if (source / "data" / "3x3").is_dir() or (source / "3x3").is_dir():
1062
+ if args.sam or args.review:
1063
+ parser.error("--sam and --review apply only to raw labeled folders")
1064
+ _, counts = prepare_jsonl(source, args.output)
1065
+ else:
1066
+ _, counts = prepare(args.data, args.output, args.seed, args.workers, args.sam, args.review)
1067
+ print(json.dumps(counts, indent=2))
1068
+ elif args.command == "prepare-folders":
1069
+ _, summary = prepare_folders(args.data, args.manifest, args.output, args.seed)
1070
+ print(json.dumps(summary, indent=2))
1071
+ elif args.command == "train":
1072
+ if min(args.batch_size, args.epochs, args.patience) < 1 or args.frozen_epochs < 0:
1073
+ parser.error(
1074
+ "Batch size, epochs, and patience must be positive; frozen epochs cannot be negative"
1075
+ )
1076
+ if any(
1077
+ lr is not None and (not np.isfinite(lr) or lr <= 0)
1078
+ for lr in (args.backbone_lr, args.finetune_head_lr, args.head_lr)
1079
+ ):
1080
+ parser.error("Learning rates must be finite and positive")
1081
+ if not 0 < args.old_fraction < 1 or args.negative_weight < 0 or args.workers < 0:
1082
+ parser.error("--old-fraction must be in (0, 1); weights and workers cannot be negative")
1083
+ if not np.isfinite(args.negative_weight):
1084
+ parser.error("--negative-weight must be finite")
1085
+ if (args.epoch_size is not None and args.epoch_size < 1) or (
1086
+ args.size is not None and args.size < 1
1087
+ ):
1088
+ parser.error("--epoch-size and --size must be positive")
1089
+ manifest = json.loads(Path(args.manifest).read_text())
1090
+ folders = json.loads(Path(args.folders).read_text()) if args.folders else None
1091
+ for tiles in [9, 16] if args.tiles == "both" else [int(args.tiles)]:
1092
+ train_one(args, tiles, manifest, folders)
1093
+ elif args.command == "evaluate":
1094
+ evaluate(args)
1095
+ elif args.command == "export":
1096
+ if args.calibration_grids < 1:
1097
+ parser.error("--calibration-grids must be positive")
1098
+ export(args)
1099
+ elif args.command == "solve":
1100
+ solve(args)
1101
+ elif args.command == "calibrate-crops":
1102
+ calibrate_crops(args)
1103
+ else:
1104
+ predict(args)
1105
+
1106
+
1107
+ if __name__ == "__main__":
1108
+ main()
uv.lock ADDED
@@ -0,0 +1,659 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version = 1
2
+ revision = 5
3
+ requires-python = "==3.11.*"
4
+
5
+ [[package]]
6
+ name = "certifi"
7
+ version = "2026.7.22"
8
+ source = { registry = "https://pypi.org/simple" }
9
+ sdist = { url = "https://files.pythonhosted.org/packages/a3/c2/24167ea9858356b47a87a50d39908bfdb72ceeefe0041586e704e5376b3a/certifi-2026.7.22.tar.gz", hash = "sha256:741e2c3b351ddf169a738da9f2c048608ff7f2c5cc02f1ebc6b118bb090d5d55", size = 138112, upload-time = "2026-07-22T03:35:12.644Z" }
10
+ wheels = [
11
+ { url = "https://files.pythonhosted.org/packages/0b/a7/71ac2cff56fec219ed242bb11b8efb69fcc4bec75db06fb7bfe35de520e6/certifi-2026.7.22-py3-none-any.whl", hash = "sha256:62f22742b58a1a33014a2b6b706588a8d7e2a88ae7bd1a6ebe8c992928483775", size = 136983, upload-time = "2026-07-22T03:35:11.276Z" },
12
+ ]
13
+
14
+ [[package]]
15
+ name = "charset-normalizer"
16
+ version = "3.5.2"
17
+ source = { registry = "https://pypi.org/simple" }
18
+ sdist = { url = "https://files.pythonhosted.org/packages/33/1c/f41d4e74c28ab327ff3acd36053f7ea506c55872d7a90b0fa71aa3ab0c89/charset_normalizer-3.5.2.tar.gz", hash = "sha256:39de2a259fc954455c57274dc94c79d5842774e1247a016aff30bc0efed0f4ef", size = 172659, upload-time = "2026-09-30T04:39:23.398Z" }
19
+ wheels = [
20
+ { url = "https://files.pythonhosted.org/packages/22/67/6a0b94a7960d5e1b5eacd2fb529f3fccc47db4644f7f0a7cfdcfc3be578a/charset_normalizer-3.5.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:3d21b8b13c7592db2ac5e544a6d83187b995257472b0c9e8351b6d507ae37ed6", size = 370642, upload-time = "2026-09-30T04:35:06.91Z" },
21
+ { url = "https://files.pythonhosted.org/packages/fb/94/01009e13b94041599004edf32e56e382c24e570f60f79bab8efe45cfe1eb/charset_normalizer-3.5.2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:d760fe2a4d7c3b226cb9026d6a842868d52a7901bd98420e1baf14e80da85cf5", size = 259280, upload-time = "2026-09-30T04:35:08.448Z" },
22
+ { url = "https://files.pythonhosted.org/packages/66/85/3b5358f60a13210f0b67d3755c168ef758701b021e655d88d4da28554467/charset_normalizer-3.5.2-cp311-cp311-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:c9790464842f85f437dbbb54417eda1e0e6bfc52dd8d22d6fd1c994b73b2dc74", size = 245335, upload-time = "2026-09-30T04:35:10.104Z" },
23
+ { url = "https://files.pythonhosted.org/packages/74/75/77c1c479b09ecd751d1e767b251ea5c14d4d50ff757bf404afab2692f600/charset_normalizer-3.5.2-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:4685902cf26edf013ed7a3da0f426ebba7a00ebb9541386d835afbf002c11cab", size = 291707, upload-time = "2026-09-30T04:35:11.575Z" },
24
+ { url = "https://files.pythonhosted.org/packages/0b/0d/363f78cacb70f58f15f4b083961bbd9d292f335d3f5c66fc4f1cfe69cb90/charset_normalizer-3.5.2-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:4495c5002a7b28557e7e222e77e0b661183e432b7d6d2e788101e3f240e05b8c", size = 286747, upload-time = "2026-09-30T04:35:13.022Z" },
25
+ { url = "https://files.pythonhosted.org/packages/e4/ed/cf505d3011ffceb12c2067a7a5d3cfe92b875d4d44bb0ff0d69375e2c184/charset_normalizer-3.5.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:211d5a3eb6af8f513b8d4ca19a8c1b7accab1b5f0d3175f9826b03c1a920dc1f", size = 269972, upload-time = "2026-09-30T04:35:14.606Z" },
26
+ { url = "https://files.pythonhosted.org/packages/15/d8/f0a93a431d170e7ca681d4f6650fee3de934d18560e474e7267eb4b0f987/charset_normalizer-3.5.2-cp311-cp311-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:ef4fcbf3327382cd4c9f540babd61248208af7b93eec4de397b4d5f58a09e288", size = 269339, upload-time = "2026-09-30T04:35:16.087Z" },
27
+ { url = "https://files.pythonhosted.org/packages/86/bd/9b2bd1c5b7af02462c9752d33994834ff972a96b4c483eefde9e594488e2/charset_normalizer-3.5.2-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:bd16aabe4a02a297c23417aa17ac6299dbd8c49f673bcd645b4929b11f5a4400", size = 261683, upload-time = "2026-09-30T04:35:17.488Z" },
28
+ { url = "https://files.pythonhosted.org/packages/76/a5/cac540ab0fd61f3fec88ad3dbb64509e71424593d73cfdfff5ab3e4db279/charset_normalizer-3.5.2-cp311-cp311-musllinux_1_2_armv7l.whl", hash = "sha256:fb9e68df06293761f9fe66ade60a9bc6d0f5e42b8acf2939a9158af86ab0e5bd", size = 248143, upload-time = "2026-09-30T04:35:18.849Z" },
29
+ { url = "https://files.pythonhosted.org/packages/71/7a/ff467301deef2089fad87f72df9e000a26a78fec7acbb18e1999371b8369/charset_normalizer-3.5.2-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:59f63901b0031c3136cf64704dcb21de0bbae62ce2c9529bc39d27665463de37", size = 292358, upload-time = "2026-09-30T04:35:20.326Z" },
30
+ { url = "https://files.pythonhosted.org/packages/ad/77/22d7e785d1e210afc2e2f58600dd1799d17a35665faf84383f002826c5f8/charset_normalizer-3.5.2-cp311-cp311-musllinux_1_2_riscv64.whl", hash = "sha256:304d5463e65a35d7bb0850550e0780395395f6fcf452f04db7d5ca7cecc425ac", size = 268766, upload-time = "2026-09-30T04:35:21.72Z" },
31
+ { url = "https://files.pythonhosted.org/packages/ae/91/e8e946267f1c2d9e2bd651726e2fbd2addf02c4d36cea5069e32ca9d7bb5/charset_normalizer-3.5.2-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:9cf9b1a857e25c4baceeb3624e92a56df3668f398c4acba74e174d81fb4d1d3a", size = 287432, upload-time = "2026-09-30T04:35:23.273Z" },
32
+ { url = "https://files.pythonhosted.org/packages/4e/88/7561d8a88d555e7df6623abe7c0070b4baf47549b9408783a2ae0a1a6cf7/charset_normalizer-3.5.2-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:114e4d0c92d618409ed82a99e22b5c5e768fe995f2973f78265f4524f49d4640", size = 272470, upload-time = "2026-09-30T04:35:24.655Z" },
33
+ { url = "https://files.pythonhosted.org/packages/35/7e/578c702301ec036f01455f30744a08d2b42f6ab35b9b2d4bf8cae0ef2a80/charset_normalizer-3.5.2-cp311-cp311-win32.whl", hash = "sha256:2625388c6c754520c37abaf3b41eb34d1cc4a373f457898f08606c8e362b891d", size = 186688, upload-time = "2026-09-30T04:35:26.225Z" },
34
+ { url = "https://files.pythonhosted.org/packages/e8/fc/fdf8cf52ff21cd5bf158f20978991cf985325842f74283eb6df26c8a39d8/charset_normalizer-3.5.2-cp311-cp311-win_amd64.whl", hash = "sha256:87e50a3e7cb90af586b6c5faf23e302a970415ac73bd7bd90a515a04b427ef96", size = 214932, upload-time = "2026-09-30T04:35:27.796Z" },
35
+ { url = "https://files.pythonhosted.org/packages/97/66/3e45a506d8110b632541faf9a9470185aa9878f1ed44020f31346c1c5e5b/charset_normalizer-3.5.2-cp311-cp311-win_arm64.whl", hash = "sha256:254eb48b9fa5ee9898a3c445825a1f340fe53712a098904b39b0bddba8ea3cb1", size = 202828, upload-time = "2026-09-30T04:35:29.259Z" },
36
+ { url = "https://files.pythonhosted.org/packages/8c/ab/176fbfd5b64939c55d652366aa5b9ef1d767af207a3aa6ebeb0d226c484d/charset_normalizer-3.5.2-cp37-abi3-macosx_10_9_universal2.whl", hash = "sha256:4275811936e2f06feff5e598fb42a1b7ae852da8e39605211892b56b81a34efd", size = 331815, upload-time = "2026-09-30T04:38:26.216Z" },
37
+ { url = "https://files.pythonhosted.org/packages/7e/84/371eac6b30bdbcbf2d632a1a01809103459216fcaae61b8b8d922c1bfb8a/charset_normalizer-3.5.2-cp37-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:1c50fe28bbc2ced33386f298650d91218076c05420e6cbd790b913adc41659e7", size = 253276, upload-time = "2026-09-30T04:38:28.032Z" },
38
+ { url = "https://files.pythonhosted.org/packages/43/6f/c4fbae58febff71709c51bc7e18fdfa55341dc382704740f9f0cbf03817b/charset_normalizer-3.5.2-cp37-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:d19fbd981a488e22cd04883659ca6b08f50b5974f9fd7c95655ef6a043e5893f", size = 241239, upload-time = "2026-09-30T04:38:29.732Z" },
39
+ { url = "https://files.pythonhosted.org/packages/61/71/458c3f42164a07d0c5210798e9e704b39e540a6793b05aba67f3a35243a9/charset_normalizer-3.5.2-cp37-abi3-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:0fed1d06615f022ee3b13caf5e8b180cfea32bb2c5aded8a9d44277afc040f93", size = 231121, upload-time = "2026-09-30T04:38:31.462Z" },
40
+ { url = "https://files.pythonhosted.org/packages/09/54/ab9e89367076f6331bb6c65c4bf14a5361fa5191cb6561bf534f18504e1b/charset_normalizer-3.5.2-cp37-abi3-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:838dcc90063569a0448120554591a1d6c4a4ffe11babf048908793154ab86ade", size = 260350, upload-time = "2026-09-30T04:38:33.239Z" },
41
+ { url = "https://files.pythonhosted.org/packages/7c/c1/061431ecc688d9d76602502cb57cc01e691e682c18f1beb45f9673b5bbd2/charset_normalizer-3.5.2-cp37-abi3-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:2ce45c6627b22c47e390bc91a41c3d13032192e699fa0bea96e9671b373d69b0", size = 255430, upload-time = "2026-09-30T04:38:34.865Z" },
42
+ { url = "https://files.pythonhosted.org/packages/8d/1f/20c8949f0676f7ab811abdeb7f4d7f1cbc6e61ff20bef08b44edeb092bc8/charset_normalizer-3.5.2-cp37-abi3-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:0774bf9bf620249fee3e0b8b9fd3065de213be30f3aa94ce2494b3b638949e26", size = 250612, upload-time = "2026-09-30T04:38:36.649Z" },
43
+ { url = "https://files.pythonhosted.org/packages/2b/9e/46f2fa4c431fc98c4ae76a8cb5bdca54e0341e3cfc3fcfd8e82740250818/charset_normalizer-3.5.2-cp37-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:1db38f4c5496827c1a501846d64d14c3b80c7e6714e406cd7dc36a9899fa1011", size = 242083, upload-time = "2026-09-30T04:38:38.26Z" },
44
+ { url = "https://files.pythonhosted.org/packages/bd/39/559be29a0c0f086e0bba6922babd38916cc5e0b58ced4de13ee01ea05508/charset_normalizer-3.5.2-cp37-abi3-musllinux_1_2_armv7l.whl", hash = "sha256:304d8e4d493af723536393eee0c689eb7813f4a474c8b479dee63f1fdd98f621", size = 232738, upload-time = "2026-09-30T04:38:39.81Z" },
45
+ { url = "https://files.pythonhosted.org/packages/ff/6c/387b0e4f756a282831c1d9fc6aeb6c51ca4507ca202767c8de15ce9b12e2/charset_normalizer-3.5.2-cp37-abi3-musllinux_1_2_ppc64le.whl", hash = "sha256:9b7f416ff0978e2f2249330527f0ad6fa02f4932e6199692d3b52da2048c19e4", size = 260703, upload-time = "2026-09-30T04:38:41.346Z" },
46
+ { url = "https://files.pythonhosted.org/packages/96/92/1fdf015f09ef449f50d3ac4b67c90887c9c318b727daa95cc4f866e6521d/charset_normalizer-3.5.2-cp37-abi3-musllinux_1_2_riscv64.whl", hash = "sha256:01077390b03f7988f11d700a2194e69b119741a86b1a638b1db88891e3eced8e", size = 247622, upload-time = "2026-09-30T04:38:42.937Z" },
47
+ { url = "https://files.pythonhosted.org/packages/dc/3c/8e7b8a5671ad5d433669fb2a76f1a0164df2d9b1718b0206bc2a16d840cc/charset_normalizer-3.5.2-cp37-abi3-musllinux_1_2_s390x.whl", hash = "sha256:7e841fb9010836c992c9f12fcbd43a831de93a5f726fc1ccd8ca1d0268c5014c", size = 257500, upload-time = "2026-09-30T04:38:44.604Z" },
48
+ { url = "https://files.pythonhosted.org/packages/b4/f0/45b579df5cabc1d5d53ea1cc35e8437d3ca768c0acccc7041517cb6fbb32/charset_normalizer-3.5.2-cp37-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:9cae88599c7219005d879f98e5ed53341e9a122af585e1091200358a3003d2a0", size = 255100, upload-time = "2026-09-30T04:38:46.289Z" },
49
+ { url = "https://files.pythonhosted.org/packages/31/68/fdec18a343f5fb3f310588dd478b09ac4799e0b187dbade3a8cd776f03ef/charset_normalizer-3.5.2-cp37-abi3-win32.whl", hash = "sha256:01b0c0d2262a9e28e8484a278c7e1b5d650e3ac8cf2683d2967e25899f208bdf", size = 174499, upload-time = "2026-09-30T04:38:47.999Z" },
50
+ { url = "https://files.pythonhosted.org/packages/9d/8a/b618149cc5207943a0242068d7a27897f56a62947b5a039085f2a22029f8/charset_normalizer-3.5.2-cp37-abi3-win_amd64.whl", hash = "sha256:9f56f72050826f63dcee7a7f55b0a77168cb3bfc553fd405e7f8f9ece75a4036", size = 200092, upload-time = "2026-09-30T04:38:49.707Z" },
51
+ { url = "https://files.pythonhosted.org/packages/03/cf/4c66866fa9e2b1c78e3c911516d1de497a677b7ac60f1eceda74ce777ca3/charset_normalizer-3.5.2-cp37-abi3-win_arm64.whl", hash = "sha256:40ab6bffa02ae10a0581e6c198be7d2d8ca5c2a0c64e4ed3465d766df457573e", size = 294363, upload-time = "2026-09-30T04:38:51.312Z" },
52
+ { url = "https://files.pythonhosted.org/packages/fc/ad/d07d7862a62ffa6d79d68074d14823243dd235a77c45262acbf6adeb28bf/charset_normalizer-3.5.2-py3-none-any.whl", hash = "sha256:b6b751274acb69d77b3323d6b7dbaa3c7fdfc1eb829b7eb61d262f32e1af9685", size = 68872, upload-time = "2026-09-30T04:39:21.828Z" },
53
+ ]
54
+
55
+ [[package]]
56
+ name = "rc1"
57
+ version = "0.1.0"
58
+ source = { virtual = "." }
59
+ dependencies = [
60
+ { name = "huggingface-hub" },
61
+ { name = "numpy" },
62
+ { name = "pillow" },
63
+ { name = "timm" },
64
+ { name = "torch" },
65
+ { name = "torchvision" },
66
+ ]
67
+
68
+ [package.dev-dependencies]
69
+ export = [
70
+ { name = "onnx" },
71
+ { name = "onnxruntime" },
72
+ ]
73
+
74
+ [package.metadata]
75
+ requires-dist = [
76
+ { name = "huggingface-hub", specifier = "==0.34.4" },
77
+ { name = "numpy", specifier = "==2.2.6" },
78
+ { name = "pillow", specifier = "==11.3.0" },
79
+ { name = "timm", specifier = "==1.0.20" },
80
+ { name = "torch", specifier = "==2.8.0" },
81
+ { name = "torchvision", specifier = "==0.23.0" },
82
+ ]
83
+
84
+ [package.metadata.requires-dev]
85
+ export = [
86
+ { name = "onnx", specifier = ">=1.23.2" },
87
+ { name = "onnxruntime", specifier = ">=1.30.0" },
88
+ ]
89
+
90
+ [[package]]
91
+ name = "colorama"
92
+ version = "0.4.6"
93
+ source = { registry = "https://pypi.org/simple" }
94
+ sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697, upload-time = "2022-10-25T02:36:22.414Z" }
95
+ wheels = [
96
+ { url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" },
97
+ ]
98
+
99
+ [[package]]
100
+ name = "filelock"
101
+ version = "4.0.12"
102
+ source = { registry = "https://pypi.org/simple" }
103
+ sdist = { url = "https://files.pythonhosted.org/packages/53/e4/34efcb869715cf299e47d1ac7b2624d2bcb6f2d3dffc2f0abe8417f65ab2/filelock-4.0.12.tar.gz", hash = "sha256:cf42711a7ac791818b299fab0332a088c65aeeefa36290de98db92c434303b0c", size = 253880, upload-time = "2026-10-05T13:17:43.677Z" }
104
+ wheels = [
105
+ { url = "https://files.pythonhosted.org/packages/da/a1/b047e1c486a2c66283633b7dbb73872ca16ca1ce6a426f70d4d037fc8e1c/filelock-4.0.12-py3-none-any.whl", hash = "sha256:5f17ee83ecee8a6f3e389c75822fb70a1c2f0506b99438a6dffa1d56793588c8", size = 111732, upload-time = "2026-10-05T13:17:42.361Z" },
106
+ ]
107
+
108
+ [[package]]
109
+ name = "flatbuffers"
110
+ version = "25.12.19"
111
+ source = { registry = "https://pypi.org/simple" }
112
+ wheels = [
113
+ { url = "https://files.pythonhosted.org/packages/e8/2d/d2a548598be01649e2d46231d151a6c56d10b964d94043a335ae56ea2d92/flatbuffers-25.12.19-py2.py3-none-any.whl", hash = "sha256:7634f50c427838bb021c2d66a3d1168e9d199b0607e6329399f04846d42e20b4", size = 26661, upload-time = "2025-12-19T23:16:13.622Z" },
114
+ ]
115
+
116
+ [[package]]
117
+ name = "fsspec"
118
+ version = "2026.9.0"
119
+ source = { registry = "https://pypi.org/simple" }
120
+ sdist = { url = "https://files.pythonhosted.org/packages/77/cd/9be253869fc42e764de7f3dedd6969af7d44ff9c3375214a3442a6f3fc08/fsspec-2026.9.0.tar.gz", hash = "sha256:0f08147951c8cb31d844c3547d631053b127863b60be04cf06e121333ee0e2fe", size = 333545, upload-time = "2026-09-18T17:50:42.825Z" }
121
+ wheels = [
122
+ { url = "https://files.pythonhosted.org/packages/6c/c0/a98505f18594f1bce828bb159cec0fcf9860562f1a2c85913409fc8f3d9e/fsspec-2026.9.0-py3-none-any.whl", hash = "sha256:8dd6e646e99ea382bd85f97a45e6b526a442d79423a7dc673f1e2756d05fcb5f", size = 221738, upload-time = "2026-09-18T17:50:41.341Z" },
123
+ ]
124
+
125
+ [[package]]
126
+ name = "hf-xet"
127
+ version = "1.6.0"
128
+ source = { registry = "https://pypi.org/simple" }
129
+ sdist = { url = "https://files.pythonhosted.org/packages/1b/ab/522a2ab67f27971a9d48ca666d4fca85ef7d5282d142e31fd087e27b1bbe/hf_xet-1.6.0.tar.gz", hash = "sha256:2e58454a340b3556dfa4972d5451aff4fba8dd42a236600ba1a1d2b1514f0fef", size = 920527, upload-time = "2026-08-03T22:33:13.243Z" }
130
+ wheels = [
131
+ { url = "https://files.pythonhosted.org/packages/a2/50/7afa2c9c787405864fc47a0d1bbc02c62e9101947ed43c1f43899fc7d91d/hf_xet-1.6.0-cp38-abi3-macosx_10_12_x86_64.whl", hash = "sha256:633dc0cd71d32da58ab8c03ad38e2fac452c15c2b0a2866ebf6ededfe0a5061d", size = 4071729, upload-time = "2026-08-03T22:33:00.721Z" },
132
+ { url = "https://files.pythonhosted.org/packages/4b/69/55b8dcf636142ae660fec1869fcac14c4da2e8412e14d6eee1523be77e9f/hf_xet-1.6.0-cp38-abi3-macosx_11_0_arm64.whl", hash = "sha256:f0906082d9932ae0c0057fa194041c22b4e2cdb46b2592ef3b91f020d62a081a", size = 3876287, upload-time = "2026-08-03T22:33:02.251Z" },
133
+ { url = "https://files.pythonhosted.org/packages/67/4e/a28359bf1c1ecf11eba22123168c138698f7cb576ac678f5a2e16cd5da08/hf_xet-1.6.0-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:d62671bb130879cef0ee4c9ebe47a14af6c66ec53e6d84dc15936e5ffdfac82f", size = 4464663, upload-time = "2026-08-03T22:33:03.802Z" },
134
+ { url = "https://files.pythonhosted.org/packages/9a/69/1f0cbc2fb22ae6082d094f743d1b8945a3f36f6089cb95f42b7ee348cda7/hf_xet-1.6.0-cp38-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:0e6e21fa3cdfcdcd76748564bf593870a5e013f47d97cf10aed63aa222cff5b7", size = 4262538, upload-time = "2026-08-03T22:33:05.287Z" },
135
+ { url = "https://files.pythonhosted.org/packages/d1/3a/4f4f2301ade26e404462d3336fa11f7958d914cabbabdd6e03c3c5d5658c/hf_xet-1.6.0-cp38-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:4fc74352a17015bd0ee90038bc9efe38db894cde45f268b6712b04fce8cd0acb", size = 4460520, upload-time = "2026-08-03T22:33:06.81Z" },
136
+ { url = "https://files.pythonhosted.org/packages/ab/5f/311725e2a905534dfee2dcb5b08414f249147f1f12252bfc2bd24caa075c/hf_xet-1.6.0-cp38-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:8fb4f71cba6129110c3374a33f919001ff130488fc23553698e34cc1c2a1198c", size = 4675937, upload-time = "2026-08-03T22:33:08.616Z" },
137
+ { url = "https://files.pythonhosted.org/packages/98/b7/8c59a66d15205024662f1d66968136f13893f96df1ddc5087e2e281fc95f/hf_xet-1.6.0-cp38-abi3-win_amd64.whl", hash = "sha256:fb4fadde1b2b70bf4c0c14a6dccbe7194b1c28947fefd5bbe3fed9d940676c3b", size = 4033128, upload-time = "2026-08-03T22:33:10.171Z" },
138
+ { url = "https://files.pythonhosted.org/packages/73/63/ca511b6f802f28cf3489b280fe77475bcca8de85e81a6299d7916b5b5555/hf_xet-1.6.0-cp38-abi3-win_arm64.whl", hash = "sha256:3dc3e35441ba395006af5aaacc40ef2e603c51ef46c3530b9156185f00935ea3", size = 3859359, upload-time = "2026-08-03T22:33:11.725Z" },
139
+ ]
140
+
141
+ [[package]]
142
+ name = "huggingface-hub"
143
+ version = "0.34.4"
144
+ source = { registry = "https://pypi.org/simple" }
145
+ dependencies = [
146
+ { name = "filelock" },
147
+ { name = "fsspec" },
148
+ { name = "hf-xet", marker = "platform_machine == 'aarch64' or platform_machine == 'amd64' or platform_machine == 'arm64' or platform_machine == 'x86_64'" },
149
+ { name = "packaging" },
150
+ { name = "pyyaml" },
151
+ { name = "requests" },
152
+ { name = "tqdm" },
153
+ { name = "typing-extensions" },
154
+ ]
155
+ sdist = { url = "https://files.pythonhosted.org/packages/45/c9/bdbe19339f76d12985bc03572f330a01a93c04dffecaaea3061bdd7fb892/huggingface_hub-0.34.4.tar.gz", hash = "sha256:a4228daa6fb001be3f4f4bdaf9a0db00e1739235702848df00885c9b5742c85c", size = 459768, upload-time = "2025-08-08T09:14:52.365Z" }
156
+ wheels = [
157
+ { url = "https://files.pythonhosted.org/packages/39/7b/bb06b061991107cd8783f300adff3e7b7f284e330fd82f507f2a1417b11d/huggingface_hub-0.34.4-py3-none-any.whl", hash = "sha256:9b365d781739c93ff90c359844221beef048403f1bc1f1c123c191257c3c890a", size = 561452, upload-time = "2025-08-08T09:14:50.159Z" },
158
+ ]
159
+
160
+ [[package]]
161
+ name = "idna"
162
+ version = "3.20"
163
+ source = { registry = "https://pypi.org/simple" }
164
+ sdist = { url = "https://files.pythonhosted.org/packages/f5/08/8eea9d4b8302028f3abb2c0813953f7aec26d33b7a8960ed760e65ff29fa/idna-3.20.tar.gz", hash = "sha256:a7db850025b95ded1eae8a46181a1a6c56c92c96f0e2b005d9ff8dc0210cab44", size = 216463, upload-time = "2026-09-17T14:11:04.752Z" }
165
+ wheels = [
166
+ { url = "https://files.pythonhosted.org/packages/58/a2/bb081bab032533a855d44de1d56f8e8426114ff1ba5d1f07a438a0a654f8/idna-3.20-py3-none-any.whl", hash = "sha256:ab7ae7122974553370f0bdb919e1a960b2cd1bc1ef0276416d896db81c14582c", size = 69583, upload-time = "2026-09-17T14:11:03.168Z" },
167
+ ]
168
+
169
+ [[package]]
170
+ name = "jinja2"
171
+ version = "3.1.6"
172
+ source = { registry = "https://pypi.org/simple" }
173
+ dependencies = [
174
+ { name = "markupsafe" },
175
+ ]
176
+ sdist = { url = "https://files.pythonhosted.org/packages/df/bf/f7da0350254c0ed7c72f3e33cef02e048281fec7ecec5f032d4aac52226b/jinja2-3.1.6.tar.gz", hash = "sha256:0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d", size = 245115, upload-time = "2025-03-05T20:05:02.478Z" }
177
+ wheels = [
178
+ { url = "https://files.pythonhosted.org/packages/62/a1/3d680cbfd5f4b8f15abc1d571870c5fc3e594bb582bc3b64ea099db13e56/jinja2-3.1.6-py3-none-any.whl", hash = "sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67", size = 134899, upload-time = "2025-03-05T20:05:00.369Z" },
179
+ ]
180
+
181
+ [[package]]
182
+ name = "markupsafe"
183
+ version = "3.0.4"
184
+ source = { registry = "https://pypi.org/simple" }
185
+ sdist = { url = "https://files.pythonhosted.org/packages/38/9b/e422a865e1d5d57d0e509b4e0bf1c1a70a7f6382c29a5aa428df994c8bc8/markupsafe-3.0.4.tar.gz", hash = "sha256:2e9ad7dd851bf45fab9f75cbff4cb493fee9979e8d8c7c9c3ee119022518edd6", size = 153777, upload-time = "2026-10-02T23:07:22.29Z" }
186
+ wheels = [
187
+ { url = "https://files.pythonhosted.org/packages/32/55/18dbb4778b30ada5ce071608503cc3edc9e14e13d868c17a6d178fc30f7a/markupsafe-3.0.4-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:9e25feb9e330b63edb0278a0acdf85e50d0cb0fbf49c3084abbe4e24ae195346", size = 11520, upload-time = "2026-10-02T23:04:36.299Z" },
188
+ { url = "https://files.pythonhosted.org/packages/6c/14/0b05f79b4733e264a18d08fe08fa1df7347630ff32a6cb82180d9dccec55/markupsafe-3.0.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:7d3391b2188d18737cb2fa147028b1096236eaa7e156446c650a489fa2cadc91", size = 12063, upload-time = "2026-10-02T23:04:37.291Z" },
189
+ { url = "https://files.pythonhosted.org/packages/ca/3a/63ba10b6c1463216b3e4df669a9f0e5a3b0c3071557d2e8229e3968c79fb/markupsafe-3.0.4-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:849dd2bb0e5e4ab2b71c7191726a4a8d5aa8a610daa584728cbee0b710ddc4ef", size = 24321, upload-time = "2026-10-02T23:04:38.262Z" },
190
+ { url = "https://files.pythonhosted.org/packages/1a/2e/5f015261b76ad633d187ef6f388b413aedd64a8773c4df59e530a0be5525/markupsafe-3.0.4-cp311-cp311-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:befb4158af32106b9a93db8d6d1d1cbbd418c0d5aca0cabb7b1780abf0c89169", size = 28845, upload-time = "2026-10-02T23:04:39.295Z" },
191
+ { url = "https://files.pythonhosted.org/packages/33/cf/26e594b26be40c2f1fec63ccf8a8b99d0335a5b2cbe84835c7d82a994375/markupsafe-3.0.4-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:71f88e749ea29f67f21f3b36433c1dc54c7729ed2a6d9e2da2e0d9e0d7b224eb", size = 24701, upload-time = "2026-10-02T23:04:40.348Z" },
192
+ { url = "https://files.pythonhosted.org/packages/81/a5/a513b76c139a3915b43404324e55c0b7979ae4f0d39eb6f075b0282e90a8/markupsafe-3.0.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:6da83a088f8ef93b2d483a8232a4dbf4d69d3d8496b568a03c56becac43e1808", size = 22961, upload-time = "2026-10-02T23:04:41.372Z" },
193
+ { url = "https://files.pythonhosted.org/packages/46/cf/4c66192c100b4542bcbe392ae06696b670f66927be3ac38a213234778ff9/markupsafe-3.0.4-cp311-cp311-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:8f0fac8b13d14bb06c68195f849371924ae53dd7b1c00fed24650f704383b692", size = 21920, upload-time = "2026-10-02T23:04:42.429Z" },
194
+ { url = "https://files.pythonhosted.org/packages/cb/17/ac3662678bfbad649893117ada2ba44dc30bf56884e84f13154a792b10f1/markupsafe-3.0.4-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:4a7cdc2a420ca01058182da4253329764d4bfa055564d1eced90e6ba1e8b1d3d", size = 23726, upload-time = "2026-10-02T23:04:43.531Z" },
195
+ { url = "https://files.pythonhosted.org/packages/f7/af/fe47cee339180a69ebca3c57fb3483d0f5cbd1e8337d1871fb1d9c1aebee/markupsafe-3.0.4-cp311-cp311-musllinux_1_2_armv7l.whl", hash = "sha256:83b3944fea42a8400edf92fd1770fb8d0d4f7de651353bd2d8525a92dba69a21", size = 22539, upload-time = "2026-10-02T23:04:44.618Z" },
196
+ { url = "https://files.pythonhosted.org/packages/12/32/d55440ba140442800e02d799c9cb5ab597bf6ebdb1177b5ea39a11f797bd/markupsafe-3.0.4-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:8138eb83940ec7299024d92d4dee45f601b9e6c5ffde9d25f4e35e326203c707", size = 23963, upload-time = "2026-10-02T23:04:45.656Z" },
197
+ { url = "https://files.pythonhosted.org/packages/50/9d/9c86042cb364c2ad4c971e6d1247929effd25f714cd7ee11b05e6316445b/markupsafe-3.0.4-cp311-cp311-musllinux_1_2_riscv64.whl", hash = "sha256:811d02d5122171c1941357efd8f9bf4ffe907b7f0a1a4e729a880e4be3f46e3e", size = 21506, upload-time = "2026-10-02T23:04:46.671Z" },
198
+ { url = "https://files.pythonhosted.org/packages/75/ef/5b824f03ba40c3b3652b6272d083d2fc4fcdd440de519a3a39ba2c3e7262/markupsafe-3.0.4-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:50b5bedc9ed8a94fc8857a42ef4f84a81ea88f8d4f05dc8705fb23ee6d8dcca7", size = 22955, upload-time = "2026-10-02T23:04:47.698Z" },
199
+ { url = "https://files.pythonhosted.org/packages/1e/e8/44cfcb5ea40e5e43cec7793ef90704ed0c475280839076c4345757eb8e59/markupsafe-3.0.4-cp311-cp311-win32.whl", hash = "sha256:2e5a7cd7fdd14fcb1ae5d7d8bf23d24fbd1daefd1fbca2580132e1ea75f098b5", size = 14094, upload-time = "2026-10-02T23:04:48.788Z" },
200
+ { url = "https://files.pythonhosted.org/packages/91/89/f2b509f7bf79352e40117824c1070dbeafd4df67031d3fa98165a3134228/markupsafe-3.0.4-cp311-cp311-win_amd64.whl", hash = "sha256:fdb4ca07ab75ffadab4a8b135ad59cdbb3156b99310f3d565370da74a15d6bd3", size = 14328, upload-time = "2026-10-02T23:04:49.801Z" },
201
+ { url = "https://files.pythonhosted.org/packages/2b/5a/ccf22672a0f64dc682306e288f0dabcb06c7a201f3bb6e6cbf86d9e8ad03/markupsafe-3.0.4-cp311-cp311-win_arm64.whl", hash = "sha256:569d65055d367e3dcdf30c3f41119467b73d9ee9faf332bdf40402644f5ac08e", size = 14188, upload-time = "2026-10-02T23:04:50.847Z" },
202
+ ]
203
+
204
+ [[package]]
205
+ name = "ml-dtypes"
206
+ version = "0.6.0"
207
+ source = { registry = "https://pypi.org/simple" }
208
+ dependencies = [
209
+ { name = "numpy" },
210
+ ]
211
+ sdist = { url = "https://files.pythonhosted.org/packages/12/72/307d7c4bd0600601c7133fba5cb78af7db968152951c1cd473abb1cda782/ml_dtypes-0.6.0.tar.gz", hash = "sha256:5e60251d32ced5598972e4d5e06a2f044341f9291402551a3f6f0ec44f9299b0", size = 3032327, upload-time = "2026-08-13T14:14:40.215Z" }
212
+ wheels = [
213
+ { url = "https://files.pythonhosted.org/packages/b8/2c/318cd1a9014c63939ffe687e19559ae12831fcc37d66c71ad1f616f1ffd6/ml_dtypes-0.6.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:f4f59f83c82ab480e924b988e7b1b4eb4de836dfcf5390c6f59148d1a00e1d02", size = 566813, upload-time = "2026-08-13T14:13:55.053Z" },
214
+ { url = "https://files.pythonhosted.org/packages/d9/83/706b8a39449f0d55a7d5f7d07a169da4decfafae8a1f4983a9236d4b49e8/ml_dtypes-0.6.0-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:7728c0420ec1c338564fc8b01015ff2d58567e70f17fedce5a0a7c0308c0d5b9", size = 356864, upload-time = "2026-08-13T14:13:56.249Z" },
215
+ { url = "https://files.pythonhosted.org/packages/2e/b1/135a7bf47633f5b9184f0d0316af819884124d12b40965064bd216266514/ml_dtypes-0.6.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:6c8e39b53e90afda8ce52859c93de4dba3e02b76d85dcf091cc469f9184c6dae", size = 412043, upload-time = "2026-08-13T14:13:57.614Z" },
216
+ { url = "https://files.pythonhosted.org/packages/07/23/8870bb62d6e499d6bcbc1242b9f11689bae00a3d39d3684a9aefad8b6ee6/ml_dtypes-0.6.0-cp311-cp311-win_amd64.whl", hash = "sha256:3035518e3e19add1a4cac9236ab22888b208a4074912514313ccb2d6d242cde8", size = 433670, upload-time = "2026-08-13T14:13:59.097Z" },
217
+ { url = "https://files.pythonhosted.org/packages/cf/7a/5d8fbe24d0bffd0d7cb5165a89f8ab7c3de000f26d6705242aeed99d583c/ml_dtypes-0.6.0-cp311-cp311-win_arm64.whl", hash = "sha256:5a519c9e95a216fbcb8e759793ef7fb40793fc803ed839142d6dc5be9be5bc89", size = 551915, upload-time = "2026-08-13T14:14:00.368Z" },
218
+ ]
219
+
220
+ [[package]]
221
+ name = "mpmath"
222
+ version = "1.3.0"
223
+ source = { registry = "https://pypi.org/simple" }
224
+ sdist = { url = "https://files.pythonhosted.org/packages/e0/47/dd32fa426cc72114383ac549964eecb20ecfd886d1e5ccf5340b55b02f57/mpmath-1.3.0.tar.gz", hash = "sha256:7a28eb2a9774d00c7bc92411c19a89209d5da7c4c9a9e227be8330a23a25b91f", size = 508106, upload-time = "2023-03-07T16:47:11.061Z" }
225
+ wheels = [
226
+ { url = "https://files.pythonhosted.org/packages/43/e3/7d92a15f894aa0c9c4b49b8ee9ac9850d6e63b03c9c32c0367a13ae62209/mpmath-1.3.0-py3-none-any.whl", hash = "sha256:a0b2b9fe80bbcd81a6647ff13108738cfb482d481d826cc0e02f5b35e5c88d2c", size = 536198, upload-time = "2023-03-07T16:47:09.197Z" },
227
+ ]
228
+
229
+ [[package]]
230
+ name = "networkx"
231
+ version = "3.6.1"
232
+ source = { registry = "https://pypi.org/simple" }
233
+ sdist = { url = "https://files.pythonhosted.org/packages/6a/51/63fe664f3908c97be9d2e4f1158eb633317598cfa6e1fc14af5383f17512/networkx-3.6.1.tar.gz", hash = "sha256:26b7c357accc0c8cde558ad486283728b65b6a95d85ee1cd66bafab4c8168509", size = 2517025, upload-time = "2025-12-08T17:02:39.908Z" }
234
+ wheels = [
235
+ { url = "https://files.pythonhosted.org/packages/9e/c9/b2622292ea83fbb4ec318f5b9ab867d0a28ab43c5717bb85b0a5f6b3b0a4/networkx-3.6.1-py3-none-any.whl", hash = "sha256:d47fbf302e7d9cbbb9e2555a0d267983d2aa476bac30e90dfbe5669bd57f3762", size = 2068504, upload-time = "2025-12-08T17:02:38.159Z" },
236
+ ]
237
+
238
+ [[package]]
239
+ name = "numpy"
240
+ version = "2.2.6"
241
+ source = { registry = "https://pypi.org/simple" }
242
+ sdist = { url = "https://files.pythonhosted.org/packages/76/21/7d2a95e4bba9dc13d043ee156a356c0a8f0c6309dff6b21b4d71a073b8a8/numpy-2.2.6.tar.gz", hash = "sha256:e29554e2bef54a90aa5cc07da6ce955accb83f21ab5de01a62c8478897b264fd", size = 20276440, upload-time = "2025-05-17T22:38:04.611Z" }
243
+ wheels = [
244
+ { url = "https://files.pythonhosted.org/packages/da/a8/4f83e2aa666a9fbf56d6118faaaf5f1974d456b1823fda0a176eff722839/numpy-2.2.6-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:f9f1adb22318e121c5c69a09142811a201ef17ab257a1e66ca3025065b7f53ae", size = 21176963, upload-time = "2025-05-17T21:31:19.36Z" },
245
+ { url = "https://files.pythonhosted.org/packages/b3/2b/64e1affc7972decb74c9e29e5649fac940514910960ba25cd9af4488b66c/numpy-2.2.6-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:c820a93b0255bc360f53eca31a0e676fd1101f673dda8da93454a12e23fc5f7a", size = 14406743, upload-time = "2025-05-17T21:31:41.087Z" },
246
+ { url = "https://files.pythonhosted.org/packages/4a/9f/0121e375000b5e50ffdd8b25bf78d8e1a5aa4cca3f185d41265198c7b834/numpy-2.2.6-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:3d70692235e759f260c3d837193090014aebdf026dfd167834bcba43e30c2a42", size = 5352616, upload-time = "2025-05-17T21:31:50.072Z" },
247
+ { url = "https://files.pythonhosted.org/packages/31/0d/b48c405c91693635fbe2dcd7bc84a33a602add5f63286e024d3b6741411c/numpy-2.2.6-cp311-cp311-macosx_14_0_x86_64.whl", hash = "sha256:481b49095335f8eed42e39e8041327c05b0f6f4780488f61286ed3c01368d491", size = 6889579, upload-time = "2025-05-17T21:32:01.712Z" },
248
+ { url = "https://files.pythonhosted.org/packages/52/b8/7f0554d49b565d0171eab6e99001846882000883998e7b7d9f0d98b1f934/numpy-2.2.6-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b64d8d4d17135e00c8e346e0a738deb17e754230d7e0810ac5012750bbd85a5a", size = 14312005, upload-time = "2025-05-17T21:32:23.332Z" },
249
+ { url = "https://files.pythonhosted.org/packages/b3/dd/2238b898e51bd6d389b7389ffb20d7f4c10066d80351187ec8e303a5a475/numpy-2.2.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba10f8411898fc418a521833e014a77d3ca01c15b0c6cdcce6a0d2897e6dbbdf", size = 16821570, upload-time = "2025-05-17T21:32:47.991Z" },
250
+ { url = "https://files.pythonhosted.org/packages/83/6c/44d0325722cf644f191042bf47eedad61c1e6df2432ed65cbe28509d404e/numpy-2.2.6-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:bd48227a919f1bafbdda0583705e547892342c26fb127219d60a5c36882609d1", size = 15818548, upload-time = "2025-05-17T21:33:11.728Z" },
251
+ { url = "https://files.pythonhosted.org/packages/ae/9d/81e8216030ce66be25279098789b665d49ff19eef08bfa8cb96d4957f422/numpy-2.2.6-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:9551a499bf125c1d4f9e250377c1ee2eddd02e01eac6644c080162c0c51778ab", size = 18620521, upload-time = "2025-05-17T21:33:39.139Z" },
252
+ { url = "https://files.pythonhosted.org/packages/6a/fd/e19617b9530b031db51b0926eed5345ce8ddc669bb3bc0044b23e275ebe8/numpy-2.2.6-cp311-cp311-win32.whl", hash = "sha256:0678000bb9ac1475cd454c6b8c799206af8107e310843532b04d49649c717a47", size = 6525866, upload-time = "2025-05-17T21:33:50.273Z" },
253
+ { url = "https://files.pythonhosted.org/packages/31/0a/f354fb7176b81747d870f7991dc763e157a934c717b67b58456bc63da3df/numpy-2.2.6-cp311-cp311-win_amd64.whl", hash = "sha256:e8213002e427c69c45a52bbd94163084025f533a55a59d6f9c5b820774ef3303", size = 12907455, upload-time = "2025-05-17T21:34:09.135Z" },
254
+ ]
255
+
256
+ [[package]]
257
+ name = "nvidia-cublas-cu12"
258
+ version = "12.8.4.1"
259
+ source = { registry = "https://pypi.org/simple" }
260
+ wheels = [
261
+ { url = "https://files.pythonhosted.org/packages/dc/61/e24b560ab2e2eaeb3c839129175fb330dfcfc29e5203196e5541a4c44682/nvidia_cublas_cu12-12.8.4.1-py3-none-manylinux_2_27_x86_64.whl", hash = "sha256:8ac4e771d5a348c551b2a426eda6193c19aa630236b418086020df5ba9667142", size = 594346921, upload-time = "2025-03-07T01:44:31.254Z" },
262
+ ]
263
+
264
+ [[package]]
265
+ name = "nvidia-cuda-cupti-cu12"
266
+ version = "12.8.90"
267
+ source = { registry = "https://pypi.org/simple" }
268
+ wheels = [
269
+ { url = "https://files.pythonhosted.org/packages/f8/02/2adcaa145158bf1a8295d83591d22e4103dbfd821bcaf6f3f53151ca4ffa/nvidia_cuda_cupti_cu12-12.8.90-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:ea0cb07ebda26bb9b29ba82cda34849e73c166c18162d3913575b0c9db9a6182", size = 10248621, upload-time = "2025-03-07T01:40:21.213Z" },
270
+ ]
271
+
272
+ [[package]]
273
+ name = "nvidia-cuda-nvrtc-cu12"
274
+ version = "12.8.93"
275
+ source = { registry = "https://pypi.org/simple" }
276
+ wheels = [
277
+ { url = "https://files.pythonhosted.org/packages/05/6b/32f747947df2da6994e999492ab306a903659555dddc0fbdeb9d71f75e52/nvidia_cuda_nvrtc_cu12-12.8.93-py3-none-manylinux2010_x86_64.manylinux_2_12_x86_64.whl", hash = "sha256:a7756528852ef889772a84c6cd89d41dfa74667e24cca16bb31f8f061e3e9994", size = 88040029, upload-time = "2025-03-07T01:42:13.562Z" },
278
+ ]
279
+
280
+ [[package]]
281
+ name = "nvidia-cuda-runtime-cu12"
282
+ version = "12.8.90"
283
+ source = { registry = "https://pypi.org/simple" }
284
+ wheels = [
285
+ { url = "https://files.pythonhosted.org/packages/0d/9b/a997b638fcd068ad6e4d53b8551a7d30fe8b404d6f1804abf1df69838932/nvidia_cuda_runtime_cu12-12.8.90-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:adade8dcbd0edf427b7204d480d6066d33902cab2a4707dcfc48a2d0fd44ab90", size = 954765, upload-time = "2025-03-07T01:40:01.615Z" },
286
+ ]
287
+
288
+ [[package]]
289
+ name = "nvidia-cudnn-cu12"
290
+ version = "9.10.2.21"
291
+ source = { registry = "https://pypi.org/simple" }
292
+ dependencies = [
293
+ { name = "nvidia-cublas-cu12" },
294
+ ]
295
+ wheels = [
296
+ { url = "https://files.pythonhosted.org/packages/ba/51/e123d997aa098c61d029f76663dedbfb9bc8dcf8c60cbd6adbe42f76d049/nvidia_cudnn_cu12-9.10.2.21-py3-none-manylinux_2_27_x86_64.whl", hash = "sha256:949452be657fa16687d0930933f032835951ef0892b37d2d53824d1a84dc97a8", size = 706758467, upload-time = "2025-06-06T21:54:08.597Z" },
297
+ ]
298
+
299
+ [[package]]
300
+ name = "nvidia-cufft-cu12"
301
+ version = "11.3.3.83"
302
+ source = { registry = "https://pypi.org/simple" }
303
+ dependencies = [
304
+ { name = "nvidia-nvjitlink-cu12" },
305
+ ]
306
+ wheels = [
307
+ { url = "https://files.pythonhosted.org/packages/1f/13/ee4e00f30e676b66ae65b4f08cb5bcbb8392c03f54f2d5413ea99a5d1c80/nvidia_cufft_cu12-11.3.3.83-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:4d2dd21ec0b88cf61b62e6b43564355e5222e4a3fb394cac0db101f2dd0d4f74", size = 193118695, upload-time = "2025-03-07T01:45:27.821Z" },
308
+ ]
309
+
310
+ [[package]]
311
+ name = "nvidia-cufile-cu12"
312
+ version = "1.13.1.3"
313
+ source = { registry = "https://pypi.org/simple" }
314
+ wheels = [
315
+ { url = "https://files.pythonhosted.org/packages/bb/fe/1bcba1dfbfb8d01be8d93f07bfc502c93fa23afa6fd5ab3fc7c1df71038a/nvidia_cufile_cu12-1.13.1.3-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:1d069003be650e131b21c932ec3d8969c1715379251f8d23a1860554b1cb24fc", size = 1197834, upload-time = "2025-03-07T01:45:50.723Z" },
316
+ ]
317
+
318
+ [[package]]
319
+ name = "nvidia-curand-cu12"
320
+ version = "10.3.9.90"
321
+ source = { registry = "https://pypi.org/simple" }
322
+ wheels = [
323
+ { url = "https://files.pythonhosted.org/packages/fb/aa/6584b56dc84ebe9cf93226a5cde4d99080c8e90ab40f0c27bda7a0f29aa1/nvidia_curand_cu12-10.3.9.90-py3-none-manylinux_2_27_x86_64.whl", hash = "sha256:b32331d4f4df5d6eefa0554c565b626c7216f87a06a4f56fab27c3b68a830ec9", size = 63619976, upload-time = "2025-03-07T01:46:23.323Z" },
324
+ ]
325
+
326
+ [[package]]
327
+ name = "nvidia-cusolver-cu12"
328
+ version = "11.7.3.90"
329
+ source = { registry = "https://pypi.org/simple" }
330
+ dependencies = [
331
+ { name = "nvidia-cublas-cu12" },
332
+ { name = "nvidia-cusparse-cu12" },
333
+ { name = "nvidia-nvjitlink-cu12" },
334
+ ]
335
+ wheels = [
336
+ { url = "https://files.pythonhosted.org/packages/85/48/9a13d2975803e8cf2777d5ed57b87a0b6ca2cc795f9a4f59796a910bfb80/nvidia_cusolver_cu12-11.7.3.90-py3-none-manylinux_2_27_x86_64.whl", hash = "sha256:4376c11ad263152bd50ea295c05370360776f8c3427b30991df774f9fb26c450", size = 267506905, upload-time = "2025-03-07T01:47:16.273Z" },
337
+ ]
338
+
339
+ [[package]]
340
+ name = "nvidia-cusparse-cu12"
341
+ version = "12.5.8.93"
342
+ source = { registry = "https://pypi.org/simple" }
343
+ dependencies = [
344
+ { name = "nvidia-nvjitlink-cu12" },
345
+ ]
346
+ wheels = [
347
+ { url = "https://files.pythonhosted.org/packages/c2/f5/e1854cb2f2bcd4280c44736c93550cc300ff4b8c95ebe370d0aa7d2b473d/nvidia_cusparse_cu12-12.5.8.93-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:1ec05d76bbbd8b61b06a80e1eaf8cf4959c3d4ce8e711b65ebd0443bb0ebb13b", size = 288216466, upload-time = "2025-03-07T01:48:13.779Z" },
348
+ ]
349
+
350
+ [[package]]
351
+ name = "nvidia-cusparselt-cu12"
352
+ version = "0.7.1"
353
+ source = { registry = "https://pypi.org/simple" }
354
+ wheels = [
355
+ { url = "https://files.pythonhosted.org/packages/56/79/12978b96bd44274fe38b5dde5cfb660b1d114f70a65ef962bcbbed99b549/nvidia_cusparselt_cu12-0.7.1-py3-none-manylinux2014_x86_64.whl", hash = "sha256:f1bb701d6b930d5a7cea44c19ceb973311500847f81b634d802b7b539dc55623", size = 287193691, upload-time = "2025-02-26T00:15:44.104Z" },
356
+ ]
357
+
358
+ [[package]]
359
+ name = "nvidia-nccl-cu12"
360
+ version = "2.27.3"
361
+ source = { registry = "https://pypi.org/simple" }
362
+ wheels = [
363
+ { url = "https://files.pythonhosted.org/packages/5c/5b/4e4fff7bad39adf89f735f2bc87248c81db71205b62bcc0d5ca5b606b3c3/nvidia_nccl_cu12-2.27.3-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:adf27ccf4238253e0b826bce3ff5fa532d65fc42322c8bfdfaf28024c0fbe039", size = 322364134, upload-time = "2025-06-03T21:58:04.013Z" },
364
+ ]
365
+
366
+ [[package]]
367
+ name = "nvidia-nvjitlink-cu12"
368
+ version = "12.8.93"
369
+ source = { registry = "https://pypi.org/simple" }
370
+ wheels = [
371
+ { url = "https://files.pythonhosted.org/packages/f6/74/86a07f1d0f42998ca31312f998bd3b9a7eff7f52378f4f270c8679c77fb9/nvidia_nvjitlink_cu12-12.8.93-py3-none-manylinux2010_x86_64.manylinux_2_12_x86_64.whl", hash = "sha256:81ff63371a7ebd6e6451970684f916be2eab07321b73c9d244dc2b4da7f73b88", size = 39254836, upload-time = "2025-03-07T01:49:55.661Z" },
372
+ ]
373
+
374
+ [[package]]
375
+ name = "nvidia-nvtx-cu12"
376
+ version = "12.8.90"
377
+ source = { registry = "https://pypi.org/simple" }
378
+ wheels = [
379
+ { url = "https://files.pythonhosted.org/packages/a2/eb/86626c1bbc2edb86323022371c39aa48df6fd8b0a1647bc274577f72e90b/nvidia_nvtx_cu12-12.8.90-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:5b17e2001cc0d751a5bc2c6ec6d26ad95913324a4adb86788c944f8ce9ba441f", size = 89954, upload-time = "2025-03-07T01:42:44.131Z" },
380
+ ]
381
+
382
+ [[package]]
383
+ name = "onnx"
384
+ version = "1.23.2"
385
+ source = { registry = "https://pypi.org/simple" }
386
+ dependencies = [
387
+ { name = "ml-dtypes" },
388
+ { name = "numpy" },
389
+ { name = "protobuf" },
390
+ { name = "typing-extensions" },
391
+ ]
392
+ sdist = { url = "https://files.pythonhosted.org/packages/3f/62/bc2dfadb63ecf04cb2d65a6b17751863039d36c65de51d6a3128ab35f1e7/onnx-1.23.2.tar.gz", hash = "sha256:008cb0467b2bbee41448acc7da8b6f4e704624cb0d327a2d5adafc7ce19bc5b8", size = 6023090, upload-time = "2026-10-06T04:25:58.681Z" }
393
+ wheels = [
394
+ { url = "https://files.pythonhosted.org/packages/ea/27/b8793ea89e16ce16beb0e662d29ee8f4e100e9e95202968d08f1c08795d3/onnx-1.23.2-cp311-cp311-macosx_13_0_universal2.whl", hash = "sha256:419bbbe3fbdf45a7658ee0aa1a54cd170ea15f3e5a60ace6e8d94f1577b3674b", size = 9725398, upload-time = "2026-10-06T04:25:21.31Z" },
395
+ { url = "https://files.pythonhosted.org/packages/8a/2c/f9a5f186da571c396b660f97cc0e1aa85c5b76249abacda3de01b9f2e049/onnx-1.23.2-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:83b3fc8321303c9da62824730457ba2f7ae0970f0e2f7fc0117912df7f8a4826", size = 8644597, upload-time = "2026-10-06T04:25:23.451Z" },
396
+ { url = "https://files.pythonhosted.org/packages/12/4d/e8cafd5fbe5f5fde043676838a4754e6ff4cd00323ecc81b3345eca6f185/onnx-1.23.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c03ecf6b835d136108eeaeeafbd0026fc7b3cf98661409fbc6b63d5a29361348", size = 8886609, upload-time = "2026-10-06T04:25:25.379Z" },
397
+ { url = "https://files.pythonhosted.org/packages/de/56/cfc3ee63efc13dc112e29a79cfb77efecec50378fc4e2bd8f1b1ccd04fe8/onnx-1.23.2-cp311-cp311-win32.whl", hash = "sha256:a2b88d7e3634662f8d030117a7b02d864cfc965800547089ba62d3a9ceab3564", size = 7738192, upload-time = "2026-10-06T04:25:28.45Z" },
398
+ { url = "https://files.pythonhosted.org/packages/81/0d/3aaf8f1fea3430282bd65acb3808d80fbdfeb90f20cfecb4072604e37ca6/onnx-1.23.2-cp311-cp311-win_amd64.whl", hash = "sha256:a40265d62b7a614041593e11370d316880f9628eb5a0d49d9028c9c0e7f1cc08", size = 7875390, upload-time = "2026-10-06T04:25:30.432Z" },
399
+ { url = "https://files.pythonhosted.org/packages/ff/99/88c439dd84db6abc7d87e9d39584bdc29d4cbf5a1ae26015fcabf6679d36/onnx-1.23.2-cp311-cp311-win_arm64.whl", hash = "sha256:f8b9a5e25a390cc291600e5fd619f4b79708287a6bbc41a37209f364e08a63da", size = 8050663, upload-time = "2026-10-06T04:25:32.401Z" },
400
+ { url = "https://files.pythonhosted.org/packages/d7/d9/967d6f6838ad60964de912a5e7d01915282899b254460705d952f5d14c1a/onnx-1.23.2-cp312-abi3-macosx_13_0_universal2.whl", hash = "sha256:1b8680ce1e6a9a4736374a9dce4de14ea8ee05e0dccf0784a78a6e5646bdc1f6", size = 9725612, upload-time = "2026-10-06T04:25:34.299Z" },
401
+ { url = "https://files.pythonhosted.org/packages/f9/50/2e156ef2cae1c9f4ff01a41dffa43fc1eb7b969755055436bf6df1805d54/onnx-1.23.2-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:a203efdbaabbbe8f25e854e2b2921382d6fcf4c67895656f939044b0632974e8", size = 8640515, upload-time = "2026-10-06T04:25:36.727Z" },
402
+ { url = "https://files.pythonhosted.org/packages/87/56/21509a657f9a73ab0ca307d325043f49ca6c4ff6bf79edeb9e159190d44d/onnx-1.23.2-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7abf381d278f31ac62487fddedc9dd42da842dce94d5d43536836ee3efdf4a2b", size = 8881633, upload-time = "2026-10-06T04:25:38.868Z" },
403
+ { url = "https://files.pythonhosted.org/packages/ec/ef/0a69093ffa0b999747b373c75d07182a812722a0e595d21f763a8d406260/onnx-1.23.2-cp312-abi3-pyemscripten_2026_0_wasm32.whl", hash = "sha256:e79e35e152d3095c6910ae81013bbc68679e32bfc0ca76f840968d4b6fdfb864", size = 7314844, upload-time = "2026-10-06T04:25:41.088Z" },
404
+ { url = "https://files.pythonhosted.org/packages/97/a3/e4d4aedd0cc6820de416bb99623fc12b9a22a387d00596bb98505de9a805/onnx-1.23.2-cp312-abi3-win32.whl", hash = "sha256:b0b8dae0d33dd8606370bc264b0b1d6e64cfdf8b83d7c676fab8eff6b88ca409", size = 7736405, upload-time = "2026-10-06T04:25:42.893Z" },
405
+ { url = "https://files.pythonhosted.org/packages/38/ce/102fd4a0b2a6d111a9c86745e084c4c68c0ee020eaa359a03a8d43e4646f/onnx-1.23.2-cp312-abi3-win_amd64.whl", hash = "sha256:9b382ba898a7c142a0801d03cf04ecabced96c1543c7b643a86f0928143802de", size = 7872489, upload-time = "2026-10-06T04:25:44.802Z" },
406
+ { url = "https://files.pythonhosted.org/packages/bd/1d/37f2c7f821f79ceed3c976bd087d16abdd2b0bba6c19475322e7a31bae59/onnx-1.23.2-cp312-abi3-win_arm64.whl", hash = "sha256:80cef0fad59524d02c21ec93f4fbccdcc6223f1c33339d597519a2d27cac19a7", size = 8047076, upload-time = "2026-10-06T04:25:46.93Z" },
407
+ ]
408
+
409
+ [[package]]
410
+ name = "onnxruntime"
411
+ version = "1.30.0"
412
+ source = { registry = "https://pypi.org/simple" }
413
+ dependencies = [
414
+ { name = "flatbuffers" },
415
+ { name = "numpy" },
416
+ { name = "packaging" },
417
+ { name = "protobuf" },
418
+ ]
419
+ wheels = [
420
+ { url = "https://files.pythonhosted.org/packages/73/b6/e2fa6dfc8c3cd19639d452c3120fb0e02f5176b4e24ecabb24b5362be725/onnxruntime-1.30.0-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:f36c87ec504f4f328e968ee322e4ba9682abe66280b3425625afcbed5333fed7", size = 21533037, upload-time = "2026-09-10T16:31:03.582Z" },
421
+ { url = "https://files.pythonhosted.org/packages/4f/1a/4d197d2676a866f6239cd2d06a95b6db40d47dc29d5bec9fb1493a13dd94/onnxruntime-1.30.0-cp311-cp311-manylinux_2_28_aarch64.whl", hash = "sha256:bac3aee7b40acd805659fd81a2acd6096312d5b0f014c97ddfe75fb4c1644627", size = 21332697, upload-time = "2026-09-10T16:31:08.118Z" },
422
+ { url = "https://files.pythonhosted.org/packages/4f/2e/4c96278a99140d0307ccda6fd51e6e9d1ca7c9f6fdd1fa96ff375acfc713/onnxruntime-1.30.0-cp311-cp311-manylinux_2_28_x86_64.whl", hash = "sha256:fd54b314ea385bcecac69ab431f020ba503e3878dad4ebb645fec5a24b041242", size = 23561046, upload-time = "2026-09-10T16:31:11.494Z" },
423
+ { url = "https://files.pythonhosted.org/packages/66/68/b8aaade8c1883f569228f4b57201cce922bb7d4af6f977d619520a733430/onnxruntime-1.30.0-cp311-cp311-win_amd64.whl", hash = "sha256:0edd0145a6e3fce8a1276491dc784d615e3c58bcb952c9b4e5c876d5c6a12ad7", size = 14309136, upload-time = "2026-09-10T16:31:14.181Z" },
424
+ { url = "https://files.pythonhosted.org/packages/96/f1/fbda6fb08ac4db6c5c6f7c3e128e4d8fb398b52fe2fc3282c45cadedd18b/onnxruntime-1.30.0-cp311-cp311-win_arm64.whl", hash = "sha256:16506cfa5d218850f2b46e0edce1b952121f2f84f8e0074dafe15f4787f0c8fb", size = 14167408, upload-time = "2026-09-10T16:31:16.505Z" },
425
+ ]
426
+
427
+ [[package]]
428
+ name = "packaging"
429
+ version = "26.3"
430
+ source = { registry = "https://pypi.org/simple" }
431
+ sdist = { url = "https://files.pythonhosted.org/packages/7d/fa/3944b40b07da9ce895c0e6303a5ab7d53da063554f534556b134a54d6093/packaging-26.3.tar.gz", hash = "sha256:94edc256424af38762eb31306eed28beb9f0efc50a8837492c9d6fd6004aed79", size = 313412, upload-time = "2026-08-04T18:15:28.737Z" }
432
+ wheels = [
433
+ { url = "https://files.pythonhosted.org/packages/63/34/ba1c580383c9eada3711951fef0795c80b829a078d72188184bcab9dd527/packaging-26.3-py3-none-any.whl", hash = "sha256:d7193f7c8e4e93f444fde0262bf90af30e16fa0ad0ad44cb553c87339b23cd1c", size = 129956, upload-time = "2026-08-04T18:15:27.159Z" },
434
+ ]
435
+
436
+ [[package]]
437
+ name = "pillow"
438
+ version = "11.3.0"
439
+ source = { registry = "https://pypi.org/simple" }
440
+ sdist = { url = "https://files.pythonhosted.org/packages/f3/0d/d0d6dea55cd152ce3d6767bb38a8fc10e33796ba4ba210cbab9354b6d238/pillow-11.3.0.tar.gz", hash = "sha256:3828ee7586cd0b2091b6209e5ad53e20d0649bbe87164a459d0676e035e8f523", size = 47113069, upload-time = "2025-07-01T09:16:30.666Z" }
441
+ wheels = [
442
+ { url = "https://files.pythonhosted.org/packages/db/26/77f8ed17ca4ffd60e1dcd220a6ec6d71210ba398cfa33a13a1cd614c5613/pillow-11.3.0-cp311-cp311-macosx_10_10_x86_64.whl", hash = "sha256:1cd110edf822773368b396281a2293aeb91c90a2db00d78ea43e7e861631b722", size = 5316531, upload-time = "2025-07-01T09:13:59.203Z" },
443
+ { url = "https://files.pythonhosted.org/packages/cb/39/ee475903197ce709322a17a866892efb560f57900d9af2e55f86db51b0a5/pillow-11.3.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:9c412fddd1b77a75aa904615ebaa6001f169b26fd467b4be93aded278266b288", size = 4686560, upload-time = "2025-07-01T09:14:01.101Z" },
444
+ { url = "https://files.pythonhosted.org/packages/d5/90/442068a160fd179938ba55ec8c97050a612426fae5ec0a764e345839f76d/pillow-11.3.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:7d1aa4de119a0ecac0a34a9c8bde33f34022e2e8f99104e47a3ca392fd60e37d", size = 5870978, upload-time = "2025-07-03T13:09:55.638Z" },
445
+ { url = "https://files.pythonhosted.org/packages/13/92/dcdd147ab02daf405387f0218dcf792dc6dd5b14d2573d40b4caeef01059/pillow-11.3.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:91da1d88226663594e3f6b4b8c3c8d85bd504117d043740a8e0ec449087cc494", size = 7641168, upload-time = "2025-07-03T13:10:00.37Z" },
446
+ { url = "https://files.pythonhosted.org/packages/6e/db/839d6ba7fd38b51af641aa904e2960e7a5644d60ec754c046b7d2aee00e5/pillow-11.3.0-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:643f189248837533073c405ec2f0bb250ba54598cf80e8c1e043381a60632f58", size = 5973053, upload-time = "2025-07-01T09:14:04.491Z" },
447
+ { url = "https://files.pythonhosted.org/packages/f2/2f/d7675ecae6c43e9f12aa8d58b6012683b20b6edfbdac7abcb4e6af7a3784/pillow-11.3.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:106064daa23a745510dabce1d84f29137a37224831d88eb4ce94bb187b1d7e5f", size = 6640273, upload-time = "2025-07-01T09:14:06.235Z" },
448
+ { url = "https://files.pythonhosted.org/packages/45/ad/931694675ede172e15b2ff03c8144a0ddaea1d87adb72bb07655eaffb654/pillow-11.3.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:cd8ff254faf15591e724dc7c4ddb6bf4793efcbe13802a4ae3e863cd300b493e", size = 6082043, upload-time = "2025-07-01T09:14:07.978Z" },
449
+ { url = "https://files.pythonhosted.org/packages/3a/04/ba8f2b11fc80d2dd462d7abec16351b45ec99cbbaea4387648a44190351a/pillow-11.3.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:932c754c2d51ad2b2271fd01c3d121daaa35e27efae2a616f77bf164bc0b3e94", size = 6715516, upload-time = "2025-07-01T09:14:10.233Z" },
450
+ { url = "https://files.pythonhosted.org/packages/48/59/8cd06d7f3944cc7d892e8533c56b0acb68399f640786313275faec1e3b6f/pillow-11.3.0-cp311-cp311-win32.whl", hash = "sha256:b4b8f3efc8d530a1544e5962bd6b403d5f7fe8b9e08227c6b255f98ad82b4ba0", size = 6274768, upload-time = "2025-07-01T09:14:11.921Z" },
451
+ { url = "https://files.pythonhosted.org/packages/f1/cc/29c0f5d64ab8eae20f3232da8f8571660aa0ab4b8f1331da5c2f5f9a938e/pillow-11.3.0-cp311-cp311-win_amd64.whl", hash = "sha256:1a992e86b0dd7aeb1f053cd506508c0999d710a8f07b4c791c63843fc6a807ac", size = 6986055, upload-time = "2025-07-01T09:14:13.623Z" },
452
+ { url = "https://files.pythonhosted.org/packages/c6/df/90bd886fabd544c25addd63e5ca6932c86f2b701d5da6c7839387a076b4a/pillow-11.3.0-cp311-cp311-win_arm64.whl", hash = "sha256:30807c931ff7c095620fe04448e2c2fc673fcbb1ffe2a7da3fb39613489b1ddd", size = 2423079, upload-time = "2025-07-01T09:14:15.268Z" },
453
+ { url = "https://files.pythonhosted.org/packages/9e/e3/6fa84033758276fb31da12e5fb66ad747ae83b93c67af17f8c6ff4cc8f34/pillow-11.3.0-pp311-pypy311_pp73-macosx_10_15_x86_64.whl", hash = "sha256:7c8ec7a017ad1bd562f93dbd8505763e688d388cde6e4a010ae1486916e713e6", size = 5270566, upload-time = "2025-07-01T09:16:19.801Z" },
454
+ { url = "https://files.pythonhosted.org/packages/5b/ee/e8d2e1ab4892970b561e1ba96cbd59c0d28cf66737fc44abb2aec3795a4e/pillow-11.3.0-pp311-pypy311_pp73-macosx_11_0_arm64.whl", hash = "sha256:9ab6ae226de48019caa8074894544af5b53a117ccb9d3b3dcb2871464c829438", size = 4654618, upload-time = "2025-07-01T09:16:21.818Z" },
455
+ { url = "https://files.pythonhosted.org/packages/f2/6d/17f80f4e1f0761f02160fc433abd4109fa1548dcfdca46cfdadaf9efa565/pillow-11.3.0-pp311-pypy311_pp73-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:fe27fb049cdcca11f11a7bfda64043c37b30e6b91f10cb5bab275806c32f6ab3", size = 4874248, upload-time = "2025-07-03T13:11:20.738Z" },
456
+ { url = "https://files.pythonhosted.org/packages/de/5f/c22340acd61cef960130585bbe2120e2fd8434c214802f07e8c03596b17e/pillow-11.3.0-pp311-pypy311_pp73-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:465b9e8844e3c3519a983d58b80be3f668e2a7a5db97f2784e7079fbc9f9822c", size = 6583963, upload-time = "2025-07-03T13:11:26.283Z" },
457
+ { url = "https://files.pythonhosted.org/packages/31/5e/03966aedfbfcbb4d5f8aa042452d3361f325b963ebbadddac05b122e47dd/pillow-11.3.0-pp311-pypy311_pp73-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5418b53c0d59b3824d05e029669efa023bbef0f3e92e75ec8428f3799487f361", size = 4957170, upload-time = "2025-07-01T09:16:23.762Z" },
458
+ { url = "https://files.pythonhosted.org/packages/cc/2d/e082982aacc927fc2cab48e1e731bdb1643a1406acace8bed0900a61464e/pillow-11.3.0-pp311-pypy311_pp73-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:504b6f59505f08ae014f724b6207ff6222662aab5cc9542577fb084ed0676ac7", size = 5581505, upload-time = "2025-07-01T09:16:25.593Z" },
459
+ { url = "https://files.pythonhosted.org/packages/34/e7/ae39f538fd6844e982063c3a5e4598b8ced43b9633baa3a85ef33af8c05c/pillow-11.3.0-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:c84d689db21a1c397d001aa08241044aa2069e7587b398c8cc63020390b1c1b8", size = 6984598, upload-time = "2025-07-01T09:16:27.732Z" },
460
+ ]
461
+
462
+ [[package]]
463
+ name = "protobuf"
464
+ version = "7.36.2"
465
+ source = { registry = "https://pypi.org/simple" }
466
+ sdist = { url = "https://files.pythonhosted.org/packages/d9/89/5b8517baa72f84a67b8a307ba953c91057af618bf40bf676f3c03551f8f0/protobuf-7.36.2.tar.gz", hash = "sha256:497d0463ff3316681da6c0b9e8d06cb465d61abce00b613ab42226175644d1bb", size = 512737, upload-time = "2026-09-17T20:07:59.326Z" }
467
+ wheels = [
468
+ { url = "https://files.pythonhosted.org/packages/32/72/98342feb672507c8f3a69e34b4fa8961f608edba5c1a48a6f47156d92cb5/protobuf-7.36.2-cp310-abi3-macosx_10_9_universal2.whl", hash = "sha256:cbc70b17ee27e28894c7fee8bb04be1abead49e936bc70eb60052531eee2079e", size = 456039, upload-time = "2026-09-17T20:07:51.542Z" },
469
+ { url = "https://files.pythonhosted.org/packages/b6/ea/91fdf7c2b8bbd49cde056f00a9df6773532987e1c00fe2830b895af95c7e/protobuf-7.36.2-cp310-abi3-manylinux2014_aarch64.whl", hash = "sha256:e11e1f0180583a2af89db6a2ecd9e8dc40aa6d2988ca175bfd0e6d12ea72d74e", size = 344219, upload-time = "2026-09-17T20:07:52.914Z" },
470
+ { url = "https://files.pythonhosted.org/packages/17/ab/5fd5f8ece73fad885c5a09aa849b32d70472f954ba3a92d3bb5974ea953b/protobuf-7.36.2-cp310-abi3-manylinux2014_s390x.whl", hash = "sha256:f4fee11ec330d238b34a05c9b675f693c20415d1c5bd7d5320cc2f8a798eb9cf", size = 357223, upload-time = "2026-09-17T20:07:53.985Z" },
471
+ { url = "https://files.pythonhosted.org/packages/db/f3/3996583dd2906297a637af12114deddf7658af6e683fedb83be061983fb5/protobuf-7.36.2-cp310-abi3-manylinux2014_x86_64.whl", hash = "sha256:89f23aa53c24553a2416fd4fd1ec06f74fa42b14b546d8883128813f775bbfd2", size = 343223, upload-time = "2026-09-17T20:07:54.931Z" },
472
+ { url = "https://files.pythonhosted.org/packages/fc/1b/dcc64f358fcb51811b58ae40b3d28f820725f116d86487cc20bd4b130701/protobuf-7.36.2-cp310-abi3-win32.whl", hash = "sha256:912c1221170e16c08d1f086762f563dd61ff83c18b5fa6652952dfaded66f728", size = 442998, upload-time = "2026-09-17T20:07:55.826Z" },
473
+ { url = "https://files.pythonhosted.org/packages/8a/55/b77bda4e5e5f5971fb51b07663694690e9afdb9402136c16a522bd621cad/protobuf-7.36.2-cp310-abi3-win_amd64.whl", hash = "sha256:a300819d441e078a5608c0d3c709796bb548136058fda017ae51d425b44fd353", size = 456514, upload-time = "2026-09-17T20:07:57.188Z" },
474
+ { url = "https://files.pythonhosted.org/packages/e4/04/d52c7016b04b6c5108f26691f9d33ec82a9b65d041f1a9c771137693d618/protobuf-7.36.2-py3-none-any.whl", hash = "sha256:bdb3a345d48db958e6ce1f18e508beb0cc981d64f24088427549c866cd039f1e", size = 179806, upload-time = "2026-09-17T20:07:58.211Z" },
475
+ ]
476
+
477
+ [[package]]
478
+ name = "pyyaml"
479
+ version = "6.0.3"
480
+ source = { registry = "https://pypi.org/simple" }
481
+ sdist = { url = "https://files.pythonhosted.org/packages/05/8e/961c0007c59b8dd7729d542c61a4d537767a59645b82a0b521206e1e25c2/pyyaml-6.0.3.tar.gz", hash = "sha256:d76623373421df22fb4cf8817020cbb7ef15c725b9d5e45f17e189bfc384190f", size = 130960, upload-time = "2025-09-25T21:33:16.546Z" }
482
+ wheels = [
483
+ { url = "https://files.pythonhosted.org/packages/6d/16/a95b6757765b7b031c9374925bb718d55e0a9ba8a1b6a12d25962ea44347/pyyaml-6.0.3-cp311-cp311-macosx_10_13_x86_64.whl", hash = "sha256:44edc647873928551a01e7a563d7452ccdebee747728c1080d881d68af7b997e", size = 185826, upload-time = "2025-09-25T21:31:58.655Z" },
484
+ { url = "https://files.pythonhosted.org/packages/16/19/13de8e4377ed53079ee996e1ab0a9c33ec2faf808a4647b7b4c0d46dd239/pyyaml-6.0.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:652cb6edd41e718550aad172851962662ff2681490a8a711af6a4d288dd96824", size = 175577, upload-time = "2025-09-25T21:32:00.088Z" },
485
+ { url = "https://files.pythonhosted.org/packages/0c/62/d2eb46264d4b157dae1275b573017abec435397aa59cbcdab6fc978a8af4/pyyaml-6.0.3-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:10892704fc220243f5305762e276552a0395f7beb4dbf9b14ec8fd43b57f126c", size = 775556, upload-time = "2025-09-25T21:32:01.31Z" },
486
+ { url = "https://files.pythonhosted.org/packages/10/cb/16c3f2cf3266edd25aaa00d6c4350381c8b012ed6f5276675b9eba8d9ff4/pyyaml-6.0.3-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:850774a7879607d3a6f50d36d04f00ee69e7fc816450e5f7e58d7f17f1ae5c00", size = 882114, upload-time = "2025-09-25T21:32:03.376Z" },
487
+ { url = "https://files.pythonhosted.org/packages/71/60/917329f640924b18ff085ab889a11c763e0b573da888e8404ff486657602/pyyaml-6.0.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:b8bb0864c5a28024fac8a632c443c87c5aa6f215c0b126c449ae1a150412f31d", size = 806638, upload-time = "2025-09-25T21:32:04.553Z" },
488
+ { url = "https://files.pythonhosted.org/packages/dd/6f/529b0f316a9fd167281a6c3826b5583e6192dba792dd55e3203d3f8e655a/pyyaml-6.0.3-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:1d37d57ad971609cf3c53ba6a7e365e40660e3be0e5175fa9f2365a379d6095a", size = 767463, upload-time = "2025-09-25T21:32:06.152Z" },
489
+ { url = "https://files.pythonhosted.org/packages/f2/6a/b627b4e0c1dd03718543519ffb2f1deea4a1e6d42fbab8021936a4d22589/pyyaml-6.0.3-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:37503bfbfc9d2c40b344d06b2199cf0e96e97957ab1c1b546fd4f87e53e5d3e4", size = 794986, upload-time = "2025-09-25T21:32:07.367Z" },
490
+ { url = "https://files.pythonhosted.org/packages/45/91/47a6e1c42d9ee337c4839208f30d9f09caa9f720ec7582917b264defc875/pyyaml-6.0.3-cp311-cp311-win32.whl", hash = "sha256:8098f252adfa6c80ab48096053f512f2321f0b998f98150cea9bd23d83e1467b", size = 142543, upload-time = "2025-09-25T21:32:08.95Z" },
491
+ { url = "https://files.pythonhosted.org/packages/da/e3/ea007450a105ae919a72393cb06f122f288ef60bba2dc64b26e2646fa315/pyyaml-6.0.3-cp311-cp311-win_amd64.whl", hash = "sha256:9f3bfb4965eb874431221a3ff3fdcddc7e74e3b07799e0e84ca4a0f867d449bf", size = 158763, upload-time = "2025-09-25T21:32:09.96Z" },
492
+ ]
493
+
494
+ [[package]]
495
+ name = "requests"
496
+ version = "2.34.2"
497
+ source = { registry = "https://pypi.org/simple" }
498
+ dependencies = [
499
+ { name = "certifi" },
500
+ { name = "charset-normalizer" },
501
+ { name = "idna" },
502
+ { name = "urllib3" },
503
+ ]
504
+ sdist = { url = "https://files.pythonhosted.org/packages/ac/c3/e2a2b89f2d3e2179abd6d00ebd70bff6273f37fb3e0cc209f48b39d00cbf/requests-2.34.2.tar.gz", hash = "sha256:f288924cae4e29463698d6d60bc6a4da69c89185ad1e0bcc4104f584e960b9ed", size = 142856, upload-time = "2026-05-14T19:25:27.735Z" }
505
+ wheels = [
506
+ { url = "https://files.pythonhosted.org/packages/a0/f4/c67b0b3f1b9245e8d266f0f112c500d50e5b4e83cb6f3b71b6528104182a/requests-2.34.2-py3-none-any.whl", hash = "sha256:2a0d60c172f83ac6ab31e4554906c0f3b3588d37b5cb939b1c061f4907e278e0", size = 73075, upload-time = "2026-05-14T19:25:26.443Z" },
507
+ ]
508
+
509
+ [[package]]
510
+ name = "safetensors"
511
+ version = "0.8.0"
512
+ source = { registry = "https://pypi.org/simple" }
513
+ sdist = { url = "https://files.pythonhosted.org/packages/45/06/f955dbbb1859e3bd23c8ac6141af5106e7ad5fedec4a3a6e3d60f94b7001/safetensors-0.8.0.tar.gz", hash = "sha256:fabaf3e0f18a6618d9b36560682562157f77c2b71fcffc7b432be2baed9d753d", size = 325846, upload-time = "2026-06-09T07:52:25.563Z" }
514
+ wheels = [
515
+ { url = "https://files.pythonhosted.org/packages/39/a0/f718cda65b05407d228f97602cf60dca269c979867aa5beb25410de26cd3/safetensors-0.8.0-cp310-abi3-macosx_10_12_x86_64.whl", hash = "sha256:c554f85858e05226d3c2828e32395e677434685d6d94594a41643361c5e837f0", size = 473568, upload-time = "2026-06-09T07:52:18.829Z" },
516
+ { url = "https://files.pythonhosted.org/packages/f5/b1/fa7c600e7dceae12e9606c7578cbc9ff1e1ed55844883ee5c92205e86226/safetensors-0.8.0-cp310-abi3-macosx_11_0_arm64.whl", hash = "sha256:c80201d22cbf405b80647a60ada77bba06c8fba2da2743ba1e89cdcc39a81f25", size = 484562, upload-time = "2026-06-09T07:52:17.518Z" },
517
+ { url = "https://files.pythonhosted.org/packages/09/7d/65a7de0af421317bb36a067241e4235fff194eed60b961ed6d3f59a3fc60/safetensors-0.8.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7a46e5ff292c356d6991e60942ba7f79817682d3a2cef0702136448cb9c4d235", size = 502844, upload-time = "2026-06-09T07:52:07.624Z" },
518
+ { url = "https://files.pythonhosted.org/packages/91/4f/3175c9d75634e0e0dda0082794193521035edd7c70a6f212bf33ca06ddf4/safetensors-0.8.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:4124502b78f03534117c848f87a39b8f31e577b15eff423bf8bfb95f2a8c30d0", size = 511823, upload-time = "2026-06-09T07:52:09.565Z" },
519
+ { url = "https://files.pythonhosted.org/packages/20/87/846c289e7aa2299eff406335717cf43ce8777194ece8aad75772e0411615/safetensors-0.8.0-cp310-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:7bc0a787ba8a35be368ee3574edfa2b1ad389eebd0a72e482ae275490e3f6c98", size = 633461, upload-time = "2026-06-09T07:52:11.128Z" },
520
+ { url = "https://files.pythonhosted.org/packages/76/22/8d64d9df2c45d5ded401df889d0ad90882804ca172d79ec4f0df8f727fe0/safetensors-0.8.0-cp310-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:040070828e36dc8e122178bbbd5830ff9e97920affb84cbe0f46442497bed358", size = 545148, upload-time = "2026-06-09T07:52:13.603Z" },
521
+ { url = "https://files.pythonhosted.org/packages/28/50/f203ff3a3ddfe19308efc83c5a3a29ed02bf786732ec35e68bf9162f3365/safetensors-0.8.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fd6f3f93c9a0a7cc2788ee63fb763353d4bd2e89b0751bc78fcf7dda00bea774", size = 516040, upload-time = "2026-06-09T07:52:16.29Z" },
522
+ { url = "https://files.pythonhosted.org/packages/46/fb/cdaed17ceb2948784fd9c36b6fd3e951b608547cea81a48e8ee6f8cfdfcb/safetensors-0.8.0-cp310-abi3-manylinux_2_31_riscv64.whl", hash = "sha256:fcdd41ec4628fee5799f807c73c353629130fbd942aa23d83c623dd6c9d52d78", size = 513832, upload-time = "2026-06-09T07:52:12.37Z" },
523
+ { url = "https://files.pythonhosted.org/packages/0d/49/1e15de264dcc3b77943d2d0c56a95809956883b1c2d6d585c792523f180b/safetensors-0.8.0-cp310-abi3-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:8e9f537aa183a38ace122d27303dcd986b26bd2a7591f9181d7f0c396f4677ca", size = 559930, upload-time = "2026-06-09T07:52:14.743Z" },
524
+ { url = "https://files.pythonhosted.org/packages/2a/43/bf38443278eab4b1be1fce2931e2b012ad9cb7df52ada751d0aab8f7659a/safetensors-0.8.0-cp310-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:87eec7ffed2b809f05a398a8becb7d013f19f7837cd15d9748580d6cf30dbaf4", size = 678670, upload-time = "2026-06-09T07:52:20.032Z" },
525
+ { url = "https://files.pythonhosted.org/packages/72/e3/68cd3fa5b48488e84add63e04cb12f3bc28ae4638c06d4508c6e88823d0e/safetensors-0.8.0-cp310-abi3-musllinux_1_2_armv7l.whl", hash = "sha256:4a95ae2b05d7726d751da4ebf626a2ca782b706e101bd894c95bc2450b1cffcc", size = 786679, upload-time = "2026-06-09T07:52:21.322Z" },
526
+ { url = "https://files.pythonhosted.org/packages/29/4b/1c19c509d56e01f4fbb3d0a2e597450f6cc04d1d56cf52defb0a62dfd715/safetensors-0.8.0-cp310-abi3-musllinux_1_2_i686.whl", hash = "sha256:3ae091f16662658bdc019a4ff6cb4c085bb7d725eb5978b183ffd265863b6d2d", size = 765683, upload-time = "2026-06-09T07:52:22.594Z" },
527
+ { url = "https://files.pythonhosted.org/packages/27/43/41c1621732edd934d868a00d1b891584c892a7b62a9aab82ea5a0a5623ee/safetensors-0.8.0-cp310-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:8e080062fcde23be189565e1c3305d16751a218ecf9412c8601e64204eb6f846", size = 722361, upload-time = "2026-06-09T07:52:23.924Z" },
528
+ { url = "https://files.pythonhosted.org/packages/8e/3f/73ccf82579412b4a71c4ca673f10b5f1f888d7cf5af7fe24f27d30307be4/safetensors-0.8.0-cp310-abi3-win32.whl", hash = "sha256:2ddf52eac562eda224f99acfa7889d02968c1fd59a5b011ae7d8137c37e9c02d", size = 342401, upload-time = "2026-06-09T07:52:28.895Z" },
529
+ { url = "https://files.pythonhosted.org/packages/1b/6d/3fba214c1e5e0f69991677ec3bc17023f0421776975e1de0c682dca475e2/safetensors-0.8.0-cp310-abi3-win_amd64.whl", hash = "sha256:096ec1a98435df7beb08853bb5aa9081a84f23d0adc67ed1a0a10550f608373f", size = 355540, upload-time = "2026-06-09T07:52:27.832Z" },
530
+ { url = "https://files.pythonhosted.org/packages/8d/fc/7eedc3510d97878876e32774eebbeb61c43f148a96e915c84229a3e967aa/safetensors-0.8.0-cp310-abi3-win_arm64.whl", hash = "sha256:f7838e5135a406ad3e02efdcb8cf2e5397d368b0154537c4fec682dbc544d452", size = 340500, upload-time = "2026-06-09T07:52:26.745Z" },
531
+ ]
532
+
533
+ [[package]]
534
+ name = "setuptools"
535
+ version = "84.0.0"
536
+ source = { registry = "https://pypi.org/simple" }
537
+ sdist = { url = "https://files.pythonhosted.org/packages/6d/44/f5da03a8ef95d369145c5bb53050e7877c9f3d312e128605fd9504829143/setuptools-84.0.0.tar.gz", hash = "sha256:f4695c21257f0d9b537ec2692c941d02ee143b7cc1276941349a546573b2ef73", size = 1168449, upload-time = "2026-08-08T18:27:58.365Z" }
538
+ wheels = [
539
+ { url = "https://files.pythonhosted.org/packages/95/9c/c510029fc6ef33a6275cd2c5d3cecd6613dfd6aa401d57c54f1c18852ccf/setuptools-84.0.0-py3-none-any.whl", hash = "sha256:51a52592b3b99e102b609654876bd65f19f999935166d1352678931132b0c670", size = 818216, upload-time = "2026-08-08T18:27:56.719Z" },
540
+ ]
541
+
542
+ [[package]]
543
+ name = "sympy"
544
+ version = "1.14.0"
545
+ source = { registry = "https://pypi.org/simple" }
546
+ dependencies = [
547
+ { name = "mpmath" },
548
+ ]
549
+ sdist = { url = "https://files.pythonhosted.org/packages/83/d3/803453b36afefb7c2bb238361cd4ae6125a569b4db67cd9e79846ba2d68c/sympy-1.14.0.tar.gz", hash = "sha256:d3d3fe8df1e5a0b42f0e7bdf50541697dbe7d23746e894990c030e2b05e72517", size = 7793921, upload-time = "2025-04-27T18:05:01.611Z" }
550
+ wheels = [
551
+ { url = "https://files.pythonhosted.org/packages/a2/09/77d55d46fd61b4a135c444fc97158ef34a095e5681d0a6c10b75bf356191/sympy-1.14.0-py3-none-any.whl", hash = "sha256:e091cc3e99d2141a0ba2847328f5479b05d94a6635cb96148ccb3f34671bd8f5", size = 6299353, upload-time = "2025-04-27T18:04:59.103Z" },
552
+ ]
553
+
554
+ [[package]]
555
+ name = "timm"
556
+ version = "1.0.20"
557
+ source = { registry = "https://pypi.org/simple" }
558
+ dependencies = [
559
+ { name = "huggingface-hub" },
560
+ { name = "pyyaml" },
561
+ { name = "safetensors" },
562
+ { name = "torch" },
563
+ { name = "torchvision" },
564
+ ]
565
+ sdist = { url = "https://files.pythonhosted.org/packages/b5/ba/6f5d96622a4a9fc315da53f58b3ca224c66015efe40aa191df0d523ede7c/timm-1.0.20.tar.gz", hash = "sha256:7468d32a410c359181c1ef961f49c7e213286e0c342bfb898b99534a4221fc54", size = 2360052, upload-time = "2025-09-21T17:26:35.492Z" }
566
+ wheels = [
567
+ { url = "https://files.pythonhosted.org/packages/c5/74/5573615570bf010f788e977ac57c4b49db0aaf6d634134f6a9212d8dcdfd/timm-1.0.20-py3-none-any.whl", hash = "sha256:f6e62f780358476691996c47aa49de87b95cc507edf923c3042f74a07e45b7fe", size = 2504047, upload-time = "2025-09-21T17:26:33.487Z" },
568
+ ]
569
+
570
+ [[package]]
571
+ name = "torch"
572
+ version = "2.8.0"
573
+ source = { registry = "https://pypi.org/simple" }
574
+ dependencies = [
575
+ { name = "filelock" },
576
+ { name = "fsspec" },
577
+ { name = "jinja2" },
578
+ { name = "networkx" },
579
+ { name = "nvidia-cublas-cu12", marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" },
580
+ { name = "nvidia-cuda-cupti-cu12", marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" },
581
+ { name = "nvidia-cuda-nvrtc-cu12", marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" },
582
+ { name = "nvidia-cuda-runtime-cu12", marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" },
583
+ { name = "nvidia-cudnn-cu12", marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" },
584
+ { name = "nvidia-cufft-cu12", marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" },
585
+ { name = "nvidia-cufile-cu12", marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" },
586
+ { name = "nvidia-curand-cu12", marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" },
587
+ { name = "nvidia-cusolver-cu12", marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" },
588
+ { name = "nvidia-cusparse-cu12", marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" },
589
+ { name = "nvidia-cusparselt-cu12", marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" },
590
+ { name = "nvidia-nccl-cu12", marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" },
591
+ { name = "nvidia-nvjitlink-cu12", marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" },
592
+ { name = "nvidia-nvtx-cu12", marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" },
593
+ { name = "sympy" },
594
+ { name = "triton", marker = "platform_machine == 'x86_64' and sys_platform == 'linux'" },
595
+ { name = "typing-extensions" },
596
+ ]
597
+ wheels = [
598
+ { url = "https://files.pythonhosted.org/packages/8f/c4/3e7a3887eba14e815e614db70b3b529112d1513d9dae6f4d43e373360b7f/torch-2.8.0-cp311-cp311-manylinux_2_28_aarch64.whl", hash = "sha256:220a06fd7af8b653c35d359dfe1aaf32f65aa85befa342629f716acb134b9710", size = 102073391, upload-time = "2025-08-06T14:53:20.937Z" },
599
+ { url = "https://files.pythonhosted.org/packages/5a/63/4fdc45a0304536e75a5e1b1bbfb1b56dd0e2743c48ee83ca729f7ce44162/torch-2.8.0-cp311-cp311-manylinux_2_28_x86_64.whl", hash = "sha256:c12fa219f51a933d5f80eeb3a7a5d0cbe9168c0a14bbb4055f1979431660879b", size = 888063640, upload-time = "2025-08-06T14:55:05.325Z" },
600
+ { url = "https://files.pythonhosted.org/packages/84/57/2f64161769610cf6b1c5ed782bd8a780e18a3c9d48931319f2887fa9d0b1/torch-2.8.0-cp311-cp311-win_amd64.whl", hash = "sha256:8c7ef765e27551b2fbfc0f41bcf270e1292d9bf79f8e0724848b1682be6e80aa", size = 241366752, upload-time = "2025-08-06T14:53:38.692Z" },
601
+ { url = "https://files.pythonhosted.org/packages/a4/5e/05a5c46085d9b97e928f3f037081d3d2b87fb4b4195030fc099aaec5effc/torch-2.8.0-cp311-none-macosx_11_0_arm64.whl", hash = "sha256:5ae0524688fb6707c57a530c2325e13bb0090b745ba7b4a2cd6a3ce262572916", size = 73621174, upload-time = "2025-08-06T14:53:25.44Z" },
602
+ ]
603
+
604
+ [[package]]
605
+ name = "torchvision"
606
+ version = "0.23.0"
607
+ source = { registry = "https://pypi.org/simple" }
608
+ dependencies = [
609
+ { name = "numpy" },
610
+ { name = "pillow" },
611
+ { name = "torch" },
612
+ ]
613
+ wheels = [
614
+ { url = "https://files.pythonhosted.org/packages/f0/d7/15d3d7bd8d0239211b21673d1bac7bc345a4ad904a8e25bb3fd8a9cf1fbc/torchvision-0.23.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:49aa20e21f0c2bd458c71d7b449776cbd5f16693dd5807195a820612b8a229b7", size = 1856884, upload-time = "2025-08-06T14:58:00.237Z" },
615
+ { url = "https://files.pythonhosted.org/packages/dd/14/7b44fe766b7d11e064c539d92a172fa9689a53b69029e24f2f1f51e7dc56/torchvision-0.23.0-cp311-cp311-manylinux_2_28_aarch64.whl", hash = "sha256:01dc33ee24c79148aee7cdbcf34ae8a3c9da1674a591e781577b716d233b1fa6", size = 2395543, upload-time = "2025-08-06T14:58:04.373Z" },
616
+ { url = "https://files.pythonhosted.org/packages/79/9c/fcb09aff941c8147d9e6aa6c8f67412a05622b0c750bcf796be4c85a58d4/torchvision-0.23.0-cp311-cp311-manylinux_2_28_x86_64.whl", hash = "sha256:35c27941831b653f5101edfe62c03d196c13f32139310519e8228f35eae0e96a", size = 8628388, upload-time = "2025-08-06T14:58:07.802Z" },
617
+ { url = "https://files.pythonhosted.org/packages/93/40/3415d890eb357b25a8e0a215d32365a88ecc75a283f75c4e919024b22d97/torchvision-0.23.0-cp311-cp311-win_amd64.whl", hash = "sha256:09bfde260e7963a15b80c9e442faa9f021c7e7f877ac0a36ca6561b367185013", size = 1600741, upload-time = "2025-08-06T14:57:59.158Z" },
618
+ ]
619
+
620
+ [[package]]
621
+ name = "tqdm"
622
+ version = "4.70.1"
623
+ source = { registry = "https://pypi.org/simple" }
624
+ dependencies = [
625
+ { name = "colorama", marker = "sys_platform == 'win32'" },
626
+ ]
627
+ sdist = { url = "https://files.pythonhosted.org/packages/0d/ea/b2a5bd54b28a324dae8211928b2d730b6547500342c7e6c6dea08bd0a485/tqdm-4.70.1.tar.gz", hash = "sha256:cefd0eca11b2a37a3aee776544d4f4ae913f02688135b5556b8788dfa474afc4", size = 171846, upload-time = "2026-09-11T07:25:16.601Z" }
628
+ wheels = [
629
+ { url = "https://files.pythonhosted.org/packages/a7/03/921a3d3c75785aca9ebfbfcabfbc3a1be12e2ab5265deb026d55a5a3f83e/tqdm-4.70.1-py3-none-any.whl", hash = "sha256:c293e525e6fef9c20e8728fd4612df02a0aa31bb5fe91ecd93e123b1b7bffa73", size = 80199, upload-time = "2026-09-11T07:25:14.599Z" },
630
+ ]
631
+
632
+ [[package]]
633
+ name = "triton"
634
+ version = "3.4.0"
635
+ source = { registry = "https://pypi.org/simple" }
636
+ dependencies = [
637
+ { name = "setuptools" },
638
+ ]
639
+ wheels = [
640
+ { url = "https://files.pythonhosted.org/packages/7d/39/43325b3b651d50187e591eefa22e236b2981afcebaefd4f2fc0ea99df191/triton-3.4.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7b70f5e6a41e52e48cfc087436c8a28c17ff98db369447bcaff3b887a3ab4467", size = 155531138, upload-time = "2025-07-30T19:58:29.908Z" },
641
+ ]
642
+
643
+ [[package]]
644
+ name = "typing-extensions"
645
+ version = "4.16.0"
646
+ source = { registry = "https://pypi.org/simple" }
647
+ sdist = { url = "https://files.pythonhosted.org/packages/f6/cc/6253133b5bb138fc3306cebfbda2c520f545d36b5be2c7255cc528bb45d6/typing_extensions-4.16.0.tar.gz", hash = "sha256:dc983d19a509c94dba722ee6abd33940f7c05a89e243c47e907eb4db6f1a43e5", size = 113555, upload-time = "2026-07-02T08:40:05.92Z" }
648
+ wheels = [
649
+ { url = "https://files.pythonhosted.org/packages/49/d3/b8441a820a491ddfc024b0b0cf0393375b75ea13866d9c66727e54c2fc80/typing_extensions-4.16.0-py3-none-any.whl", hash = "sha256:481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8", size = 45571, upload-time = "2026-07-02T08:40:04.659Z" },
650
+ ]
651
+
652
+ [[package]]
653
+ name = "urllib3"
654
+ version = "2.8.0"
655
+ source = { registry = "https://pypi.org/simple" }
656
+ sdist = { url = "https://files.pythonhosted.org/packages/e3/05/b17359e1cefb4f909b5e40b1b90a496d987258916dbbf88e842c729f510e/urllib3-2.8.0.tar.gz", hash = "sha256:63bf2ead4c879426ebf22ef2a781eeb4aa3b4ae798a0435506f8687fd5bb9b63", size = 458972, upload-time = "2026-09-15T19:29:36.253Z" }
657
+ wheels = [
658
+ { url = "https://files.pythonhosted.org/packages/92/9d/c4e665119135114480843e7ab388fa94d8480650450e6f8e26b70d323a4c/urllib3-2.8.0-py3-none-any.whl", hash = "sha256:0cf3cae568d36aa9576b28dfb35f11328f1cb974ca7647d9475ebb86c75ac6e3", size = 135717, upload-time = "2026-09-15T19:29:34.577Z" },
659
+ ]
weights/grid16.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:95a33468cbb03d022c34d85a3fbf913feeef5bcba25294b88530cf4d83f57d3c
3
+ size 51243220
weights/grid9.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9d93ace9418ebf60fe05f18e8e4cf1b665a565aa17af1cc233d6ec4d91ce2b0d
3
+ size 33692057