PiDiNet soft edges (fastforks)

Soft edge preprocessor of ControlNet 1.1 (controlnet_aux PidiNetDetector, ComfyUI's "PiDiNet Soft-Edge Lines"): pixel difference networks (Su et al., ICCV 2021), a 0.7 M-parameter edge detector of difference convolutions, here converted to plain depthwise convolutions (the authors' re-parameterization). Research use only.

This repo is the model card only: it holds no weights. fastforks downloads the authors' weights from the links below and checks them against the SHA-256 in the model card. Code: https://github.com/kleinicke/fastforks. Kernels for the kernels backend: https://huggingface.co/fastforks/kernels. Original code: https://github.com/huggingface/controlnet_aux at b1aac318b15c.

Author weight repos: https://huggingface.co/lllyasviel/Annotators.

Task: edges. Tier: experimental. Outputs: edges. Backends: portable, kernels.

Input: one RGB image. Output: a line / edge map [H, W] in [0, 1] at the input size (1 = line), the ControlNet preprocessors (line art, HED, PiDiNet, TEED / Anyline); M-LSD also returns straight line segments.

Variants

Weights are the authors' files (not hosted here). SHA-256 shortened to 12 hex digits; the full hashes are in card.toml.

variant weights (author link) SHA-256 weights licence commercial use
pidinet@1 table5_pidinet.pth 80860ac26725 LicenseRef-research-only (assumed from code) no

Licence

Original-code strings, recorded as they are (research-use package; check them before any other use). Code: LicenseRef-research-only. Licence files: LICENSE.

Code licence: LicenseRef-research-only; the authors do not state a separate weights licence.

Training data: Not stated for these checkpoints (lllyasviel/Annotators, ControlNet 1.1). The file name matches the paper's table 5 BSDS500 model..

Licence evidence: https://github.com/huggingface/controlnet_aux/blob/b1aac318b15c4e65a21bc516dc236ad4bf593d46/src/controlnet_aux/pidi/LICENSE ; https://github.com/hellozhuo/pidinet/blob/master/LICENSE ; https://huggingface.co/lllyasviel/Annotators

Input size

any H x W >= 32, padded to a multiple of 32 Tested up to (portable, fp16, RTX 5060 Ti 16 GB): pidinet 1080x1920 (0.3 GiB peak allocated, 0.4 reserved)

Speed and memory

Edges, synthetic, 1080x1920

model time (ms): original portable kernels kernels speed-up: vs portable peak memory (MiB, allocated / reserved): original portable kernels
pidinet 35.9 13.1 12.3 1.1x 339 / 368 328 / 372 328 / 392

Startup and first call

model load (s): original portable kernels first call (s): original portable kernels
pidinet 0.28 0.16 0.17 (1024x1024) 0.06 0.01 0.62 (1024x1024)

torch.compile and TensorRT

model input time: portable compile TensorRT (fp16 unless shown) kernels preparation: compile (cold first call) ONNX + engine build peak MiB (alloc / reserved): portable compile kernels TensorRT (engine + torch)
pidinet 1024x1024 6.59 ms 5.66 ms 4.50 ms 6.37 ms 12.4 s 20.4 s 186 / 228 166 / 190 186 / 228 187 / 200
pidinet 1080x1920 13.1 ms 10.6 ms 9.04 ms 12.3 ms 16.1 s 22.6 s 328 / 372 216 / 246 328 / 392 307 / 312

Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).

Hardware, protocol and caveats: benchmarks (RTX 5060 Ti 16 GB, sm_120). Original = the original code named above at the precision of portable (fp16, or (fp32) where fp16 is unsupported or not finite); original fp32 = its default fp32 run. Peak memory is the torch allocator's.

Accuracy

On public datasets

All 200 BSDS500 test images. The benchmark uses the official boundary correspondence with a tolerance of 0.0075 of the image diagonal. ODS, OIS and AP use 99 thresholds on 8-bit predictions without thinning. The first 75 BSDS500 test images by filename. Scores use the official boundary correspondence at 0.0075 of the image diagonal and 99 thresholds on 8-bit predictions without thinning. Original = the original code named under Details, same checkpoint and protocol.

variant dataset original fp32 portable portable fp32 kernels note
pidinet BSDS500 test (200 images), boundary ODS / OIS / AP % 59.29 / 59.92 / 60.81 59.29 / 59.90 / 60.81
pidinet BSDS500 test (first 75 images), boundary ODS / OIS / AP % 58.79 / 59.59 / 60.31 58.79 / 59.61 / 60.31 58.79 / 59.55 / 60.31 58.79 / 59.61 / 60.31

Measured on portable: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 5f4a908a0, 2026-11-19; portable32: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 3bf0bac7, 2026-11-17; kernels: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 67dbea00e, 2026-11-20.

Parity with the original code

Every variant is checked against reference outputs of the original code at its pinned commit. CPU, float32: max |diff| <= 0.002 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.02 and p99 <= 0.25 (absolute error of the output edges).

Usage

from fastforks import edges

# non-commercial weights: run with FASTFORKS_NONCOMMERCIAL=1 in the environment
model = edges.load("pidinet")  # mode="auto": the preferred backend from recorded measurements
result = model("photo.jpg")
result.edges  # [H, W] float32 in [0, 1], 1 = line, input resolution
result.backend  # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')

Install with pip install fastforks (see https://github.com/kleinicke/fastforks). Other variants: pidinet.

Kernels backend

edges.load("pidinet", mode="kernels") runs our CUDA kernels (cv_resample). It needs a prebuilt kernel for your GPU architecture (downloaded from https://huggingface.co/fastforks/kernels on first use) and a recent NVIDIA driver; if there is none it raises BackendUnavailableError with the reason and never falls back silently. mode="auto" picks kernels when it can run and logs the choice.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Collection including fastforks/pidinet