YOLO-face-detection320-LeakyReLU(0.1)

Four nano-scale YOLO face detectors with a fixed 320×320 input and a single class. This repo is the SiLU → LeakyReLU(0.1) single-variable ablation of wesjos/YOLO-face-detection320: dataset, hyperparameters, initial weights and seed are identical — only the activation differs.

TL;DR — do not swap SiLU out for this

Comparison Δ mAP50-95 Significance b32 latency
SiLU − LeakyReLU(0.1) SiLU +0.28 pp 3/4 architectures significant no difference
SiLU − ReLU SiLU +0.41 pp 4/4 significant no difference
ReLU − LeakyReLU(0.1) only +0.12 pp 0/4 significant no difference
  1. The loss is real. All four architectures get worse, and the 95% CI from a 1000-round paired bootstrap does not cross zero for three of them.
  2. Changing the activation buys no speed here. On an RTX 4090 the activation is not the bottleneck — b1 / b32 / b64 all tie. "Use LeakyReLU because it's faster" does not hold on this machine.
  3. The only legitimate use case is a target platform (NPU / INT8 pipeline) that cannot evaluate exp(), so SiLU has to go. And in that case plain ReLU is enough: LeakyReLU's "recover the negative side" story buys +0.12 pp over ReLU with zero statistical support (0/4 significant). Reach for ReLU first.

Demo images

Each panel is one image: the output of yolov8n-face320-leaky.pt, the number on the box is the confidence. Params: imgsz=320, conf=0.25, iou=0.5, run on CPU with ultralytics 8.3.51 — no cherry-picking, no post-processing.

iu 188×268 · 1 face · conf 0.95

iu · 188×268 · 1 face · box covers 13.4% of the frame · conf 0.952

images 556×552 · 1 face · conf 0.92

images · 556×552 · 1 face · box covers 22.8% of the frame · conf 0.924

licensed-image 2048×1365 · 1 face · conf 0.93

licensed-image · 2048×1365 · 1 face · box covers 22.9% of the frame · conf 0.926 (downscaled to 320 for inference; the face still spans ~23% of the frame — the model's comfort zone)

lyf 381×524 · 1 face · conf 0.96

lyf · 381×524 · 1 face · box covers 15.5% of the frame · conf 0.960

talyor 452×678 · 1 face · conf 0.95

talyor · 452×678 · 1 face · box covers 12.7% of the frame · conf 0.948

Every image holds a single face. Re-running the same five images at conf=0.10 returned one box each for yolov8n, yolo11n and yolov5nu; yolo26n adds one extra low-confidence box (0.16) on licensed-image — a genuine extra candidate, not a rendering artifact.

When to use it

These weights are built for small inputs where the face takes up a large share of the frame. The input is a fixed 320×320 and the intended subject is one face (or a head-and-shoulders shot) filling most of the image: ID photos, avatars, access-control / gate captures, cropped portraits. The demos above sit in the 13%–23% box-to-frame range, which is where the model is most reliable.

Conversely, tiny distant faces (ground-truth box < 0.4% of the frame) only reach ~0.73 recall — that is not what these weights are for. Tile large images and run 320 on each tile, or train a 640 model.

Results

Same val set as the SiLU baseline (5,797 images / 6,146 boxes), imgsz=320, conf=0.001, COCO-style 101-point interpolated AP:

File Params GFLOPs Size mAP50 mAP50-95 vs SiLU
yolov5nu-face320-leaky.pt 2.636 M 1.93 5.25 MB 0.9879 0.9058 −0.0040
yolov8n-face320-leaky.pt 3.138 M 2.19 6.18 MB 0.9874 0.9074 −0.0025
yolo11n-face320-leaky.pt 2.605 M 1.63 5.24 MB 0.9869 0.9074 −0.0020
yolo26n-face320-leaky.pt 2.534 M 1.35 5.20 MB 0.9869 0.9064 −0.0037
  • Accuracy: 101-point interpolated COCO AP computed in numpy — the same estimator as the baseline repo, so the two tables are directly comparable.
  • Params / GFLOPs / Size were re-measured on the released checkpoints here (ultralytics 8.4.211, .info(imgsz=320)), not copied from the ModelScope card. The one number that disagrees is yolo26n: this table says 1.35 GFLOPs, the ModelScope card said 1.48 — both 8.3.51 and 8.4.211 report 1.347 on the released file, so 1.35 is what the shipped weights actually cost.
  • Latency (in the TL;DR) is the source ablation run's measurement — RTX 4090, FP16, full predict path including pre/post-processing and NMS, median of 7 runs. It was not re-measured when publishing this repo.
  • The SiLU baseline column behind vs SiLU is the control group of this same ablation run (0.9098 / 0.9098 / 0.9094 / 0.9101). It sits 0.3–0.4 pp below the numbers published in the SiLU repo (0.9138–0.9147), i.e. the two are not the same training run — compare deltas within this table, not absolute values across repos.
  • yolov5nu is Ultralytics' port of YOLOv5n (2.64 M params), not the 1.77 M model from the original YOLOv5 repo.

Inference

from ultralytics import YOLO

model = YOLO("yolo26n-face320-leaky.pt")
results = model.predict("image.jpg", imgsz=320, conf=0.25, iou=0.5)
for b in results[0].boxes:
    print(b.xyxy.tolist(), float(b.conf))
python inference.py image.jpg          # bundled script, no config needed
yolo predict model=yolo26n-face320-leaky.pt source=./images imgsz=320 conf=0.25

Caveats

  • Input must be 320. Running a 320-trained model at 640 drops mAP50-95 from ~0.91 to 0.775 — do not upscale the input.
  • The box is the face region (hairline to chin), excluding the back of the head and neck. If downstream needs a full-head box, redefine it there.
  • The class name inside these checkpoints is item, not face (model.names == {0: 'item'}, inherited from the training data yaml). It is a single-class model so nothing breaks, but if your code keys off the string face, map it yourself — this is what makes Ultralytics' built-in plot() label the boxes item.
  • Weak on small targets: recall ~0.73 for GT boxes < 0.4% of the frame, ~0.77 for 0.4–2%, 0.998 above 10%. For distant small faces, tile the image or train a 640 model.
  • The training set is dominated by single-face images (only 5.5% have multiple faces); dense crowds are out of distribution.
  • Weights are inference-only (optimizer and EMA state stripped, epoch=-1).

Training setup

Identical to the SiLU baseline except for the one row in bold.

Item Value
epochs / batch / imgsz 150 / 256 / 320
optimizer auto → MuSGD (iterations > 10000), lr0 0.01, cos_lr
augmentation mosaic 1.0 / scale 0.5 / fliplr 0.5, mosaic off for the last 10 epochs
seed / deterministic 0 / True
cache ram (single process, serial)
activation nn.LeakyReLU(0.1, inplace=True) — the only variable
stack Ultralytics 8.4.211 / torch 2.11.0+cu130
Per-model training time ≈41 min (RTX 4090)

Training data: 23,150 train images / 24,575 boxes, 5,797 val images / 6,146 boxes, 30,721 boxes total, natively 320×320, labels produced by an automatic detector and not hand-verified box by box.

Reproducing this is less obvious than it looks

Setting model.yaml['activation'], or only changing Conv.default_act in ultralytics/nn/modules/conv.py, both produce a mixed model: when DetectionModel.load() transfers the detection head it deep-copies the source model's cv3 / one2one_cv3 wholesale, and that source model was deserialized by YOLO(pt) — it never goes through parse_model, so its activations are still SiLU. The log only prints Transferred 696/708 items and reports no error.

The reliable way is to walk the already-built module tree and replace in place:

for mod in model.modules():
    for cname, child in list(mod.named_children()):
        if isinstance(child, (nn.SiLU, nn.ReLU, nn.LeakyReLU)):
            setattr(mod, cname, nn.LeakyReLU(0.1, inplace=True))

What that gives, verified on the released files (zero SiLU left in any of them):

File LeakyReLU slots nn.Identity total of which activation slots
yolov5nu-face320-leaky.pt 69 0 0
yolov8n-face320-leaky.pt 57 0 0
yolo11n-face320-leaky.pt 77 4 4
yolo26n-face320-leaky.pt 105 10 9 (the 10th is the DFL module)

The nn.Identity slots come from the source code's explicit act=False and cannot be replaced.

Files in this repo

File Size Purpose
yolov5nu-face320-leaky.pt 5.25 MB YOLOv5nu port, LeakyReLU(0.1)
yolov8n-face320-leaky.pt 6.18 MB YOLOv8n, LeakyReLU(0.1) (the demo model)
yolo11n-face320-leaky.pt 5.24 MB YOLO11n, LeakyReLU(0.1)
yolo26n-face320-leaky.pt 5.20 MB YOLO26n, LeakyReLU(0.1) (default in inference.py)
inference.py 1.2 KB self-contained predict script
metrics.json 997 B per-file byte size + activation counts
demo/*.jpg 5 files the panels above

中文摘要

wesjos/YOLO-face-detection320 的 SiLU → LeakyReLU(0.1) 单变量消融:数据、超参、预训练权重、种子全同,只换激活。

  • 别用它替代 SiLU:4 个架构全部掉点,平均 0.28 pp,其中 3/4 配对 bootstrap 95% CI 不跨 0;RTX 4090 上延迟无差异,换激活换不来速度。
  • 唯一正当用途:目标平台(NPU / INT8 管线)不支持 exp,必须去掉 SiLU。但此时直接用更简单的 ReLU 就够了——LeakyReLU 相对 ReLU 只高 0.12 pp、0/4 显著,没有统计依据。
  • 与 ReLU 版的关系:本仓是 LeakyReLU(0.1),姊妹仓是 YOLO-face-detection320-ReLU。
  • 坑:权重里 model.names 是 item 而不是 face,单类不影响使用,但依赖类别字符串的下游要自己映射。

License

AGPL-3.0 (inherited from Ultralytics).

Downloads last month
185
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for wesjos/YOLO-face-detection320-LeakyReLU

Finetuned
(214)
this model

Collection including wesjos/YOLO-face-detection320-LeakyReLU