edgeval 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. edgeval-0.1.0/.gitignore +51 -0
  2. edgeval-0.1.0/LICENSE +196 -0
  3. edgeval-0.1.0/PKG-INFO +252 -0
  4. edgeval-0.1.0/README.md +219 -0
  5. edgeval-0.1.0/cxx/README.md +41 -0
  6. edgeval-0.1.0/cxx/__init__.py +0 -0
  7. edgeval-0.1.0/cxx/lib/__init__.py +0 -0
  8. edgeval-0.1.0/cxx/lib/solve_csa.so +0 -0
  9. edgeval-0.1.0/cxx/src/Exception.cc +43 -0
  10. edgeval-0.1.0/cxx/src/Exception.hh +55 -0
  11. edgeval-0.1.0/cxx/src/Random.cc +76 -0
  12. edgeval-0.1.0/cxx/src/Random.hh +131 -0
  13. edgeval-0.1.0/cxx/src/String.cc +193 -0
  14. edgeval-0.1.0/cxx/src/String.hh +145 -0
  15. edgeval-0.1.0/cxx/src/build.sh +1 -0
  16. edgeval-0.1.0/cxx/src/csa.cc +32 -0
  17. edgeval-0.1.0/cxx/src/csa.hh +2585 -0
  18. edgeval-0.1.0/cxx/src/csa_defs.h +229 -0
  19. edgeval-0.1.0/cxx/src/csa_types.h +215 -0
  20. edgeval-0.1.0/cxx/src/kofn.cc +69 -0
  21. edgeval-0.1.0/cxx/src/kofn.hh +9 -0
  22. edgeval-0.1.0/cxx/src/nms.cc +57 -0
  23. edgeval-0.1.0/cxx/src/solve.cc +15 -0
  24. edgeval-0.1.0/cxx/src/solve.h +10 -0
  25. edgeval-0.1.0/docs/benchmarks.md +64 -0
  26. edgeval-0.1.0/docs/optimization.md +48 -0
  27. edgeval-0.1.0/edgeval.egg-info/PKG-INFO +252 -0
  28. edgeval-0.1.0/edgeval.egg-info/SOURCES.txt +72 -0
  29. edgeval-0.1.0/edgeval.egg-info/dependency_links.txt +1 -0
  30. edgeval-0.1.0/edgeval.egg-info/entry_points.txt +2 -0
  31. edgeval-0.1.0/edgeval.egg-info/not-zip-safe +1 -0
  32. edgeval-0.1.0/edgeval.egg-info/requires.txt +6 -0
  33. edgeval-0.1.0/edgeval.egg-info/top_level.txt +2 -0
  34. edgeval-0.1.0/edgeval_cu/__init__.py +31 -0
  35. edgeval-0.1.0/edgeval_cu/__main__.py +5 -0
  36. edgeval-0.1.0/edgeval_cu/_dummy.c +2 -0
  37. edgeval-0.1.0/edgeval_cu/auction.py +308 -0
  38. edgeval-0.1.0/edgeval_cu/cli.py +224 -0
  39. edgeval-0.1.0/edgeval_cu/cpu_auction.py +180 -0
  40. edgeval-0.1.0/edgeval_cu/csa.py +445 -0
  41. edgeval-0.1.0/edgeval_cu/cuda/Makefile +27 -0
  42. edgeval-0.1.0/edgeval_cu/cuda/auction_kernel.cu +502 -0
  43. edgeval-0.1.0/edgeval_cu/cuda/edge_builder.cu +72 -0
  44. edgeval-0.1.0/edgeval_cu/edges_eval_plot.py +70 -0
  45. edgeval-0.1.0/edgeval_cu/eval.py +384 -0
  46. edgeval-0.1.0/edgeval_cu/eval_component.py +21 -0
  47. edgeval-0.1.0/edgeval_cu/eval_precise.py +137 -0
  48. edgeval-0.1.0/edgeval_cu/metrics.py +235 -0
  49. edgeval-0.1.0/edgeval_cu/nms_process.py +58 -0
  50. edgeval-0.1.0/edgeval_cu/nms_thin.py +201 -0
  51. edgeval-0.1.0/edgeval_cu/show.py +39 -0
  52. edgeval-0.1.0/edgeval_cu/toolbox.py +38 -0
  53. edgeval-0.1.0/pyproject.toml +58 -0
  54. edgeval-0.1.0/setup.cfg +4 -0
  55. edgeval-0.1.0/setup.py +166 -0
@@ -0,0 +1,51 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.pyo
5
+ *.egg-info/
6
+ dist/
7
+ build/
8
+ *.egg
9
+ *.so
10
+
11
+ # CUDA
12
+ *.fatbin
13
+ *.cubin
14
+
15
+ # IDE
16
+ .vscode/
17
+ .idea/
18
+ *.swp
19
+ *.swo
20
+ *~
21
+
22
+ # OS
23
+ .DS_Store
24
+ Thumbs.db
25
+
26
+ # Edge evaluation output
27
+ *-eval/
28
+ *-eval-*/
29
+ *-eval-gpu/
30
+
31
+ # Benchmark and test artifacts
32
+ benchmark_*.py
33
+ test_*.py
34
+ single_img_benchmark.py
35
+ run_hed_benchmark.py
36
+ generate_chart.py
37
+ *.json
38
+ *.npy
39
+ *.html
40
+ gpu_eval_precise.py
41
+
42
+ # Compiled libraries (keep source .cu and .cc, ignore local builds)
43
+ cxx/lib/*.so
44
+ cxx/cxx
45
+ cxx/lib/lib
46
+ gpu_eval/auction_cuda.so
47
+
48
+ # Environment
49
+ .env
50
+ .venv/
51
+ venv/
edgeval-0.1.0/LICENSE ADDED
@@ -0,0 +1,196 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, and merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by
174
+ reason of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ If you develop a new file, and you want it to be of the greatest
181
+ possible use to the public, we recommend making it Apache-2.0.
182
+ To do so, attach the following boilerplate notice:
183
+
184
+ Copyright 2026 0xrjman
185
+
186
+ Licensed under the Apache License, Version 2.0 (the "License");
187
+ you may not use this file except in compliance with the License.
188
+ You may obtain a copy of the License at
189
+
190
+ http://www.apache.org/licenses/LICENSE-2.0
191
+
192
+ Unless required by applicable law or agreed to in writing, software
193
+ distributed under the License is distributed on an "AS IS" BASIS,
194
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
195
+ See the License for the specific language governing permissions and
196
+ limitations under the License.
edgeval-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,252 @@
1
+ Metadata-Version: 2.4
2
+ Name: edgeval
3
+ Version: 0.1.0
4
+ Summary: GPU-accelerated edge detection evaluation (ODS/OIS/AP/R50)
5
+ Home-page: https://github.com/0xrjman/edgeval.cu
6
+ Author: 0xrjman & Contributors
7
+ License: Apache-2.0
8
+ Project-URL: Homepage, https://github.com/0xrjman/edgeval.cu
9
+ Project-URL: Repository, https://github.com/0xrjman/edgeval.cu
10
+ Keywords: edge-detection,evaluation,cuda,gpu,ods,ois,bsds500
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Topic :: Scientific/Engineering :: Image Processing
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Requires-Python: >=3.8
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: numpy
25
+ Requires-Dist: scipy>=1.6.0
26
+ Requires-Dist: opencv-python
27
+ Requires-Dist: tqdm
28
+ Requires-Dist: click
29
+ Requires-Dist: torch>=2.0
30
+ Dynamic: home-page
31
+ Dynamic: license-file
32
+ Dynamic: requires-python
33
+
34
+ <p align="center">
35
+ <img src="https://img.shields.io/badge/Python-3.8+-blue?logo=python" alt="Python">
36
+ <img src="https://img.shields.io/badge/CUDA-12.x-76B900?logo=nvidia" alt="CUDA">
37
+ <img src="https://img.shields.io/badge/license-Apache%202.0-blue" alt="License">
38
+ </p>
39
+
40
+ <p align="center">
41
+ <h1 align="center">edgeval.cu</h1>
42
+ <p align="center">GPU-accelerated edge detection evaluation</p>
43
+ <p align="center"><strong>20 min → 1.6 min</strong> on BSDS500 &nbsp;|&nbsp; <strong>12.8×</strong> faster than CPU</p>
44
+ </p>
45
+
46
+ ---
47
+
48
+ ## What Problem Does This Solve?
49
+
50
+ Evaluating an edge detection model on BSDS500 means solving **~99,000 independent assignment problems** — matching every predicted edge pixel to every ground truth pixel, at 99 thresholds, across 5 human annotations, for 200 images.
51
+
52
+ The standard CPU pipeline takes **20 minutes**. That's fine for a final paper. It's terrible when you're training and want to check your model's progress every few epochs.
53
+
54
+ **edgeval.cu** brings it down to **1.6 minutes** — fast enough to run every epoch without slowing down training.
55
+
56
+ ---
57
+
58
+ ## How It Works
59
+
60
+ Edge matching is a **minimum-cost bipartite assignment problem**:
61
+
62
+ ```
63
+ Predicted edges ──→ Match (cost = distance) ←── Ground truth edges
64
+ Or pay outlier penalty
65
+ ```
66
+
67
+ We solve it with the **Auction Algorithm** (Bertsekas, 1979), perfectly suited for GPU parallelism. Each predicted pixel iteratively bids on ground truth pixels; the highest bidder wins each round. Repeat until convergence.
68
+
69
+ ```mermaid
70
+ flowchart LR
71
+ subgraph Input["📥 Input"]
72
+ EP["Edge Map\n.png"]
73
+ GT["Ground Truth\n.mat"]
74
+ end
75
+
76
+ subgraph Pre["🎯 Preprocessing"]
77
+ THR["99 Thresholds"]
78
+ THIN["Zhang-Suen\nThinning"]
79
+ end
80
+
81
+ subgraph Graph["🔗 Graph Construction"]
82
+ EDGE["CUDA Edge Builder\nSingle Kernel Launch"]
83
+ SORT["GPU Sort + Split\nby Annotator"]
84
+ end
85
+
86
+ subgraph Solve["⚔️ Solver"]
87
+ AUCT["Auction Algorithm\nε-Scaling 8→0\n485 problems/parallel"]
88
+ end
89
+
90
+ subgraph Out["📊 Output"]
91
+ ODS["ODS · OIS"]
92
+ AP["AP · R50"]
93
+ end
94
+
95
+ EP --> THR --> THIN --> EDGE
96
+ GT -.-> EDGE
97
+ EDGE --> SORT --> AUCT --> ODS
98
+ AUCT --> AP
99
+ ```
100
+
101
+ ### ε-Scaling Strategy
102
+
103
+ ```
104
+ ε = 8 → coarse solution in ~100 rounds
105
+ ε = 4 → refine in ~200 rounds
106
+ ε = 2 → refine in ~400 rounds
107
+ ε = 1 → refine in ~500 rounds
108
+ ε = 0 → exact optimality in ~300 rounds ← tuned!
109
+ ```
110
+
111
+ Most problems converge within 200-300 rounds at ε=0. We detect convergence by counting **consecutive** no-change rounds — avoiding the trap of mistaking temporary bid-stalemates for convergence.
112
+
113
+ ### Two Modes for Two Needs
114
+
115
+ | | Simple (Training) | Extended (Paper) |
116
+ |---|---|---|
117
+ | Graph | Bipartite, real edges only | n×n, kOfN + diagonal overlay |
118
+ | Speed | **0.47s/img** | ~5.7s/img |
119
+ | ΔODS vs reference | +0.003 | <0.001 |
120
+ | Use case | Every-epoch monitoring | Final evaluation |
121
+
122
+ ---
123
+
124
+ ## Performance
125
+
126
+ <p align="center">
127
+ <strong>BSDS500 — 200 images, 99 thresholds, RTX 4090</strong>
128
+ </p>
129
+
130
+ | | CPU CSA (MATLAB) | GPU Simple | Speedup |
131
+ |---|---|---|---|
132
+ | Per image | ~6s | **0.47s** | **12.8×** |
133
+ | Full dataset | ~20 min | **1.6 min** | **12.8×** |
134
+ | ODS accuracy | 0 (reference) | Δ = +0.003 | Stable |
135
+
136
+ ### Pipeline Breakdown
137
+
138
+ ```
139
+ GPU Thinning ████████░░░░░░░░░░░░ 0.12s (25%)
140
+ Edge Builder █░░░░░░░░░░░░░░░░░░░ 0.02s ( 4%)
141
+ GPU Sort+Split █████░░░░░░░░░░░░░░░ 0.08s (17%)
142
+ Problem Build ██░░░░░░░░░░░░░░░░░░ 0.04s ( 9%)
143
+ Auction Solve ██████████░░░░░░░░░░ 0.14s (30%)
144
+ Overhead █████░░░░░░░░░░░░░░░ 0.07s (15%)
145
+ ────────────────────
146
+ TOTAL 0.47s
147
+ ```
148
+
149
+ > Detailed breakdown and configuration sweep: [docs/benchmarks.md](docs/benchmarks.md)
150
+
151
+ ---
152
+
153
+ ## Quick Start
154
+
155
+ ```bash
156
+ pip install edgeval
157
+ ```
158
+
159
+ Requires Python 3.8+, PyTorch, CUDA toolkit (nvcc), NumPy, SciPy, OpenCV, tqdm, click.
160
+
161
+ CUDA kernels are compiled at install time — your machine needs a GPU and nvcc. If compilation fails:
162
+
163
+ ```bash
164
+ # Debian/Ubuntu
165
+ sudo apt install nvidia-cuda-toolkit build-essential
166
+
167
+ # Verify nvcc
168
+ nvcc --version
169
+ ```
170
+
171
+ ```bash
172
+ # CLI — one command
173
+ edgeval eval results/ --gpu --dataset BSDS
174
+
175
+ # Python API — one function call
176
+ from edgeval_cu.eval import gpu_edges_eval_img
177
+ info, _ = gpu_edges_eval_img(edge_map, "GT/100007.mat", thrs=99, mode='simple')
178
+ ```
179
+
180
+ ---
181
+
182
+ ## Accuracy
183
+
184
+ The +0.003 ODS bias comes from the Auction solver's `atomicMax` tie-breaking. It is systematic and stable across images. In practice:
185
+
186
+ - Training monitoring: GPU simple mode — ~0.003 won't affect your model ranking
187
+ - Final evaluation: CPU CSA mode — exact match to MATLAB reference
188
+
189
+ | Image | GPU ODS | CSA ODS | Δ |
190
+ |-------|---------|---------|---|
191
+ | 100007 | 0.8601 | 0.8570 | +0.0031 |
192
+ | 100039 | 0.7358 | 0.7347 | +0.0011 |
193
+ | 100099 | 0.8091 | 0.8056 | +0.0035 |
194
+ | 10081 | 0.7655 | 0.7631 | +0.0024 |
195
+ | 101027 | 0.8749 | 0.8724 | +0.0026 |
196
+
197
+ ---
198
+
199
+ ## Project Structure
200
+
201
+ ```
202
+ edgeval.cu/
203
+ ├── edgeval_cu/ # Package
204
+ │ ├── eval.py # Main pipeline — gpu_edges_eval_img()
205
+ │ ├── auction.py # GPU Auction wrapper
206
+ │ ├── _compile.py # Lazy CUDA kernel compilation
207
+ │ ├── metrics.py # ODS/OIS/AP/R50 computation
208
+ │ ├── csa.py # CPU CSA solver (exact reference)
209
+ │ ├── nms_thin.py # Zhang-Suen thinning LUTs
210
+ │ ├── cli.py # CLI: edgeval eval / show / nms
211
+ │ └── cuda/ # CUDA kernels
212
+ │ ├── auction_kernel.cu # ε-Scaling Auction solver
213
+ │ ├── edge_builder.cu # Fused edge builder
214
+ │ └── Makefile
215
+ ├── cxx/ # CPU CSA C++ solver
216
+ │ └── lib/solve_csa.so
217
+ ├── docs/
218
+ │ ├── benchmarks.md # Detailed benchmarks & config sweep
219
+ │ └── optimization.md # 8-stage optimization journey (5.7s→0.47s)
220
+ └── README.md
221
+ ```
222
+
223
+ ---
224
+
225
+ ## Optimization Journey
226
+
227
+ We went from 5.7s to 0.47s per image — a **12× within-GPU speedup** — through 8 systematic optimizations:
228
+
229
+ | # | What | Speedup | Key Insight |
230
+ |---|------|---------|-------------|
231
+ | 1 | Simple bipartite graph | 4.9× | kOfN adds edges but not accuracy |
232
+ | 2 | Fused CUDA edge builder | 1.2× | Merge cdist+mask+nonzero into 1 kernel |
233
+ | 3 | GPU batched thinning | 1.0× | 99 masks in one conv2d batch |
234
+ | 4 | Consecutive stall detection | 1.3× | Wait for real convergence, not first silence |
235
+ | 5 | GPU annotator split | 1.3× | Sort by annotator on GPU, download once |
236
+ | 6 | GPU nonzero | 1.03× | Keep masks on GPU, extract coords there |
237
+ | 7 | Tuned ITERS_EPS0 | 1.2× | 500 iterations is plenty — system sweep proves it |
238
+ | 8 | Directory restructure | — | Flat modules, clean imports |
239
+
240
+ Details: [docs/optimization.md](docs/optimization.md)
241
+
242
+ ---
243
+
244
+ ## References
245
+
246
+ - [Bertsekas, "Auction Algorithms" (1979)](https://web.mit.edu/dimitrib/www/Auction_Encycl.pdf) — Auction algorithm for assignment problems
247
+ - [Guo & Hall, "Parallel Thinning" (1989)](https://gist.github.com/joefutrelle/562f25bbcf20691217b8) — Zhang-Suen morphological thinning
248
+ - [HED Evaluation (MATLAB)](https://github.com/s9xie/hed_release-deprecated) — Original reference implementation
249
+ - [edge-eval-python](https://github.com/Walstruzz/edge_eval_python) — Python CSA port
250
+ - [Extended BSDS Benchmark](https://github.com/davidstutz/extended-berkeley-segmentation-benchmark) — C++ CSA solver
251
+
252
+ ---