YOLOv7

YOLOv7 is an anchor-based, single-stage detector whose head adds learned implicit-knowledge offsets before the final convolution. LibreYOLO supports its single published size for detection.

Tasks
detection
Sizes
b at 640 px
Install
pip install libreyolo
Support tier
Supported, since v. Supporting trainables: kept green in CI, features land opportunistically.
Upstream
YOLOv7 by MultimediaTechLab, MIT. Paper, source
Licenses
Code MIT, weights MIT. Commercial use

Install

YOLOv7 needs no extra beyond the base package.

bash
pip install libreyolo

Predict

Weights download from Hugging Face on first use and are cached locally.

Python
from libreyolo import LibreYOLO, SAMPLE_IMAGE model = LibreYOLO("LibreYOLO7b.pt")result = model(SAMPLE_IMAGE, save=True) for box in result.boxes:    print(box.cls, box.conf, box.xyxy)
CLI
libreyolo predict model=LibreYOLO7b.pt source=https://raw.githubusercontent.com/LibreYOLO/libreyolo/release/libreyolo/assets/parkour.jpg save=True

The returned Results object is the one every family returns, so swapping in a different detector is a one line change. conf sets the confidence threshold and iou the NMS threshold applied after the anchor-based head is decoded. See prediction for sources, streaming and result handling.

Variants

LibreYOLO ships one size, b. Upstream publishes a single YOLOv7 model, so there is no size to choose between.

Train

Python
from libreyolo import LibreYOLO model = LibreYOLO("LibreYOLO7b.pt")model.train(data="my-dataset.yaml", epochs=300, imgsz=640, batch=16, lr0=0.01)
CLI
libreyolo train model=LibreYOLO7b.pt data=my-dataset.yaml \  epochs=300 imgsz=640 batch=16 lr0=0.01
Warm start from a fresh model
from libreyolo import LibreYOLO7 # pretrained=True always loads the published LibreYOLO7b.pt checkpoint,# regardless of what this instance was constructed with. Constructing# the class directly, rather than through LibreYOLO(), starts with no# weights loaded at all.model = LibreYOLO7(None, size="b")model.train(data="my-dataset.yaml", epochs=300, pretrained=True)

pretrained is read, unlike the no-op of the same name on some other families here: pass True to warm-start from the published LibreYOLO7b.pt checkpoint (auto-downloaded), or a path or name for anything else. That published checkpoint is 80-class COCO, so requesting it on a model already rebuilt for a different class count first rebuilds back to 80, loads it, then transfers every shape-matching tensor into the target head count once the dataset's class count is read. resume=True cannot be combined with pretrained. Left at the default None, training continues from whatever the model was constructed with, or from a random initialization if nothing was loaded.

Left alone otherwise, the trainer runs 300 epochs at lr0=0.01 with SGD momentum 0.937, a 3-epoch warmup, and the same SimOTA assignment and final 15-epoch no-augmentation phase YOLOX uses, adapted to the anchor-based head. The one difference: YOLOX adds an L1 box-regression refinement during those final epochs that v7 skips, because v7's SimOTA loss carries no raw-offset L1 branch to refine.

See training for datasets, augmentation, multi-GPU and loggers.

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.

Python
from libreyolo import LibreYOLO model = LibreYOLO("LibreYOLO7b.pt")metrics = model.val(data="my-dataset.yaml") print(metrics["metrics/mAP50-95"])print(metrics["metrics/mAP50"])
CLI
libreyolo val model=LibreYOLO7b.pt data=my-dataset.yaml

Export

TaskONNXTorchScriptExecuTorchTensorRTOpenVINOPaddleMNNRKNNncnnTFLiteCoreMLCore AI
DetectionDetection to ONNX: supported. Detection to TorchScript: supported. Detection to ExecuTorch: supported. Detection to TensorRT: supported. Detection to OpenVINO: supported. Detection to Paddle: not supportedDetection to MNN: not supportedDetection to RKNN: not supportedDetection to ncnn: supported. Detection to TFLite: not supportedDetection to CoreML: not supportedDetection to Core AI: supported.

An exported artifact loads back through LibreYOLO() on its file suffix, so a .onnx or .engine file behaves like a checkpoint and returns the same Results. Running the graph in a bare runtime, with no LibreYOLO installed, is also supported, but then preprocessing and postprocessing are yours to write.

Python
from libreyolo import LibreYOLO model = LibreYOLO("LibreYOLO7b.pt")model.export(format="onnx", imgsz=640)model.export(format="tensorrt", imgsz=640, half=True)
CLI
libreyolo export model=LibreYOLO7b.pt format=onnx imgsz=640libreyolo export model=LibreYOLO7b.pt format=tensorrt imgsz=640 half=True
Use the exported file
from 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("LibreYOLO7b.onnx")result = model(SAMPLE_IMAGE) print(result.boxes.xyxy)

Checkpoints

Every published weight file for this family.

FileInput (px)Weights license
Detection
LibreYOLO7b.pt640mit

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
YOLOv7, MultimediaTechLab
Upstream license
MIT
LibreYOLO code
MIT
Weights
MIT, republished at huggingface.co/LibreYOLO
Interpretation
MIT is a permissive license, so these weights can be used in commercial and closed-source products. The one standing obligation is to keep the license text and the copyright notice, Kin-Yiu Wong and Hao-Tang Tsui, with any copy you redistribute. It places no condition on your own application code, and a model you train yourself on your own data is yours. The port follows the authors' MIT re-release of YOLOv7, not the GPL-3.0 WongKinYiu/yolov7 repository that carries the same model, so the permissive terms come from the source LibreYOLO actually derives from.

Citation

@inproceedings{wang2022yolov7,
      title={{YOLOv7}: Trainable Bag-of-Freebies Sets New State-of-the-Art for Real-Time Object Detectors},
      author={Wang, Chien-Yao and Bochkovskiy, Alexey and Liao, Hong-Yuan Mark},
      year={2023},
      booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
}

Copied from the authors' citation block at github.com/MultimediaTechLab/YOLO#citations.

Verified against LibreYOLO v1.5.0. Support tables, checkpoints and benchmark numbers on this page are generated from the released library and the published weights, not written by hand.