Skip to content

v2.0.0

Choose a tag to compare

@cobanov cobanov released this 30 Aug 18:47
· 5 commits to main since this release
9ac059e

A photograph goes in, a normal map comes out, and the conversion itself is now a
portable ONNX graph rather than a Python function.

  • --estimate: Depth Anything V2 Small (Apache-2.0) runs on the photo
    first, so a photograph is a valid input. Downloaded once, checksummed, cached,
    and run on CUDA when onnxruntime-gpu is installed: 32 ms on an RTX 3090,
    231 ms on an M4 Pro CPU.
  • depth2normal export: the conversion as an ONNX graph. Height and width
    are dynamic, strength is a graph input, and it matches the NumPy path to
    within one level out of 255. The models are attached below.
  • --focal: treat the depth as metric distance from a pinhole camera and
    get the normals of the unprojected 3-D surface, so a plane keeps its
    orientation whatever its distance. Recovered against analytic planes to
    within 1e-4. (#1)
  • Scale invariant: depth is rescaled to a fixed 0-255 range before the
    gradients, and every gradient kernel is normalised, so strength means the
    same thing whatever the file's bit depth and whichever method is picked.
  • A browser demo at depth2normal.cobanov.dev,
    running both models client side, nothing uploaded.
  • SciPy is gone. All three gradient methods are separable, so pure NumPy
    matches SciPy to 1e-13 at the same speed, with 19.5 MB less to install.

depth2normal depth.png -o normal.png works exactly as it did.

The models attached below

One graph per method, and per sigma for gaussian. Input depth is float32
[1, 1, H, W] on the 0-255 range, plus a strength float32 scalar. Output
normal_map is uint8 [1, H, W, 3] RGB. They are pinned to IR version 10, so
older ONNX Runtimes load them too. Nothing else is needed to run them.

pip install depth2normal