Documentation / Getting Started / Installation & Setup
Installation & Setup
fotonet is packaged as a pure PyTorch computer vision library with zero external dependencies beyond standard scientific Python packages.
PyTorch Compatibility
fotonet requires PyTorch 2.2+ (tested through PyTorch 2.11 with CUDA 12.8). No C++ compiler or external CUDA SDK is needed for standard Python deployment.
Install for Development
git clone https://github.com/hazegreleases/fotonet.git
cd fotonet
pip install -e .
Documentation / Getting Started / Quickstart Guide
Quickstart Guide
Load pre-trained weights and run deterministic, NMS-free object detection in under 5 lines of Python code.
Basic Object Detection
from fotonet import Fotonet
import cv2
model = Fotonet("fotonet_last.pt")
frame = cv2.imread("sample.jpg")
results = model.predict_bgr(frame, imgsz=640, conf=0.25)
for box in results[0].boxes:
print(f"Class: {box.cls} | Score: {box.conf:.3f} | BBox: {box.xyxy}")
Try it visually
You can explore recorded predictions and confidence thresholds on our
Inference demo.
Documentation / Getting Started / Pre-trained Checkpoints
Pre-trained Checkpoints
Official weights staged under strict release protocols. Checkpoints are never committed directly to git source repositories.
Official Checkpoint Lineup
All weights conform strictly to Schema 3 invariance (1,723,672 training parameters; 1,698,564 deployment parameters):
| Model File |
Version |
Epoch |
Parameters |
Release verification |
Status |
| fotonet_last.pt |
v1.0.0 |
80 / 300 |
1.73 M |
Published with release asset |
Release candidate |
| fotonet_best.pt |
v1.0.0 |
80 |
1.73 M |
Private staging only |
Private staging |
Checkpoints are written continuously during training, so the fingerprint above refers to the snapshot used for the currently published benchmark figures. Weights are distributed through GitHub Releases and never committed to the repository.
Schema Contract Notice
Checkpoints from legacy schema versions (v1/v2) are rejected by design. For technical specifications, see
Schema 3 Invariance Spec.
Documentation / Architecture / Schema 3 Invariance Spec
Schema 3 Invariance Spec
The architectural contract governing fotonete graph definition, tensor shapes, and state_dict backward compatibility.
Strict Mathematical Contract
In fotonet, EXPERIMENT_SCHEMA = 3 is the permanent standard. All proposed code refactors must guarantee:
- Output tensor shape strictly preserved:
[Batch, 8400, nc + 4] (where nc = 80, 4 = xywh coordinates).
- Exact integer channel counts across stages: Backbone [64, 96, 160], Neck [64, 96, 160].
- No conversion scripts required when resuming training or loading public weights.
- Unvarying
architecture_fingerprint hash across all platforms.
Documentation / Architecture / All-Dense Residual Stacks
All-Dense Residual Stacks
Memory-efficient feature propagation inspired by dense connectivity without cross-stage buffer thrashing.
Design Principles
Traditional transformer and depthwise architectures incur significant latency overhead on edge memory busses. fotonete utilizes dense residual blocks operating with explicit integer channels, keeping compute density high while maintaining a small GPU footprint.
Hardware Alignment
Channel dimensions (64, 96, 160) are aligned to 16/32-byte boundaries, ensuring optimal warps on NVIDIA Tensor Cores and ARM Neon vectors.
Documentation / Architecture / Dual-Branch NMS-Free Head
Dual-Branch NMS-Free Head
Eliminating Non-Maximum Suppression at inference time through one-to-one matched loss during training.
One-to-One vs One-to-Many Dual Training
During training, two branches operate simultaneously:
- Auxiliary One-to-Many Branch: Provides rich gradient supervision during early epochs for rapid convergence.
- Deploy One-to-One Branch: Matches exactly 1 prediction per ground-truth bounding box via Hungarian bipartite matching.
At deployment time, the auxiliary branch is completely discarded with zero cost. Predictions from the one-to-one head are 100% deterministic and require no NMS heuristics.
Documentation / Inference Runtimes / Python SDK Reference
Python SDK Reference
High-level Python API for loading models, batch processing, camera streaming, and coordinate decoding.
Fotonet(weights_path)
Initializes the deploy graph and auto-detects CUDA / CPU availability.
Methods:
model.predict_bgr(image_or_path, imgsz=640, conf=0.25): Primary entrypoint for OpenCV BGR images or file paths.
FastPredictor(model, device="cuda", half=True): High-throughput path with pinned memory and a reusable staging buffer; predict(frame) returns an (N, 6) array of x1, y1, x2, y2, score, class.
model.export(format="onnx", **kwargs): Export engine supporting ONNX, TensorRT, and CoreML.
Documentation / Inference Runtimes / Zero-Copy CUDA Path
Zero-Copy CUDA Fast-Path
Eliminate CPU-GPU memory roundtrips for maximum FPS in camera streaming pipelines.
Pinned Memory & CUDA Stream Binding
By pinning host memory and reusing one staging buffer and one GPU tensor per stream, per-frame allocation and host-device roundtrips disappear, bringing end-to-end latency down toward the pure GPU-pass time (see the Benchmarks section for current measured figures).
Documentation / Inference Runtimes / TensorRT Export
Fotonete TensorRT
Fotonete TensorRT FP16 is the deployment path measured on our RTX 4060 test bench. The engine is compiled from the current Fotonete checkpoint at 640 x 640 with a static batch shape.
What the measured pipeline covers
The figures below are TensorRT stage timings, not PyTorch and not browser ONNX timings. Each timing run used a fresh process, a 1-second warmup, and 1,000 measured inferences. The engine used FP16 where TensorRT selected it; TensorRT reports the resulting precision as FP32+FP16. H2D, enqueue, GPU compute, and D2H are independently measured and can overlap, so they should not be added together to recreate E2E latency.
Scope
These are processing-stage measurements for Fotonete. We do not claim individual convolution-kernel timings because those were not measured for this release.
Fotonete stage speeds
| Stage |
Batch 1 average |
Batch 1 min-max |
Batch 1 std. dev. |
Batch 8 average |
Batch 8 min-max |
Batch 8 std. dev. |
| GPU compute |
0.7680 ms |
0.7481-0.7980 ms |
0.0169 ms |
3.1309 ms |
3.1260-3.1419 ms |
0.0050 ms |
| End-to-end |
1.3747 ms |
1.3546-1.4051 ms |
0.0172 ms |
7.9320 ms |
7.9263-7.9436 ms |
0.0055 ms |
| Input H2D transfer |
0.3899 ms |
0.3894-0.3912 ms |
0.0006 ms |
3.0862 ms |
3.0852-3.0877 ms |
0.0008 ms |
| Kernel enqueue |
0.4942 ms |
0.4343-0.5968 ms |
0.0493 ms |
0.5575 ms |
0.5291-0.5883 ms |
0.0164 ms |
| Output D2H transfer |
0.2168 ms |
0.2168-0.2169 ms |
~0.0000 ms |
1.7149 ms |
1.7147-1.7160 ms |
0.0003 ms |
| Time to first frame |
331.1 ms |
319.0-382.8 ms |
14.8 ms |
532.3 ms |
525.3-544.5 ms |
4.9 ms |
| TensorRT runtime VRAM |
19.98 MiB |
19.98-19.98 MiB |
0.00 MiB |
84.36 MiB |
84.36-84.36 MiB |
0.00 MiB |
VRAM is TensorRT's execution-context device memory. It does not include the entire CUDA process, desktop compositor, or other applications using the GPU.
Fotonete vs YOLO26n
Both systems were compiled as static FP16 TensorRT engines at 640 x 640 and measured on the same RTX 4060 using the same 15-run protocol. The comparison is runtime-only; it does not change or imply an accuracy claim.
| Metric |
Fotonete |
YOLO26n |
Fotonete difference |
| Batch 1 GPU latency |
0.7680 ms |
1.6663 ms |
2.17x faster |
| Batch 1 E2E latency |
1.3747 ms |
2.0599 ms |
1.50x faster |
| Batch 8 GPU latency |
3.1309 ms |
5.0692 ms |
1.62x faster |
| Batch 8 E2E latency |
7.9320 ms |
8.1774 ms |
1.03x faster |
| Batch 1 E2E throughput |
727.5 FPS |
485.5 FPS |
+49.8% |
| Batch 8 E2E throughput |
1,008.6 img/s |
978.3 img/s |
+3.1% |
| Time to first frame |
331.1 ms |
315.5 ms |
15.6 ms slower |
| TensorRT runtime VRAM |
19.98 MiB |
15.23 MiB |
+4.75 MiB |
Python Export API
from fotonet import Fotonet
model = Fotonet("fotonet_best.pt")
model.export(
format="tensorrt",
path="fotonete.engine",
imgsz=640,
batch=1,
half=True,
dynamic=False,
device="cuda",
)
Documentation / Inference Runtimes / ONNX & CoreML Export
ONNX & CoreML Export
Export ONNX Runtime artifacts with static or dynamic batching. CoreML export is platform-specific and requires coremltools.
1-Line CLI Export
fotonet export model=fotonet_last.pt format=onnx path=fotonete.onnx opset=17
Documentation / Training / Hungarian Dual-Assignment
Hungarian Dual-Assignment Loss
Cost matrix formulation balancing SIoU localization error and focal classification probabilities.
Cost Matching Equation
The bipartite matching cost between prediction $i$ and ground truth $j$ is formulated as:
Cost(i, j) = λ_cls · FL(p_i, c_j) + λ_box · L1(b_i, b_j) + λ_siou · SIoU(b_i, b_j)
Documentation / Training / Resumable Recovery
Resumable Training Protocol
Deterministic interruption-safe recovery capturing optimizer moments, EMA state, LR schedule, and RNG seeds.
Automatic Resume
fotonet train model=fotonete data=my_dataset.yaml resume=fotonet_last.pt
Documentation / Training / Hardware Telemetry Rig
Hardware Telemetry Rig
Empirical hardware specifications and concurrent load disclosures for reproducibility.
Test Bench Specifications
- CPU: 13th Gen Intel Core i3-13100F · 4 cores / 8 threads
- GPU: NVIDIA GeForce RTX 4060 (8 GB VRAM) · driver 610.74
- Memory: 16 GB system RAM
- Storage: WDC WDS480G2G0C SSD · 395 MB/s measured sequential read
- Runtime: Windows 11 · CUDA 12.8 · PyTorch 2.11.0+cu128
- Load: Benchmarks are recorded in a clean process with no training job running. Timing, memory, and cold-start figures are averages of 15 independent runs. Peer models (YOLO26n and D-FINE N) are evaluated on the same machine and COCO val2017 sample; nothing is quoted from vendor pages.