Faster R-CNN
Faster R-CNN detects objects with a region proposal network feeding a two-stage classifier, the architecture that made region proposals part of the same trained network instead of a separate step. LibreYOLO ports the torchvision implementation for detection.
- Tasks
- detection
- Sizes
- n, s, m, l at 320 to 800 px
- Install
pip install libreyolo- Support tier
- Inference only, since v. Predict, validate and export only. Training features do not apply.
- Licenses
- Code BSD-3-Clause, weights BSD-3-Clause. Commercial use
Install
Faster R-CNN needs no optional extra. Everything it imports is in the base install.
pip install libreyoloPredict
Weights download from Hugging Face on first use and are cached locally.
from libreyolo import LibreYOLO, SAMPLE_IMAGE model = LibreYOLO("LibreFasterRCNNl.pt")result = model(SAMPLE_IMAGE, save=True) for box in result.boxes: print(box.cls, box.conf, box.xyxy)libreyolo predict model=LibreFasterRCNNl.pt source=https://raw.githubusercontent.com/LibreYOLO/libreyolo/release/libreyolo/assets/parkour.jpg save=TrueThe returned Results object is the one every family returns, so swapping in
a different detector is a one line change. conf and iou set the
confidence and NMS thresholds; Faster R-CNN keeps its upstream NMS step,
unlike a query-based detector. See prediction for sources,
streaming and result handling.
Variants
Four sizes, each a different torchvision configuration rather than a scaled
version of the same one: n is MobileNetV3-Large at a 320 px input, s is
the same backbone at 800 px, m is ResNet-50 with a feature pyramid, and l
is the v2 revision, with a deeper region proposal head and a four-convolution
box head in place of m's. n and s trade accuracy for a lighter
backbone.
Validate
val() returns a dictionary of metrics/ keys covering precision, recall,
mAP 50 and mAP 50-95, measured against any dataset in the format you trained
on.
from libreyolo import LibreYOLO model = LibreYOLO("LibreFasterRCNNl.pt")metrics = model.val(data="my-dataset.yaml") print(metrics["metrics/mAP50-95"])print(metrics["metrics/mAP50"])libreyolo val model=LibreFasterRCNNl.pt data=my-dataset.yamlExport
| Task | ONNX | TorchScript | ExecuTorch | TensorRT | OpenVINO | Paddle | MNN | RKNN | ncnn | TFLite | CoreML | Core AI |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Detection | Detection to ONNX: supported. | Detection to TorchScript: not supported | Detection to ExecuTorch: not supported | Detection to TensorRT: not supported | Detection to OpenVINO: not supported | Detection to Paddle: not supported | Detection to MNN: not supported | Detection to RKNN: not supported | Detection to ncnn: not supported | Detection to TFLite: not supported | Detection to CoreML: not supported | Detection to Core AI: not supported |
Faster R-CNN exports to ONNX only, at batch size 1. The exported graph keeps
the upstream resize step inside it, so LibreYOLO forces dynamic=True
regardless of what is passed, to keep the graph valid for sources that are
not square. An exported .onnx file loads back through LibreYOLO() on its
file suffix and returns the same Results.
from libreyolo import LibreYOLO model = LibreYOLO("LibreFasterRCNNl.pt")model.export(format="onnx", imgsz=800)libreyolo export model=LibreFasterRCNNl.pt format=onnx imgsz=800from libreyolo import LibreYOLO, SAMPLE_IMAGE # The factory routes on the file suffix, so an exported artifact loads# like any checkpoint and returns the same Results object.model = LibreYOLO("LibreFasterRCNNl.onnx")result = model(SAMPLE_IMAGE) print(result.boxes.xyxy)Checkpoints
Every published weight file for this family.
| File | Input (px) | Weights license |
|---|---|---|
| Detection | ||
| LibreFasterRCNNn.pt | 320 | bsd-3-clause |
| LibreFasterRCNNs.pt | 800 | bsd-3-clause |
| LibreFasterRCNNm.pt | 800 | bsd-3-clause |
| LibreFasterRCNNl.pt | 800 | bsd-3-clause |
Every file above exists in the LibreYOLO org today and downloads on first use.
Licensing
Check the license on the Hugging Face repository of the specific weights you download. Every checkpoint in the LibreYOLO org carries one, and they are not always the same across a family. That repository is the authoritative source; the summary below describes what applied when this page was last verified.
This is a description of the licenses involved, not legal advice. If the answer matters commercially, read the licenses yourself and take your own counsel.
- Original work
- Faster R-CNN, PyTorch
- Upstream license
- BSD-3-Clause
- Upstream source
- github.com/pytorch/vision
- LibreYOLO code
- MIT
- Weights
- BSD-3-Clause, republished at huggingface.co/LibreYOLO
- Interpretation
- BSD-3-Clause is a permissive license, so this code can be used in commercial and closed-source products with no obligation on your own application code. It asks only that you keep the copyright notice and disclaimer with any copy you redistribute, and it carries no patent grant. The four published checkpoints used for parity testing are not distributed in the LibreYOLO source tree: torchvision's own documentation notes that a pretrained model's terms may depend on its training data, so each Hugging Face mirror ships the BSD text on that implied basis and repeats the caveat rather than issuing an explicit checkpoint-specific grant.
Citation
@inproceedings{renNIPS15fasterrcnn,
Author = {Shaoqing Ren and Kaiming He and Ross Girshick and Jian Sun},
Title = {Faster {R-CNN}: Towards Real-Time Object Detection
with Region Proposal Networks},
Booktitle = {Advances in Neural Information Processing Systems ({NIPS})},
Year = {2015}
}Copied from the authors' citation block at github.com/rbgirshick/py-faster-rcnn#citing-faster-r-cnn.