VGG

VGG 是一个卷积图像分类器,由一叠尺寸统一的 3x3 小卷积堆叠而成,而不是更大的滤波器。LibreYOLO 提供 16 层和 19 层两种尺寸,每种都有普通版和带批归一化(batch normalization)的版本,用于图像分类。

任务
classify
尺寸
16, 19, 16bn, 19bn at 224 px
安装
pip install libreyolo
支持层级
仅推理,自 v 起。仅支持预测、验证和导出。训练相关的功能不适用。
上游
VGG,由 Visual Geometry Group, University of Oxford 发布,采用 BSD-3-Clause 许可。论文源码
许可
代码采用 BSD-3-Clause,权重采用 BSD-3-Clause。商用

安装

VGG 不需要任何可选 extra。它导入的一切都在基础安装里。

bash
pip install libreyolo

预测

权重在首次使用时从 Hugging Face 下载,并缓存在本地。

Python
from libreyolo import LibreYOLO, SAMPLE_IMAGE model = LibreYOLO("LibreVGG16-cls.pt")result = model(SAMPLE_IMAGE, save=True) probs = result.probsprint(probs.top1, probs.top1conf)print(probs.top5, probs.top5conf)
CLI
libreyolo predict model=LibreVGG16-cls.pt source=https://raw.githubusercontent.com/LibreYOLO/libreyolo/release/libreyolo/assets/parkour.jpg save=True

分类器返回的是 result.probs 而不是 result.boxestop1top5 给出类别 索引,top1conftop5conf 给出对应的置信度。预测固定以 224px 输入运行,传入 不同的 imgsz 会报错。数据源、流式处理和结果处理见预测

变体

四种尺寸:16 层和 19 层卷积,每种各有一个普通版本和一个带批归一化的变体。随库 提供的权重来自 torchvision 后期从零开始的 ImageNet 训练,而不是牛津团队 2014 年 最初 Caffe 版本的转换结果。LibreYOLO 只以推理方式提供这个家族:预测、ImageNet 风格的 top-1/top-5 验证和导出都支持,微调没有实现。

验证

val() 在 ImageFolder 风格的划分上运行(一个带 train/val/ 子文件夹的 目录,每个类别一个文件夹),返回 top-1 和 top-5 精度。

Python
from libreyolo import LibreYOLO model = LibreYOLO("LibreVGG16-cls.pt") # data 是一个根目录,下面是按类别分文件夹的 train/ 和 val/ 划分# (ImageFolder 布局),而不是数据集 YAMLmetrics = model.val(data="imagenet-1k/") print(metrics["metrics/accuracy_top1"])print(metrics["metrics/accuracy_top5"])
CLI
libreyolo val model=LibreVGG16-cls.pt data=imagenet-1k/

导出

任务ONNXTorchScriptExecuTorchTensorRTOpenVINOPaddleMNNRKNNncnnTFLiteCoreMLCore AI
classifyclassify to ONNX:支持classify to TorchScript:支持classify to ExecuTorch:支持classify to TensorRT:支持classify to OpenVINO:支持classify to Paddle:不支持classify to MNN:不支持classify to RKNN:不支持classify to ncnn:支持classify to TFLite:不支持classify to CoreML:不支持classify to Core AI:不支持

导出的产物按文件后缀经由 LibreYOLO() 重新加载,所以一个 .onnx.engine 文件的表现和检查点(checkpoint)一样,返回同样的 Results导出列出了每种格式接受的参数,以及其中少数几种额外增加的参数。

Python
from libreyolo import LibreYOLO model = LibreYOLO("LibreVGG16-cls.pt")model.export(format="onnx")model.export(format="tensorrt", half=True)
CLI
libreyolo export model=LibreVGG16-cls.pt format=onnxlibreyolo export model=LibreVGG16-cls.pt format=tensorrt half=True
使用导出的文件
from libreyolo import LibreYOLO, SAMPLE_IMAGE # 工厂按文件后缀分发,所以导出的产物加载方式和任何检查点一样,# 返回的也是同一个 Results 对象model = LibreYOLO("LibreVGG16-cls.onnx")result = model(SAMPLE_IMAGE) print(result.probs.top1)

检查点

这个家族已发布的全部权重文件。

文件输入(px)权重许可
classify
LibreVGG16-cls.pt224bsd-3-clause
LibreVGG19bn-cls.pt224bsd-3-clause
LibreVGG19-cls.pt224bsd-3-clause
LibreVGG16bn-cls.pt224bsd-3-clause

上面的每个文件目前都在 LibreYOLO 组织中,并会在首次使用时下载。

许可证

请检查你所下载的具体权重在 Hugging Face 仓库中的许可。LibreYOLO 组织里的每个检查点都附有许可,同一家族内也不一定相同。该仓库是权威来源;以下摘要说明本页上次验证时适用的情况。

这里只说明涉及的许可证,不构成法律意见。如果答案对商用很重要,请自行阅读许可证并咨询法律顾问。

原始工作
VGG, Visual Geometry Group, University of Oxford
上游许可
BSD-3-Clause
LibreYOLO 代码
MIT
权重
采用 BSD-3-Clause 许可,重新发布在 huggingface.co/LibreYOLO
解读
BSD-3-Clause is a permissive license, so these weights can be used in commercial and closed-source products. It asks you to keep the copyright notice, the list of conditions and the disclaimer with any copy you redistribute, and it forbids using the contributors' names to endorse a derived product without permission; it carries no explicit patent grant. LibreYOLO's code and the four shipped checkpoints (16, 19, 16-BN, 19-BN) are both derived from torchvision, not from the Oxford group's original 2014 Caffe release, which is a separate model under Creative Commons Attribution and is not what LibreYOLO redistributes. Torchvision itself notes that BSD-3-Clause redistribution of a pretrained checkpoint is an implied basis rather than a grant written for that specific checkpoint, and that pretrained-model terms can depend on the data a model was trained on; LibreYOLO repeats that caveat on each hosted weights repository.

已针对 LibreYOLO v1.5.0 验证。本页的支持表、检查点和基准测试数据由已发布的库和权重生成,并非手工编写。