MoGe-2
MoGe-2 是一个单次前向的单目几何模型,从一张 RGB 图像预测稠密的表面法线场。LibreYOLO 只把它用于法线估计,通过官方的 ViT-S、ViT-B 和 ViT-L 检查点。
- 任务
- normal
- 尺寸
- s, b, l at 518 px
- 安装
pip install libreyolo- 支持层级
- 仅推理,自 v 起。仅支持预测、验证和导出。训练相关的功能不适用。
- 许可
- 代码采用 MIT,权重采用 MIT。商用
安装
MoGe-2 不需要任何可选 extra。它导入的一切都在基础安装里。
pip install libreyolo预测
权重在首次使用时自动下载:LibreYOLO 直接从官方检查点获取对应的尺寸,并缓存在本地。
from libreyolo import LibreYOLO, SAMPLE_IMAGE model = LibreYOLO("LibreMoGe2s-normal.pt")result = model(SAMPLE_IMAGE, save=True) normal = result.normal_mapprint(normal.array.shape) # (H, W, 3) float32 单位向量libreyolo predict model=LibreMoGe2s-normal.pt source=https://raw.githubusercontent.com/LibreYOLO/libreyolo/release/libreyolo/assets/parkour.jpg save=TrueMoGe-2 返回的是一个稠密场,而不是一组检测结果,所以 result.boxes 是空的,
conf、iou 和 max_det 都不起作用。result.normal_map 装的是结果:一个
(H, W, 3) 的单位向量数组,位于 OpenCV 相机坐标系中,其中 +x 向右,+y 向下,
+z 指向场景内部,正对相机的表面读作 (0, 0, -1)。对一个图像列表做预测时,每张
图像跑一次前向;这个家族没有堆叠成批的快速路径。数据源、流式处理和结果处理见
预测。
变体
三种编码器尺寸以独立的检查点(checkpoint)发布:ViT-S、ViT-B 和 ViT-L,输入 分辨率都相同。LibreYOLO 的基准测试工具尚未测过这个家族,所以没有公开的精度数字 可供比较;请按你自己的算力预算挑一个尺寸。
验证
val() 在成对的法线图数据集上测量角度误差:图像旁边放文件名主干相同的 16 位法线
PNG,还可以带一个可选的有效性掩码,让填充像素和无效像素都不计入。它返回以度为
单位的平均角度误差和中位角度误差,外加落在 11.25、22.5 和 30 度以内的像素百分比。
from libreyolo import LibreYOLO model = LibreYOLO("LibreMoGe2s-normal.pt")metrics = model.val(data="my-dataset.yaml", imgsz=518) print(metrics["metrics/mean_angular_error"]) # 单位为度print(metrics["metrics/median_angular_error"])print(metrics["metrics/within_11_25"]) # 像素百分比libreyolo val model=LibreMoGe2s-normal.pt data=my-dataset.yaml imgsz=518导出
| 任务 | ONNX | TorchScript | ExecuTorch | TensorRT | OpenVINO | Paddle | MNN | RKNN | ncnn | TFLite | CoreML | Core AI |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| normal | normal to ONNX:支持 | normal to TorchScript:支持 | normal to ExecuTorch:支持 | normal to TensorRT:支持 | normal to OpenVINO:支持 | normal to Paddle:不支持 | normal to MNN:不支持 | normal to RKNN:不支持 | normal to ncnn:支持 | normal to TFLite:不支持 | normal to CoreML:不支持 | normal to Core AI:不支持 |
法线导出使用固定分辨率、批大小为 1 的运行时契约:dynamic 以及 1 以外的 batch
都会被拒绝,而且 imgsz 必须能被 ViT 编码器的 patch size 整除,LibreYOLO 会在
运行开始前检查这一点。导出的产物按文件后缀经由 LibreYOLO() 重新加载,所以一个
.onnx 文件的表现和检查点一样,返回同样的 Results。
from libreyolo import LibreYOLO model = LibreYOLO("LibreMoGe2s-normal.pt")model.export(format="onnx", imgsz=518)model.export(format="tensorrt", imgsz=518, half=True)libreyolo export model=LibreMoGe2s-normal.pt format=onnx imgsz=518libreyolo export model=LibreMoGe2s-normal.pt format=tensorrt imgsz=518 half=Truefrom libreyolo import LibreYOLO, SAMPLE_IMAGE model = LibreYOLO("LibreMoGe2s-normal.onnx")result = model(SAMPLE_IMAGE) print(result.normal_map.array.shape)许可证
请检查你所下载的具体权重在 Hugging Face 仓库中的许可。LibreYOLO 组织里的每个检查点都附有许可,同一家族内也不一定相同。该仓库是权威来源;以下摘要说明本页上次验证时适用的情况。
这里只说明涉及的许可证,不构成法律意见。如果答案对商用很重要,请自行阅读许可证并咨询法律顾问。
- 原始工作
- MoGe-2, Microsoft
- 上游许可
- MIT
- LibreYOLO 代码
- MIT
- 权重
- 采用 MIT 许可,由作者分发。LibreYOLO 不托管或镜像这些权重。
- 解读
- MIT is a permissive license: the code and the official ViT-S, ViT-B and ViT-L checkpoints can be used in commercial and closed-source products. It asks that you keep the license text and copyright notice with any copy you redistribute, and it places no obligation on your own application code. LibreYOLO downloads these checkpoints directly from the official Hugging Face repositories at a pinned revision rather than copying them into its own organization, and verifies each file against a recorded SHA-256 checksum before use. The DINOv2 encoder MoGe-2 builds on is separately licensed Apache-2.0 by Meta AI; LibreYOLO reuses the DINOv2 implementation already bundled for its Depth Anything V2 family rather than copying it again here.
LibreYOLO 不会把这些检查点复制到自己的组织下。LibreYOLO("LibreMoGe2s-normal.pt")
会按固定的修订版本(revision)直接从官方 Hugging Face 仓库下载对应的尺寸,并在
使用前对照记录的 SHA-256 校验和验证该文件。
引用
@inproceedings{wang2025moge,
title={Moge: Unlocking accurate monocular geometry estimation for open-domain images with optimal training supervision},
author={Wang, Ruicheng and Xu, Sicheng and Dai, Cassie and Xiang, Jianfeng and Deng, Yu and Tong, Xin and Yang, Jiaolong},
booktitle={Proceedings of the Computer Vision and Pattern Recognition Conference},
pages={5261--5271},
year={2025}
}
@misc{wang2025moge2,
title={MoGe-2: Accurate Monocular Geometry with Metric Scale and Sharp Details},
author={Ruicheng Wang and Sicheng Xu and Yue Dong and Yu Deng and Jianfeng Xiang and Zelong Lv and Guangzhong Sun and Xin Tong and Jiaolong Yang},
year={2025},
eprint={2507.02546},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2507.02546},
}复制自作者在 github.com/microsoft/MoGe#-citation 上提供的引用块。