When building edge vision pipelines, the instinct in modern platform engineering is often to drop in a heavy Vision Transformer or a massive convolutional backbone. But for real-time edge applications, huge parameter counts bring unacceptable latency jitter, heavy runtime dependencies, and unpredictable memory allocations. Bio-inspired mathematical modeling offers a lean alternative. Siddharth B R’s implementation of Harmonic Contour Integration, available open source at RenderBear/haci, demonstrates how a strictly partitioned four-stage mathematical algorithm can isolate clean boundary contours from RGB images without relying on gigabyte-sized neural networks.

HaCI splits its processing pipeline into four decoupled modules: L0.py, L1.py, seed.py, and renderer.py. The first two stages handle deterministic feature extraction before any learned components step in. In L0.py, the system receives raw RGB frames and applies pixel-level contrast and gain control. This normalizes lighting variations across heterogeneous sensor capture conditions. From there, L1.py aggregates pixel features into cell-level tensor representations, computing local $z_2$ moments. These moments output three explicit metrics for every cell: energy ($E$), contrast ($C$), and dominant orientation ($\theta$). Keeping these foundational stages deterministic means platform engineers can debug upstream sensor noise without guessing what hidden neural layers are doing to the dynamic range.

Once cell-level orientation and energy are established, seed.py executes contextual contour suppression and enhancement. This stage models biological visual cortex mechanisms through four sequential operations: $\eta_z$ non-maximum suppression, association field seeding, same-orientation surround suppression, and flank suppression. Surround suppression silences uniform textures like grass or brickwork that usually flood edge detectors with false positives. Flank suppression sharpens parallel boundaries, leaving behind a sparse matrix of cell magnitudes ($\rho$). This output feeds directly into renderer.py, which projects thin, continuous ridge lines across the final map.

To make spatial rendering viable on client devices, HaCI relies on custom hardware acceleration. On Apple Silicon, splat_metal.py offloads the rendering kernel to native Metal compute shaders when invoked with the --device mps flag. Devices running standard Linux or Windows hardware fall back to standard PyTorch CUDA or CPU execution. The code structure enforces explicit modular isolation. Entry points are managed via Python 3.12 project configurations (pyproject.toml) and environment isolation tools like uv. You can run training, testing, or single-image inference directly through cli.py or script wrappers (scripts/brind.sh, scripts/biped.sh, scripts/nyud.sh).

The empirical results show how competitive a modular mathematical approach can be against traditional deep learning baselines. When evaluated against the standard Berkeley boundary benchmark on the 200-image BRIND test set (after training on the 300-image train split), HaCI achieves an Optimal Dataset Scale (ODS) score of 0.7160 at a decision threshold of 0.74. At this threshold, the thinned boundary map (s_eval) achieves 0.6841 precision and 0.7509 recall, paired with an Optimal Image Scale (OIS) of 0.7383 and Average Precision (AP) of 0.7598. Looking at the raw soft map (c_eval) prior to thin non-maximum suppression, the ODS remains nearly identical at 0.7136, though Average Precision drops to 0.6655.

Evaluation Map ODS Threshold Precision Recall OIS AP
NMS-thinned (s_eval) 0.7160 0.74 0.6841 0.7509 0.7383 0.7598
Soft raw map (c_eval) 0.7136 0.74 0.6891 0.7399 0.7347 0.6655

However, benchmark accuracy only tells half the story for edge deployments. The real engineering trade-offs show up when looking at latency scaling and VRAM consumption measured on Apple M4 hardware using baselines/speed.py:

Frame Resolution Inference Time Host RAM Footprint GPU VRAM Footprint
481 x 321 35 ms 123 MB 1.1 GB
1280 x 720 (720p) 201 ms 171 MB 1.1 GB
1920 x 1080 (1080p) 457 ms 233 MB 2.2 GB

The memory figures highlight a glaring bottleneck. While host memory overhead stays impressively low, scaling from 123 MB at 481x321 to just 233 MB at full 1080p resolution, GPU VRAM allocation jumps from 1.1 GB to 2.2 GB. A 457 ms frame time at 1080p limits execution to roughly 2 frames per second. For high-throughput edge systems or micro-orchestration layers where operators try to pack vision microservices alongside LLM inference engines like GPUWorks, holding over 2 GB of VRAM for edge detection can severely constrain local concurrency.

The core strength of HaCI lies in its architectural clarity. By separating non-linear contrast normalization, directional cell moments, and ridge splatting into discrete Python modules, debugging production anomalies becomes far simpler than probing deep neural network activations. Yet the high VRAM overhead relative to model parameter weight size shows that custom Metal splatting kernels and tensor allocations still require further memory layout optimization. Platform teams contemplating HaCI for embedded perception will need to weigh whether 35 ms frame rates at lower resolutions fit their SLA budget, or if the 1080p latency jump forces them to run downsampled inputs in production.

References