ONNX Model Zoo

alonsorobots/scrfd_320_batched

By alonsorobots · ↓ 0 · ♥ 0 · Updated 2025-12-02

What's in this repo

This page lists the files in alonsorobots/scrfd_320_batched, including arcface_w600k_r50_batch.onnx, scrfd_10g_320_batch.onnx.

  • 2 ONNX models (.onnx files)
  • 4 files, including 2 .onnx, 1 .md
  • Last updated 2025-12-02

ONNX files

File Size Download
arcface_w600k_r50_batch.onnx — Download
scrfd_10g_320_batch.onnx — Download

How to use

These ONNX files can be loaded with ONNX Runtime. To inspect a model graph, upload the file to the Netron viewer. Download links point to the original files on Hugging Face.

README


license: other license_name: insightface-non-commercial license_link: https://github.com/deepinsight/insightface#license tags:

  • face-detection
  • face-recognition
  • scrfd
  • arcface
  • onnx
  • batch-inference
  • tensorrt library_name: onnx pipeline_tag: image-classification

InsightFace Batch-Optimized Models (Max Batch 32)

Re-exported InsightFace models with proper dynamic batch support and no cross-frame contamination.

Version Comparison

Repository Max Batch Recommendation
This repo 1-32 ✅ Recommended - Optimal performance
alonsorobots/scrfd_320_batched_64 1-64 For experimentation

Batch=32 is optimal. Testing on RTX 5090 shows batch=64 provides no additional throughput benefit.

Why These Models?

The original InsightFace ONNX models have issues with batch inference:

  • buffalo_l detection model: hardcoded batch=1
  • buffalo_l_batch detection model: broken - has cross-frame contamination due to reshape operations that flatten the batch dimension

These re-exports fix the dynamic_axes in the ONNX graph for true batch inference.

Models

Model Task Input Shape Output Batch Speedup
scrfd_10g_320_batch.onnx Face Detection [N, 3, 320, 320] boxes, landmarks 1-32 6×
arcface_w600k_r50_batch.onnx Face Embedding [N, 3, 112, 112] 512-dim vectors 1-32 10×

Performance (TensorRT FP16, RTX 5090)

SCRFD Face Detection

Batch Size FPS ms/frame
1 867 1.15
16 5,498 0.18

ArcFace Embeddings

Batch Size FPS ms/embedding
1 292 3.4
16 3,029 0.33

Usage

import numpy as np
import onnxruntime as ort

# Load model
sess = ort.InferenceSession("scrfd_10g_320_batch.onnx", 
                            providers=["TensorrtExecutionProvider", "CUDAExecutionProvider"])

# Batch inference
batch = np.random.randn(16, 3, 320, 320).astype(np.float32)
outputs = sess.run(None, {"input.1": batch})

# outputs[0-2]: scores per FPN level (stride 8, 16, 32)
# outputs[3-5]: bboxes per FPN level
# outputs[6-8]: keypoints per FPN level

Verified: No Batch Contamination

# Same frame processed alone vs in batch = identical results
single_output = sess.run(None, {"input.1": frame[np.newaxis, ...]})
batch[7] = frame
batch_output = sess.run(None, {"input.1": batch})

max_diff = np.max(np.abs(single_output[0] - batch_output[0][7]))
# max_diff < 1e-5 ✓

Re-export Process

These models were re-exported from InsightFace's PyTorch source using MMDetection with proper dynamic_axes:

dynamic_axes = {
    "input.1": {0: "batch"},
    "score_8": {0: "batch"},
    "score_16": {0: "batch"},
    # ... all outputs
}

See SCRFD_320_EXPORT_INSTRUCTIONS.md for details.

License

Non-commercial research purposes only - per InsightFace license.

For commercial licensing, contact: recognition-oss-pack@insightface.ai

Credits

Model info

onnx face-detection face-recognition scrfd arcface batch-inference tensorrt image-classification arxiv:2105.04714 arxiv:1801.07698 license:other region:us
↓ 0 ♥ 0

Created: 2025-12-02

Updated: 2025-12-02

View on Hugging Face

Files (4)

.gitattributes
README.md
arcface_w600k_r50_batch.onnx ONNX
scrfd_10g_320_batch.onnx ONNX

Related models