【免费下载链接】Mini-InternVL2-1B-DA-BDD项目地址https://ai.gitcode.com/OpenGVLab/Mini-InternVL2-1B-DA-BDD点击查看免费下载Mini-InternVL2-1B-DA-BDD 是一个开箱即用的「看图说话」多模态大模型基于 Mini-InternVL 的 1B 小体量底座用 BDD100K 自动驾驶场景数据做域适配微调既能描述单张图片也支持围绕同一张图多轮追问还能一次喂入多张图做对比。本文用尽量少的代码带你跑通单图、多轮、多图三类最常用的看图说话玩法。 先搞懂这个模型能做什么模型定位1B 参数级的视觉-语言Vision-Language模型由视觉编码器 Qwen2-0.5B 语言模型组成消费级显卡即可部署。DA-BDD 的含义在通用底座上用 BDD100K伯克利驾驶数据集配合 DriveGPT4 构建的指令数据做了域适配微调因此对道路、车辆、交通场景的图片描述更在行同时保留通用看图能力。动态分辨率图片会被自动切成最多 12 个 448×448 的瓦片再加一张缩略图细节多的图看得更清对应 config.json 中的max_dynamic_patch: 12与use_thumbnail: true。 一句话记忆它 1B 小模型 动态切片看图 自动驾驶场景增强。 仓库文件速览文件作用model.safetensors模型权重config.json模型结构配置图像尺寸 448、动态瓦片上限 12、Hermes-2 对话模板等modeling_internvl_chat.pychat/batch_chat等对话核心逻辑modeling_intern_vit.py视觉编码器InternViT实现conversation.py对话 prompt 模板tokenizer.json、vocab.json分词器词表README.md官方 Quick Start 完整示例代码 环境准备三步装好依赖1️⃣ 下载模型仓库本地运行需要仓库里的自定义模型代码git clone https://gitcode.com/OpenGVLab/Mini-InternVL2-1B-DA-BDD2️⃣ 安装 Python 依赖版本要求很关键pip install transformers4.37.2 torch torchvision pillow decord3️⃣ 验证能import transformers且版本 ≥ 4.37.2 即可modeling_internvl_chat.py 中内置了版本断言过低会直接报错。⚡ 加载模型4 行代码跑起来from transformers import AutoModel, AutoTokenizer path OpenGVLab/Mini-InternVL2-1B-DA-BDD # 也可换成 clone 后的本地路径 model AutoModel.from_pretrained( path, torch_dtypetorch.bfloat16, trust_remote_codeTrue).eval().cuda() tokenizer AutoTokenizer.from_pretrained(path, trust_remote_codeTrue, use_fastFalse)两个新手必踩的点trust_remote_codeTrue该模型带自定义加载代码不加会加载失败torch.bfloat16模型默认以 bfloat16 精度存储见 config.json 的torch_dtype加载时必须一致。️ 场景一单图单轮对话——最基础的看图描述核心思路只有两条用image占位符在问题里标记这里有一张图用load_image把图片做动态切片得到pixel_values喂给模型。load_image是官方 Quick Start 里给出的工具函数可直接从 README.md 复制它会自动按图片宽高比切瓦片并补缩略图。generation_config dict(max_new_tokens1024, do_sampleTrue) pixel_values load_image(car.jpg, max_num12).to(torch.bfloat16).cuda() question image\nPlease describe the image shortly. response model.chat(tokenizer, pixel_values, question, generation_config) print(response)运行后模型会输出一段对图片的简短描述。 由于 DA-BDD 在驾驶场景上强化过给它一张街景或车内摄像头照片它对车辆、行人、道路的描述通常更细致。️ 场景二单图多轮对话——如何追问同一张图多轮的关键是history第一轮加return_historyTrue拿到历史之后每轮把它传回去即可pixel_values可以一直复用不必重复加载图片。# 第一轮详细描述 response, history model.chat( tokenizer, pixel_values, image\nPlease describe the image in detail., generation_config, historyNone, return_historyTrue) # 第二轮基于同一张图追问模型记得上一轮说了什么 response, history model.chat( tokenizer, pixel_values, Please write a poem according to the image., generation_config, historyhistory, return_historyTrue)history内部就是「(问题, 回答) 对」的列表在 modeling_internvl_chat.py 中逐轮回放进对话模板实现上下文记忆。想清空记忆传historyNone重新开始即可。 场景三多图对话——拼接与独立两种玩法多图时先把各张图的pixel_values用torch.cat拼在一起区别在于怎么告诉模型边界在哪玩法 A拼接图像一个image代表整段适合让模型整体感知实现最简单pv1 load_image(image1.jpg, max_num12).to(torch.bfloat16).cuda() pv2 load_image(image2.jpg, max_num12).to(torch.bfloat16).cuda() pixel_values torch.cat((pv1, pv2), dim0) response model.chat( tokenizer, pixel_values, image\nDescribe the two images in detail., generation_config)玩法 B独立图像每个image对应一张图需要在问题里写多个image并传num_patches_list标明每张图各占多少瓦片——因为不同图的切片数可能不同模型要靠它定位每张图的 token 范围见 chat 实现num_patches_list [pv1.size(0), pv2.size(0)] response, history model.chat( tokenizer, pixel_values, Image-1: image\nImage-2: image\nDescribe the two images in detail., generation_config, num_patches_listnum_patches_list, return_historyTrue) # 第二轮对比两张图的异同继续传 num_patches_list response, history model.chat( tokenizer, pixel_values, What are the similarities and differences between these two images., generation_config, num_patches_listnum_patches_list, historyhistory, return_historyTrue) 推荐用法把两张同一路线不同时段的路况照片丢进去问两张图的异同DA-BDD 对这类驾驶场景对比非常拿手。 进阶单图批处理批量推理要一次性处理多张图 多个问题用 batch_chatquestions [image\nDescribe the image in detail.] * len(num_patches_list) responses model.batch_chat( tokenizer, pixel_values, num_patches_listnum_patches_list, questionsquestions, generation_configgeneration_config)⚠️ 注意batch_chat目前不支持多轮对话源码中遇到history会直接抛出NotImplementedError见 modeling_internvl_chat.py批量场景都是单轮问答。 关键参数速查表参数作用新手建议max_num图片最多切片的瓦片数1~12显存够就 12紧张就降到 6 或 4max_new_tokens单轮回复的最大生成长度简短描述 256 足够详细描述 1024do_sample是否采样生成True回答更自然多样history多轮对话上下文第一轮传None之后回传上一轮返回值num_patches_list多图/批量时每张图的瓦片数独立多图与 batch_chat 必传max_new_tokens之外的generation_config如do_sampleTrue官方示例组合dict(max_new_tokens1024, do_sampleTrue)❓ 常见问题排查清单报错提示 transformers 版本过低升级即可pip install -U transformers4.37.2。加载时报错、提示缺少自定义模块检查是否传了trust_remote_codeTrue用本地路径加载时clone 的目录名保持原名。CUDA OOM 显存不足优先调小max_num如 12 → 6其次调小max_new_tokens1B 模型本身显存需求不高通常能解决。为什么回答特别懂开车这就是 DA-BDD 的域适配效果——它用 BDD100K 数据微调过驾驶场景更强但通用图片图表、文档、自然图照样能描述。纯 CPU 能跑吗可以去掉.cuda()和torch.bfloat16即可只是速度会明显变慢日常使用建议 GPU。✅ 小结一张表回顾三种用法场景调用方式关键点单图单轮model.chat(..., question 含 image)load_image动态切片单图多轮每轮回传historyreturn_historyTrue多图对话torch.cat拼接像素独立图像须传num_patches_list批量推理model.batch_chat(...)仅单轮多图多问整套示例代码都可以直接参考 README.md 的 Quick Start 部分。掌握以上四种姿势Mini-InternVL2-1B-DA-BDD 就能作为你项目里的看图说话核心组件快速搭出图片描述、驾驶场景问答、多图对比等应用。赞分享【免费下载链接】Mini-InternVL2-1B-DA-BDD项目地址https://ai.gitcode.com/OpenGVLab/Mini-InternVL2-1B-DA-BDD点击查看免费下载相关推荐ticket-purchase大麦自动抢票 5 分钟上手的 Web移动端完整指南ticket purchase大麦自动抢票 5 分钟上手的 Web移动端完整指南 ticket purchase 是一个 Python 大麦自动抢票工具网Mini-InternVL2-1B-DA-BDD动态分辨率详解dynamic_preprocess如何在不浪费参数下保留图像细节Mini InternVL2 1B DA BDD动态分辨率详解dynamic_preprocess如何在不浪费参数下保留图像细节 Mini InternVL2Mini-InternVL2-1B-DA-BDD项目全解析1B口袋级多模态模型如何实现90%性能的领域自适应Mini InternVL2 1B DA BDD项目全解析1B口袋级多模态模型如何实现90%性能的领域自适应 Mini InternVL2 1B DA BDD上一篇终极3DS游戏格式转换指南如何快速将3DS游戏转换为CIA安装包下一篇Grafana Mimir 依赖解析OpenTelemetry Go Logs SDK 实验特性与 SDK 自观测机制解读创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考