EfficientNetV2
EfficientNetV2 is an image classifier whose depth, width and per-stage block choices were found by neural architecture search, jointly optimizing for accuracy and training speed rather than accuracy alone. LibreYOLO supports it for one task: classification.
- Tasks
- classify
- Sizes
- b0, b1, b2, b3 at 224 to 300 px
- Install
pip install libreyolo- Support tier
- Supported, since v. Supporting trainables: kept green in CI, features land opportunistically.
- Licenses
- Code Apache-2.0, weights Apache-2.0. Commercial use
Install
EfficientNetV2 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("LibreEfficientNetV2b0-cls.pt")result = model(SAMPLE_IMAGE, save=True) print(result.probs.top1, result.probs.top1conf)print(result.probs.top5)libreyolo predict model=LibreEfficientNetV2b0-cls.pt source=cat.jpg save=TrueThe returned Results object is the one every family returns, so swapping in
a different model is a one line change. A classifier carries no boxes or
masks: result.probs holds the whole-image prediction, with top1, top5,
top1conf and top5conf. conf, iou and max_det are accepted for API
parity but have no effect, since there is nothing to threshold or suppress on
a single probability vector. See prediction for sources,
streaming and result handling.
Variants
Four sizes, b0 through b3, each evaluated at its own resolution and crop
ratio rather than sharing one input size across the family. Picking a size is
a straight parameter-count-for-accuracy trade. The task is fixed: every size
covers classification only. The weights filename ends -cls.pt on every
size, and that suffix is what the factory reads to route to this family; no
task= argument is needed.
Train
Fine-tuning starts from the published ImageNet backbone and rebuilds the
final classifier layer to the target dataset's class count automatically.
imgsz defaults to the size's own evaluation resolution unless set
explicitly.
from libreyolo import LibreYOLO model = LibreYOLO("LibreEfficientNetV2b0-cls.pt")model.train(data="imagenette160", epochs=5)libreyolo train model=LibreEfficientNetV2b0-cls.pt data=imagenette160 epochs=5libreyolo train model=LibreEfficientNetV2b0-cls.pt data=imagenette160 \ epochs=50 device=0,1 batch=-1Left alone, the trainer runs 100 epochs at lr0=1e-3 with AdamW, a batch of
64 and early stopping after 50 epochs without improvement. data accepts a
dataset root (train/ and val/, one folder per class), a known short name
such as imagenette160, or a .zip URL. lora=True is not supported here;
passing it raises, since LoRA in LibreYOLO targets transformer components
with nn.Linear layers and this family's MBConv blocks have none.
See training for datasets, augmentation, multi-GPU and loggers.
Validate
val() returns a dictionary of metrics/ keys. For classification that is
top-1 and top-5 accuracy over the validation split.
from libreyolo import LibreYOLO model = LibreYOLO("LibreEfficientNetV2b0-cls.pt")metrics = model.val(data="imagenette160") print(metrics["metrics/accuracy_top1"])print(metrics["metrics/accuracy_top5"])libreyolo val model=LibreEfficientNetV2b0-cls.pt data=imagenette160Export
| Task | ONNX | TorchScript | ExecuTorch | TensorRT | OpenVINO | Paddle | MNN | RKNN | ncnn | TFLite | CoreML | Core AI |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| classify | classify to ONNX: supported. | classify to TorchScript: supported. | classify to ExecuTorch: supported. | classify to TensorRT: supported. | classify to OpenVINO: supported. | classify to Paddle: not supported | classify to MNN: not supported | classify to RKNN: not supported | classify to ncnn: supported. | classify to TFLite: supported. | classify to CoreML: not supported | classify 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. Export lists the arguments every format accepts
and the extras a few of them add.
from libreyolo import LibreYOLO model = LibreYOLO("LibreEfficientNetV2b0-cls.pt")model.export(format="onnx")model.export(format="tensorrt", half=True)libreyolo export model=LibreEfficientNetV2b0-cls.pt format=onnxlibreyolo export model=LibreEfficientNetV2b0-cls.pt format=tensorrt half=Truefrom 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("LibreEfficientNetV2b0-cls.onnx")result = model(SAMPLE_IMAGE) print(result.probs.top1)Checkpoints
Every published weight file for this family.
| File | Input (px) | Weights license |
|---|---|---|
| classify | ||
| LibreEfficientNetV2b0-cls.pt | 224 | apache-2.0 |
| LibreEfficientNetV2b1-cls.pt | 240 | apache-2.0 |
| LibreEfficientNetV2b2-cls.pt | 260 | apache-2.0 |
| LibreEfficientNetV2b3-cls.pt | 300 | apache-2.0 |
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
- EfficientNetV2, Google
- Upstream license
- Apache-2.0
- Upstream source
- github.com/huggingface/pytorch-image-models
- LibreYOLO code
- MIT
- Weights
- Apache-2.0, republished at huggingface.co/LibreYOLO
- Interpretation
- Apache-2.0 is a permissive license, so these weights can be used in commercial and closed-source products. It asks you to keep its license text and attribution notices with any copy of the weights you redistribute, and it grants a patent license. It places no obligation on your own application code, and weights you train yourself on your own data are yours. The architecture is Google's design, whose reference implementation at google/automl is also Apache-2.0; LibreYOLO's implementation follows the block definitions, TensorFlow "SAME" padding and naming in timm, whose tf_efficientnetv2_b{0,1,2,3} ImageNet-1k weights (ported by Ross Wightman, no ImageNet-21k or extra data) are licensed Apache-2.0 and are what LibreYOLO ships.