Instructions to use wesjos/YOLO-face-detection320-ReLU with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ultralytics
How to use wesjos/YOLO-face-detection320-ReLU with ultralytics:
from huggingface_hub import hf_hub_download from ultralytics import YOLO # pick the weights file from this repo's "Files and versions" tab weights = hf_hub_download("wesjos/YOLO-face-detection320-ReLU", "<weights>.pt") model = YOLO(weights) source = 'http://images.cocodataset.org/val2017/000000039769.jpg' model.predict(source=source, save=True) - YOLOv26
How to use wesjos/YOLO-face-detection320-ReLU with YOLOv26:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
YOLO-face-detection320-ReLU
Four nano-scale YOLO face detectors with a fixed 320×320 input and a single class. This repo is the SiLU → ReLU 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 − ReLU | SiLU +0.41 pp | 4/4 architectures significant | 0.280 vs 0.278 ms, no difference |
| SiLU − LeakyReLU(0.1) | SiLU +0.28 pp | 3/4 significant | no difference |
| ReLU − LeakyReLU(0.1) | only +0.12 pp | 0/4 significant | no difference |
- The loss is real. All four architectures get worse, and the 95% CI from a 1000-round paired bootstrap does not cross zero for any of them.
- Changing the activation buys no speed here. On an RTX 4090 the activation is not the bottleneck — b1 / b32 / b64 all tie. "Use ReLU because it's faster" does not hold on this machine.
- The only legitimate use case is a target platform (NPU / INT8 pipeline) that cannot evaluate
exp(), so SiLU has to go. In that case plain ReLU is enough — switching to LeakyReLU to "recover negative-side information" has no statistical support.
Demo images
Each panel is one image: the output of yolov8n-face320-relu.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 · box covers 13.4% of the frame · conf 0.955
images · 556×552 · 1 face · box covers 22.4% of the frame · conf 0.932
licensed-image · 2048×1365 · 1 face · box covers 22.6% of the frame · conf 0.927 (downscaled to 320 for inference; the face still spans ~23% of the frame — the model's comfort zone)
lyf · 381×524 · 1 face · box covers 15.9% of the frame · conf 0.957
talyor · 452×678 · 1 face · box covers 12.8% of the frame · conf 0.947
Every image holds a single face. Re-running the same five images at
conf=0.10withyolov8n,yolo11nandyolov5nureturned exactly one box each. The exception isyolo26n, which adds a second low-confidence box on two images (images0.30,licensed-image0.14) — those are genuine extra candidates that the 0.25 threshold filters out, not rendering artifacts.
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-relu.pt |
2.636 M | 1.93 | 5.25 MB | 0.9870 | 0.9036 | −0.0062 |
yolov8n-face320-relu.pt |
3.138 M | 2.19 | 6.18 MB | 0.9881 | 0.9080 | −0.0019 |
yolo11n-face320-relu.pt |
2.605 M | 1.63 | 5.24 MB | 0.9866 | 0.9056 | −0.0038 |
yolo26n-face320-relu.pt |
2.534 M | 1.35 | 5.20 MB | 0.9870 | 0.9050 | −0.0051 |
- 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 baseline card. - Latency (in the TL;DR): RTX 4090, FP16, full predict path including pre/post-processing and NMS, median of 7 runs.
- The
SiLU baselinecolumn behindvs SiLUis 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. yolov5nuis 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-relu.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-relu.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, notface(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 stringface, map it yourself — this is what makes Ultralytics' built-inplot()label the boxesitem. - 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.ReLU(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.ReLU(inplace=True))
What that gives, verified on the released files (zero SiLU left in any of them):
| File | ReLU slots | nn.Identity total |
of which activation slots |
|---|---|---|---|
yolov5nu-face320-relu.pt |
69 | 0 | 0 |
yolov8n-face320-relu.pt |
57 | 0 | 0 |
yolo11n-face320-relu.pt |
77 | 4 | 4 |
yolo26n-face320-relu.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-relu.pt |
5.25 MB | YOLOv5nu port, ReLU |
yolov8n-face320-relu.pt |
6.18 MB | YOLOv8n, ReLU (the demo model) |
yolo11n-face320-relu.pt |
5.24 MB | YOLO11n, ReLU |
yolo26n-face320-relu.pt |
5.20 MB | YOLO26n, ReLU (default in inference.py) |
inference.py |
1.1 KB | self-contained predict script |
metrics.json |
954 B | per-file byte size + activation counts |
demo/*.jpg |
5 files | the panels above |
中文摘要
wesjos/YOLO-face-detection320 的 SiLU → ReLU 单变量消融:数据、超参、预训练权重、种子全同,只换激活。
- 别用它替代 SiLU:4 个架构全部掉点,平均 0.41 pp,配对 bootstrap 1000 次 95% CI 不跨 0;RTX 4090 上延迟无差异。
- 唯一正当用途:目标平台(NPU / INT8 管线)不支持
exp,必须去掉 SiLU;此时直接用 ReLU,为「补回负值信息」换 LeakyReLU 没有统计依据(两者差 0.12 pp,0/4 显著)。 - 与 LeakyReLU 版的关系:本仓是 ReLU,姊妹仓是 YOLO-face-detection320-LeakyReLU。
- 坑:权重里
model.names是item而不是face,单类不影响使用,但依赖字符串的下游要自己映射。
License
AGPL-3.0 (inherited from Ultralytics).
- Downloads last month
- 233
Model tree for wesjos/YOLO-face-detection320-ReLU
Base model
Ultralytics/YOLO11



