【腾讯犀牛鸟2026】Tencent-Hunyuan/HunyuanOCR ncnn 移植与多平台部署 #6808
HGinkgo
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
HunyuanOCR-ncnn 发布说明
作者:HGinkgo
日期:2026 年 7 月 8 日
版本:v0.2
项目仓库:HGinkgo/HunyuanOCR-ncnn
项目概览
HunyuanOCR-ncnn 是一个面向 Tencent HunyuanOCR 的 ncnn C++ runtime。项目将 HunyuanOCR 推理链路拆成 ncnn 子模块,并用 C++17 串起图片解码、图像预处理、vision encoder、LLM KV cache 解码、lm_head 和 tokenizer decode。
当前版本的目标是先提供一个可以复现、可以编译、可以端到端运行的 fp32 CPU 版本,并用公开图片做严格 token/text 回归。
当前交付能力:
spotting/document,支持自定义--promptRuntime 结构
运行时模型目录使用以下结构:
C++ 代码结构:
第三方代码只保留
stb_image.h负责 PNG/JPEG 解码,核心推理依赖 ncnn。验证结果
当前公开回归集包含 28 张图片,来源包括 HunyuanOCR upstream assets、HunyuanOCR README 示例图和 OmniDocBench 少量公开样本。图片来源记录在仓库的
examples/IMAGE_SOURCES.md。验证口径:
min_pixels=262144,max_pixels=524288do_sample=False1.03spotting,document, custom prompt28 张公开样本回归结果:
覆盖情况:
spotting样本document样本覆盖的 grid:
回归检查项包括:
Windows 侧也完成了两类验证:
示例
仓库内置 28 张公开示例图:
运行单张图:
运行全部示例图:
严格回归:
部分公开样本统计:
hf_demospotting38x52chinese_docspotting54x36en_bookdocument58x34formuladocument58x34tabledocument54x36hunyuan_vis_parsing_table_2document46x42hunyuan_translation2document40x48hunyuan_show_res_parsing_figdocument44x46完整列表见仓库:
examples/regression_cases.jsonexamples/EXPECTED_OUTPUTS.mdexamples/IMAGE_SOURCES.md示例效果
下面选了几类不同图片做展示。输出来自 ncnn runtime,展示时只做换行排版,不做内容截断;
spotting类保留坐标,便于核对检测结果。完整样本列表和来源见仓库中的examples/目录。字幕 / 双语文字
ncnn 输出:
中文文档页
ncnn 输出:
英文文档页
ncnn 输出:
网页 / UI 截图
ncnn 输出:
公式 / 论文页
ncnn 输出:
构建方式
使用已安装的 ncnn CMake package:
cmake -S . -B build -Dncnn_DIR=/path/to/ncnn/lib/cmake/ncnn cmake --build build -j或者直接指定本地 ncnn build tree:
cmake -S . -B build \ -DHUNYUAN_OCR_USE_NCNN_PACKAGE=OFF \ -DNCNN_INCLUDE_DIR=/path/to/ncnn/src \ -DNCNN_BUILD_INCLUDE_DIR=/path/to/ncnn/build/src \ -DNCNN_LIBRARY=/path/to/ncnn/build/src/libncnn.a cmake --build build -j打包 runtime 模型目录:
当前边界
当前版本聚焦 fp32 correctness 和跨平台可运行性:
max_pixels=524288是在这台机器上选择的稳定验证配置,不是模型结构上限。min_pixels/max_pixels,但需要重新生成 PyTorch reference、runtime 模型包和 regression fixtures。后续计划
下一步会继续补充:
参考链接
Beta Was this translation helpful? Give feedback.
All reactions