SmolVLM 是一个本地图像分析技能,基于 SmolVLM-2B-Instruct 这一紧凑型视觉语言模型,针对 Apple Silicon 通过 mlx-vlm 进行优化,所有图像分析在本地完成。
【用途】 用于对本地图片进行视觉语言理解,包括图像描述、文字提取、界面分析、视觉问答和代码截图识别等任务。无需将图片上传到云端。
【主要能力】
- 描述图像:生成图像的基本或详细描述。
- 文字提取(OCR):提取图片中可见的文字内容。
- UI/截图分析:描述界面元素、识别按钮和控件、判断应用及其当前状态。
- 视觉问答:回答关于图像中物体数量、颜色、是否存在某物体等问题。
- 代码/技术类:识别代码截图中使用的编程语言、描述代码作用、识别代码中的错误。
【模型规格】
- 模型:SmolVLM-2B-Instruct
- 大小:约 4GB
- 峰值内存:5.8GB
- 速度:约 94 tok/s(M 系列芯片)
- 支持格式:PNG、JPG、JPEG、GIF、WebP
【使用方式】 描述图像: python ~/.claude/skills/smolvlm/scripts/view_image.py /path/to/image.png
针对图像提问: python ~/.claude/skills/smolvlm/scripts/view_image.py /path/to/image.png "What text is visible?"
提取文字(OCR): python ~/.claude/skills/smolvlm/scripts/view_image.py screenshot.png "Extract all text"
UI 分析: python ~/.claude/skills/smolvlm/scripts/view_image.py ui.png "Describe the UI elements"
详细描述: python ~/.claude/skills/smolvlm/scripts/view_image.py photo.jpg --detailed
【有效提示词示例】
- 通用描述:"Describe this image";"Describe this image in detail, including colors, composition, and any text"
- 文字提取(OCR):"Extract all visible text from this image";"What text appears in this screenshot?";"Read the text in this document"
- UI/截图分析:"Describe the user interface elements";"What buttons and controls are visible?";"Identify the application and its current state"
- 视觉问答:"How many [objects] are in this image?";"What color is the [object]?";"Is there a [object] in this image?"
- 代码/技术:"What programming language is shown?";"Describe what this code does";"Identify any errors in this code screenshot"
【环境要求】
- macOS 搭配 Apple Silicon(M1/M2/M3)
- Python 3.10+
- mlx-vlm 包:uv pip install mlx-vlm --system
【限制与故障排查】
- 需要 macOS 与 Apple Silicon,其他平台暂未提供支持说明。
- "Model not found":首次运行会下载模型(约 4GB),需等待完成。
- 内存不足:需要约 6GB 可用内存,可关闭其他应用。
- 首次推理较慢:模型加载在首次使用时需 10-15 秒,后续调用更快。