L2CS-Net
L2CS-Net 是一个两阶段视线估计器:先由人脸检测器定位人脸,再由一个带两个角度分箱分类 head 的 ResNet 主干为每张人脸预测俯仰角和偏航角。LibreYOLO 对它的封装仅支持推理。
- 任务
- gaze
- 尺寸
- r18, r34, r50, r101, r152 at 448 px
- 安装
pip install libreyolo- 支持层级
- 仅推理,自 v 起。仅支持预测、验证和导出。训练相关的功能不适用。
- 上游
- L2CS-Net,由 Ahmed A. Abdelrahman et al. 发布,采用 Gaze360 dataset terms: research and non-commercial use only, no redistribution 许可。论文、源码
- 许可
- 代码采用 MIT,权重采用 Gaze360 dataset terms: research and non-commercial use only, no redistribution。商用
安装
只要你手上已经有检查点,构造 L2CS-Net 模型、用它预测或者导出它,都不需要任何 可选 extra。
pip install libreyoloLibreYOLO 唯一能自动获取的检查点是一个在 Gaze360 上训练的 ResNet-50,它走
gdown 下载,而不是普通的 HTTP 镜像,因为它放在作者本人的 Google Drive 上,而
不是 LibreYOLO 组织下。这条路径需要 gaze extra:
pip install "libreyolo[gaze]"没有它的话,LibreYOLO 会打印手动下载说明,而不是悄无声息地失败。
预测
from libreyolo import LibreYOLO, SAMPLE_IMAGE # 不给 face_detector 时,会回退到 OpenCV 自带的人脸检测器# (OpenCV 4 上是 Haar,OpenCV 5 上是 YuNet),所以除了 L2CS 检查点# 本身之外不需要任何额外下载model = LibreYOLO("LibreL2CSr50.pt")result = model(SAMPLE_IMAGE) print(result.gaze.pitch, result.gaze.yaw)libreyolo predict model=LibreL2CSr50.pt source=https://raw.githubusercontent.com/LibreYOLO/libreyolo/release/libreyolo/assets/parkour.jpg save=Truefrom libreyolo import LibreYOLO, SAMPLE_IMAGE model = LibreYOLO("LibreL2CSr50.pt") # 把你已经跑过的检测器给出的检测框交给 L2CSresult = model(SAMPLE_IMAGE, face_boxes=[[34, 12, 90, 80]]) # 或者指定某个自带的人脸检测器result = model(SAMPLE_IMAGE, face_detector="yunet")L2CS-Net 是一个两阶段估计器:先跑人脸检测器,再由视线 head 从它返回的每一张人脸
裁剪图里读出俯仰角和偏航角。不做设置时,预测会回退到 OpenCV 自带的检测器,所以
只要 L2CS 检查点本身到手,一次裸调用就能跑起来,不需要额外下载。face_boxes 接
受你已经跑过的检测器给出的检测框;face_detector 接受 "auto"、"haar"、
"yunet"、一个 LibreYOLO 检测模型,或者一个普通的可调用对象。result.gaze 以弧
度给出俯仰角和偏航角,逐行与 result.boxes(也就是检测到的人脸框)对齐。数据
源、流式处理和结果处理见预测。
变体
五种骨干深度共用一个输入分辨率,接受的参数也相同。唯一一份已发布检查点背后的数 据集 Gaze360 训练的是 ResNet-50;另外四种深度在架构上是支持的,但没有可加载的已 发布权重。
导出
| 任务 | ONNX | TorchScript | ExecuTorch | TensorRT | OpenVINO | Paddle | MNN | RKNN | ncnn | TFLite | CoreML | Core AI |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| gaze | gaze to ONNX:支持 | gaze to TorchScript:支持 | gaze to ExecuTorch:支持 | gaze to TensorRT:支持 | gaze to OpenVINO:支持 | gaze to Paddle:不支持 | gaze to MNN:不支持 | gaze to RKNN:不支持 | gaze to ncnn:不支持 | gaze to TFLite:不支持 | gaze to CoreML:不支持 | gaze to Core AI:不支持 |
from libreyolo import LibreYOLO model = LibreYOLO("LibreL2CSr50.pt")model.export(format="onnx")model.export(format="tensorrt", half=True)libreyolo export model=LibreL2CSr50.pt format=onnximport numpy as npimport onnxruntime as ort # 导出的计算图只有 ResNet 主干和那两个角度分箱 head:它接收一份预处理好# 的 448x448 人脸裁剪图,返回的是原始的 (yaw_logits, pitch_logits),# 而不是解码后的角度;softmax、分箱期望和角度换算仍留在 Python 里,见# libreyolo.models.l2cs.utils.bin_logits_to_anglessession = ort.InferenceSession("LibreL2CSr50.onnx")name = session.get_inputs()[0].nameyaw_logits, pitch_logits = session.run( None, {name: np.zeros((1, 3, 448, 448), dtype=np.float32)})许可证
请检查你所下载的具体权重在 Hugging Face 仓库中的许可。LibreYOLO 组织里的每个检查点都附有许可,同一家族内也不一定相同。该仓库是权威来源;以下摘要说明本页上次验证时适用的情况。
这里只说明涉及的许可证,不构成法律意见。如果答案对商用很重要,请自行阅读许可证并咨询法律顾问。
- 原始工作
- L2CS-Net, Ahmed A. Abdelrahman et al.
- 上游许可
- Gaze360 dataset terms: research and non-commercial use only, no redistribution
- LibreYOLO 代码
- MIT
- 权重
- 采用 Gaze360 dataset terms: research and non-commercial use only, no redistribution 许可,由作者分发。LibreYOLO 不托管或镜像这些权重。
- 解读
- The L2CS-Net source is MIT and may be used, modified and redistributed, including commercially. The one checkpoint LibreYOLO can fetch automatically, a ResNet-50 trained on Gaze360, is not covered by that grant: the Gaze360 dataset license restricts use of models trained on it to research and non-commercial purposes and forbids redistribution. LibreYOLO does not mirror or host that checkpoint. It downloads it, on request, directly from the author's own distribution and prints the Gaze360 terms once before the transfer starts. A model trained on data you hold the rights to, using this MIT architecture, carries none of those restrictions.
LibreYOLO 不托管也不镜像任何 L2CS 检查点:与本站大多数其他家族不同,LibreYOLO 的 Hugging Face 组织下没有这个家族的任何东西。库能自动获取的那一份检查点直接来自作 者本人的 Google Drive 分发,下载开始前会先打印 Gaze360 的许可证声明作为门槛,它 并不是上面的摘要所暗示的那份「在 huggingface.co/LibreYOLO 重新发布」的副本。