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.
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 | peak memory (MiB, allocated / reserved): original | portable |
|---|---|---|---|---|
pidinet |
35.9 | 13.1 | 339 / 368 | 328 / 372 |
Startup and first call
| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
|---|---|---|---|---|---|---|
pidinet |
0.28 | 0.16 | β | 0.06 | 0.01 | β |
torch.compile and TensorRT
| model | input | time: portable | compile | TensorRT fp16 | 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 | β | 12.4 s | 20.4 s | 186 / 228 | 166 / 190 | β | 187 / 200 |
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
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
No kernels backend: the converted network is plain convolutions (cuDNN); no custom kernel measured to pay off.