minerU2.5报错TypeError: Qwen2VLForConditionalGeneration.__init__() got an unexpected keyword argument 'dtype
Closed this issue · 10 comments
🔎 Search before asking | 提交之前请先搜索
- I have searched the MinerU Readme and found no similar bug report.
- I have searched the MinerU Issues and found no similar bug report.
- I have searched the MinerU Discussions and found no similar bug report.
🤖 Consult the online AI assistant for assistance | 在线 AI 助手咨询
- I have consulted the online AI assistant but was unable to obtain a solution to the issue.
Description of the bug | 错误描述
按照官网的步骤安装pip install "mineru-vl-utils[transformers]==0.1.10",运行minerU2.5,报错了
How to reproduce the bug | 如何复现
安装没问题
Operating System Mode | 操作系统类型
Linux
Operating System Version| 操作系统版本
Linux version 3.10.0-1160.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ) #1 SMP Mon Oct 19 16:
Python version | Python 版本
No response
Software version | 软件版本 (mineru --version)
No response
Device mode | 设备模式
No response
Hi @l878619717! I'm Dosu and I’m helping the MinerU team.
这个报错的根本原因是 transformers 版本和 MinerU 代码中的参数传递方式不兼容。MinerU 2.5 在加载 Qwen2VLForConditionalGeneration 时,会根据 transformers 版本动态选择传递 dtype 或 torch_dtype 参数。如果 transformers 版本低于 4.56.0,却传递了 dtype,就会出现你遇到的 TypeError(即你的 transformers 版本不支持 dtype 参数)代码出处。
解决办法:
-
检查 transformers 版本:
pip show transformers
如果版本低于 4.56.0,建议升级:
pip install 'transformers>=4.56.0,<5.0.0'(如有环境限制,确保 transformers 版本和 mineru-vl-utils 依赖兼容)
-
升级后重新运行 minerU2.5,问题应可解决。
如果你有特殊依赖或环境限制,建议贴出 pip freeze 结果,方便进一步定位依赖冲突。
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other
升级transformers 问题解决了,感谢,demo里面应该提前说明transformers 版本
另外输出extracted_blocks = client.two_step_extract(image),要自己组织,拼成最后的输出吗
不需要你手动组织或拼接 extracted_blocks,MinerU 已经提供了标准流程和工具函数来自动完成后续处理。
推荐做法是:先用 result_to_middle_json 把 extracted_blocks 转成结构化的 middle_json,然后再用 union_make 或类似工具把 middle_json 生成最终的 Markdown 或 JSON 输出。整个流程是模块化的,避免了重复劳动和出错。
简单示例(伪代码):
# 假设你已经拿到 extracted_blocks
middle_json = result_to_middle_json([extracted_blocks], images_list, pdf_doc, image_writer)
final_output = union_make(middle_json["pdf_info"], make_mode="MM_MD") # 生成 Markdown
# 或
final_output = union_make(middle_json["pdf_info"], make_mode="CONTENT_LIST") # 生成结构化 JSON这样你只需要调用这些工具函数,无需自己拼接 blocks。相关实现可以参考 MinerU 的 demo.py 和 vlm_middle_json_mkcontent.py 文件 代码参考。
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other
最好整理成一个文件,这样自己还要去整理,找代码
您是直接使用的utils,没有安装mineru是吗
您是直接使用的utils,没有安装mineru是吗
是的,就是安装了mineru,也要从里面找代码,组合起来
您是直接使用的utils,没有安装mineru是吗
是的,就是安装了mineru,也要从里面找代码,组合起来
我比较在意的是,通过mineru使用就不会出现transformers版本的问题,标题出现的问题,您的使用方法是?能show一下您当时的代码吗?
您是直接使用的utils,没有安装mineru是吗
是的,就是安装了mineru,也要从里面找代码,组合起来
我比较在意的是,通过mineru使用就不会出现transformers版本的问题,标题出现的问题,您的使用方法是?能show一下您当时的代码吗?
按照这里的代码跑的。有能直接运行代码,加载模型,跑出markdown的代码的吗?这样对新手更友好
https://modelscope.cn/models/opendatalab/MinerU2.5-2509-1.2B