TinyFox-2: High-Performance Night/IR Red Fox & Wildlife Detector
TinyFox-2 is an ultra-fast, edge-optimized 12-class object detection model specialized for nocturnal infrared (IR) camera-traps and perimeter pest/predator monitoring.
Built on the lightweight YOLO26n architecture (2.38M parameters, 5.2 GFLOPs), TinyFox-2 was specifically engineered to solve the historical failure modes of night wildlife detectors: false fires on empty backgrounds, fox-vs-canid confusion, and loss of small quadruped recall.
Key Highlights
- 88.2% Fox Detection Rate on Real IR Deployment Video (vs 45.7% in v3 and 80.5% in v4).
- 0% Canid Confusion at Operating Threshold (0.40): Solves the long-standing bug where raccoons, dingoes, or domestic dogs stole fox detections.
- Zero False Alarms on Verified IR Negatives: 0/225 false fires across night-time camera footage.
- Extreme Edge Efficiency:
- FP32 PyTorch Checkpoint: 5.39 MB (
TinyFox-2.pt) - FP16 ONNX: 4.75 MB (
TinyFox-2_fp16.onnx) - INT8 Calibrated ONNX: 2.60 MB (72.5% compression with 0.68 px mean box delta and 100% class agreement).
- FP32 PyTorch Checkpoint: 5.39 MB (
- Ready for CPU, GPU & Edge NPU Deployment (ONNX Runtime, OpenVINO, TorchScript, Radxa, Jetson, Raspberry Pi).
Generational Leap: TinyFox-2 vs. TinyFox 1.0
TinyFox-2 is a complete architectural and algorithmic overhaul compared to the original TinyFox 1.0. Where TinyFox 1.0 was a proof-of-concept single-class detector prone to background false alarms and species confusion, TinyFox-2 is a robust, production-grade 12-class nocturnal wildlife vision model.
| Metric / Dimension | TinyFox 1.0 (Legacy) | TinyFox-2 (Current Release) | Real-World Impact |
|---|---|---|---|
| Architecture | Custom NanoDet-Plus Head | YOLO26n (Anchor-Free, Multi-Scale) | Modern backbone with superior feature extraction and gradient stability |
| Taxonomy & Classes | 1 class (red_fox on HF) / 3-class early prototype (fox/cat/dog) | 12 distinct biological classes | Full contextual awareness; distinguishes foxes from cats, dogs, mustelids, and marsupials |
| Fox Recall on IR Video | ~38.0% of frames | 88.2% of frames | >2.3× improvement in detection continuity across video sequences |
| Rival Canid Confusion | Severe (stolen by raccoons/dogs) | 0.0% rival fires (@ conf 0.40) | Splitting dingo, raccoondog, and domestic_dog completely eliminates misclassifications |
| False Alarm Rate | 5.8% on clean night frames | 0.0% (0 / 225 verified negatives) | True zero false-alarm operation on empty infrared scenes |
| Median Detection Confidence | 0.71 | 0.89 | Higher confidence separation between true targets and background clutter |
| Dataset & Annotation Quality | 2,281 images (pseudo-labeled noise, leaking split) | 14,627 images (human-verified VOC/COCO, 0-leak stratified split) | Clean ground truth eliminates conflicting loss gradients |
| Edge Footprint (INT8) | ~2.5 MB (experimental) | 2.60 MB calibrated via YOLO-Quantizer | 72.5% compression with <0.7 px box shift and 100% class match |
Why Early Versions Struggled and How TinyFox-2 Fixed It:
- The Class Trap: In the initial 1-class Hugging Face release, all non-fox animals were forced into the background loss, causing dogs and cats to trigger false fox alerts. In the early 3-class YOLO prototypes (
fox,cat,dog),catwas actually wild Asian Leopard Cat anddogwas Raccoon Dog, lacking domestic species and confusing distinct canids. TinyFox-2 establishes 12 honest, biology-grounded categories. - Canid Splitting Discovery: Grouping raccoon dogs, dingoes, and pet dogs into a generic
canid/dogbucket created a decision boundary too loose to separate from foxes. TinyFox-2 explicitly splitsdingo,raccoondog, anddomestic_dog, which drove rival canid misclassifications on deployment video from 36.5% down to 0.0%. - Stratified 0-Leak Training: Earlier iterations suffered from temporal burst leakage across train/val. TinyFox-2 enforces burst-atomic group stratification and uniform IR filtering, ensuring metrics reflect true real-world generalization.
Legal & Multi-Factor Licensing Analysis
Releasing an edge AI model trained from heterogeneous wildlife datasets and modern vision frameworks involves multiple legal and intellectual property factors. TinyFox-2 is released under the GNU Affero General Public License v3.0 (AGPL-3.0) with full upstream attribution.
┌────────────────────────────────────────┐
│ TinyFox-2 Release License │
│ AGPL-3.0 │
└───────────────────┬────────────────────┘
│
┌───────────────────────────────┴───────────────────────────────┐
▼ ▼
┌───────────────────────────────┐ ┌───────────────────────────────┐
│ Model Architecture & │ │ Upstream Datasets & │
│ Base Weights │ │ Academic Sources │
├───────────────────────────────┤ ├───────────────────────────────┤
│ • Framework: Ultralytics YOLO │ │ • NTLNP (Beijing Normal Univ) │
│ • Pretrained: yolo26n.pt │ │ Academic / Research Open │
│ • License: AGPL-3.0 │ │ • UNSW Predators / Dryland │
│ • Commercial: Requires │ │ Academic Non-Commercial │
│ Enterprise License from │ │ • ENA24 / LILA BC │
│ Ultralytics Inc. │ │ CDLA-Permissive-1.0 / CC-BY │
│ │ │ • Deploy IR Negatives │
│ │ │ User Contributed │
└───────────────────────────────┘ └───────────────────────────────┘
1. Model Architecture & Upstream Framework (AGPL-3.0)
TinyFox-2 is built with the Ultralytics YOLO framework and fine-tuned from yolo26n.pt.
- License: GNU Affero General Public License v3.0 (AGPL-3.0).
- Copyleft Requirement: Open-source distributions of this model or downstream network services based on it must make the corresponding source code available under AGPL-3.0.
- Commercial Use Notice: Commercial users who wish to incorporate TinyFox-2 into closed-source or proprietary hardware/software without AGPL-3.0 obligations must acquire a commercial Enterprise License directly from Ultralytics Inc..
2. Training Data Provenance & Academic Use Considerations
TinyFox-2 was trained on a leak-free, stratified corpus of 14,627 nocturnal IR images compiled from:
- NTLNP Dataset (10,338 images, human boxes): Northeast China Tiger and Leopard National Park camera-trap project (Beijing Normal University / Chinese Academy of Sciences). Released for scientific research and wildlife conservation.
- UNSW Dryland Ecology / Predators Dataset (3,524 images, MegaDetector-mined): University of New South Wales predator monitoring in arid Australia. Provided under academic research / non-commercial research terms.
- ENA24 (194 images, human COCO boxes): Eastern North America camera-trap benchmark hosted on LILA BC under the Community Data License Agreement (CDLA-Permissive-1.0).
- Deployment Camera Harvest (225 images): Animal-free infrared CCTV frames captured on deployment hardware, contributed by the author.
[!NOTE] Due to the inclusion of academic camera-trap research sets (NTLNP, UNSW), users deploying TinyFox-2 in commercial operations should ensure compliance with upstream academic and non-commercial research terms or retrain exclusively on permissively licensed/owned data (e.g. ENA24 and private footage).
3. Model Safety & Operational Disclaimer
Limitation of Liability & No Warranty (AGPL-3.0 §§ 15–16): TinyFox-2 is provided "AS IS", without warranty of any kind. While TinyFox-2 demonstrates high empirical detection rates (0.983 mAP@0.50 on fox), no autonomous computer vision system is 100% infallible. Do not rely solely on this software for life-critical, commercial livestock protection, or security-critical perimeter defence.
Class Taxonomy
TinyFox-2 recognizes 12 distinct animal classes.
The breakthrough from v3/v4 to v5/TinyFox-2 was splitting the generic canid class into separate biological categories (dingo, raccoondog, domestic_dog). Lumping distinct canids caused the detector to learn overly loose decision boundaries that overlapped with foxes. Separating them completely eliminated fox-vs-canid misclassifications.
| Class ID | Class Name | Training Instances | Val Instances | Val mAP@0.50 | Val mAP@0.50–0.95 |
|---|---|---|---|---|---|
| 0 | fox (target) | 1,254 | 159 | 0.983 | 0.795 |
| 1 | bear | 369 | 72 | 0.978 | 0.817 |
| 2 | bigcat | 871 | 121 | 0.995 | 0.892 |
| 3 | cat | 787 | 145 | 0.972 | 0.804 |
| 4 | dingo | 836 | 115 | 0.956 | 0.857 |
| 5 | domestic_dog | 96 | 29 | 0.693 | 0.565 |
| 6 | lagomorph | 1,061 | 300 | 0.983 | 0.850 |
| 7 | mustelid | 1,295 | 241 | 0.960 | 0.747 |
| 8 | possum | 1,842 | 310 | 0.983 | 0.915 |
| 9 | quoll | 590 | 96 | 0.949 | 0.844 |
| 10 | raccoondog | 1,085 | 159 | 0.971 | 0.806 |
| 11 | ungulate | 2,749 | 423 | 0.976 | 0.852 |
| All | Macro Average | 12,835 | 2,194 | 0.950 | 0.812 |
(Note: domestic_dog has a low validation sample count in this split. The non-dog classes average 0.973 mAP@0.50).
Real-World Deployment Benchmark
Evaluated on 1,443 continuous nocturnal IR frames from camera-trap footage under realistic working distance and low-light noise:
| Metric | TinyFox 1.0 (NanoDet) | v3 (dog lumped) | v4 (canid lumped) | TinyFox-2 (v5 Split) |
|---|---|---|---|---|
| Fox Top Prediction Rate (@0.40) | ~38.0% | 45.7% | 79.9% | 88.2% |
| Rival Top Prediction Rate | N/A (1-class) | 36.5% | 4.6% | 0.0% |
| Same-Object Dual-Class Fire | N/A | 12.1% | 0.5% | 0.0% |
| Median Fox Confidence | 0.71 | 0.87 | 0.85 | 0.89 |
| False Fires on 225 Clean Negatives | 13 (5.8%) | 2 (0.9%) | 4 (1.8%) | 0 (0.0%) |
Operating Threshold Guide
- Recommended Operating Point (
conf = 0.40): Optimum balance for automated alerts. Delivers 88.2% fox capture with zero rival canid false triggers. - Search / Discovery (
conf = 0.25): Captures 88.5% of frames with minimal low-confidence background noise. - Strict High-Precision Alarm (
conf = 0.50): Zero false positives across any lighting condition with ~78% frame capture.
Quantization & Edge Compression
TinyFox-2 includes INT8 calibrated weights generated with YOLO-Quantizer (per-channel Conv weight quantization with sensitivity analysis).
| Format | File | Size | Reduction | Mean Box Delta | Class Agreement |
|---|---|---|---|---|---|
| PyTorch (FP32) | TinyFox-2.pt | 5.39 MB | — | Baseline | 100% |
| ONNX (FP32) | TinyFox-2.onnx | 9.48 MB | — | Baseline | 100% |
| ONNX (FP16) | TinyFox-2_fp16.onnx | 4.75 MB | 50.0% | < 0.05 px | 100% |
| ONNX (INT8) | TinyFox-2_int8.onnx | 2.60 MB | 72.5% | 0.68 px | 100% |
On validation images, the INT8 model matches the FP32 model with an average bounding box shift of less than 0.7 pixels on a 640×640 grid and 100% class match.
Repository Files
TinyFox-2/
├── README.md # Model Card & Documentation
├── LICENSE # GNU AGPL-3.0 + Attribution Notice
├── config.json # Architecture & class metadata
├── TinyFox-2.pt # PyTorch model checkpoint (Ultralytics)
├── TinyFox-2_last.pt # Resume training checkpoint
├── TinyFox-2.onnx # FP32 ONNX model (opset 20, 640x640)
├── TinyFox-2_fp16.onnx # FP16 ONNX model (for GPU/NPU)
├── TinyFox-2_int8.onnx # Calibrated INT8 ONNX (2.60 MB)
├── TinyFox-2.torchscript # TorchScript traced model
├── infer.py # Ultralytics inference script
├── infer_onnx.py # Standalone ONNX Runtime runner (no PyTorch required)
├── export_all_formats.py # Multi-format export utility
├── yolo_quantizer.py # YOLO mixed-precision quantizer (MIT)
├── upload_to_hf.ps1 # Hugging Face upload script
└── evaluation/ # Performance curves & validation plots
├── BoxF1_curve.png
├── BoxPR_curve.png
├── confusion_matrix.png
├── results.png
└── results.csv
Quickstart & Usage
1. PyTorch / Ultralytics API
from ultralytics import YOLO
# Load model
model = YOLO("TinyFox-2.pt")
# Predict on an infrared image
results = model.predict(source="night_frame.jpg", conf=0.40, imgsz=640)
# Display or save results
for r in results:
r.show() # Display
r.save(filename="output.jpg") # Save
2. Command-Line Inference
# Run on an image
python infer.py --source test_ir.jpg --conf 0.40 --output result.jpg
# Run on a video file
python infer.py --source trail_cam.mp4 --conf 0.40 --output annotated.mp4
# Run on an RTSP stream (live monitor)
python infer.py --source "rtsp://192.168.1.100:554/stream" --conf 0.40 --show
3. Lightweight ONNX Runtime (Zero PyTorch Dependency)
For low-power edge nodes (Raspberry Pi, mini PCs) without PyTorch:
pip install onnxruntime opencv-python numpy
python infer_onnx.py --model TinyFox-2_int8.onnx --image test_ir.jpg --conf 0.40
Exporting & Quantizing
To re-quantize or export to additional formats:
# Quantize to INT8 with YOLO-Quantizer
python yolo_quantizer.py TinyFox-2.onnx --mode int8 --per-channel --out TinyFox-2_int8.onnx
# Export to TorchScript / OpenVINO
python export_all_formats.py --model TinyFox-2.pt --imgsz 640
Citation & Acknowledgments
If you use TinyFox-2 in your research or deployment, please cite:
@misc{tinyfox2026,
title={TinyFox-2: High-Performance Night/IR Red Fox and Wildlife Object Detector},
author={Thenukegun10x and Contributors},
year={2026},
publisher={Hugging Face},
howpublished={\url{https://huggingface.co/Thenukegun10x/TinyFox-2}}
}
Upstream Acknowledgments
- Ultralytics YOLO: https://github.com/ultralytics/ultralytics (AGPL-3.0).
- NTLNP Dataset: Northeast China Tiger and Leopard National Park research group, Beijing Normal University.
- UNSW Dryland Ecology: Centre for Ecosystem Science, University of New South Wales.
- LILA BC (Camera Traps): Eastern North America 2024 (ENA24) and Snapshot USA contributors.
- Microsoft AI for Earth: MegaDetector v6 camera-trap framework.
- YOLO-Quantizer: https://github.com/Thenukegun10x/YOLO-Quantizer (MIT).