Ollama 运行视觉语言模型LLaVA

Ollama的LLaVA(大型语言和视觉助手)模型集已更新至 1.6 版,支持:

  • 更高的图像分辨率:支持高达 4 倍的像素,使模型能够掌握更多细节。
  • 改进的文本识别和推理能力:在附加文档、图表和图表数据集上进行训练。
  • 更宽松的许可证:通过 Apache 2.0 许可证或 LLaMA 2 社区许可证分发。

这些模型有三种参数大小。7B、13B 和新的 34B 模型:

  • ollama run llava:7b
  • ollama run llava:13b
  • ollama run llava:34b

NSDT工具推荐Three.js AI纹理开发包 - YOLO合成数据生成器 - GLTF/GLB在线编辑 - 3D模型格式在线转换 - 可编程3D场景编辑器 - REVIT导出3D模型插件 - 3D模型语义搜索引擎 - AI模型在线查看 - Three.js虚拟轴心开发包 - 3D模型在线减面 - STL模型在线切割

1、Ollama视觉模型使用方法

命令行使用方法:

要将视觉模型与 ollama run 结合使用,请使用文件路径引用 .jpg 或 .png 文件,例如上图:

复制代码
% ollama run llava "describe this image: ./art.jpg"
The image shows a colorful poster featuring an illustration of a cartoon character with spiky hair. Above the character's head is a crown, suggesting royalty or high status. On the right side of the poster, there is text in French that reads "Jean-Michel Basquiat,"

在Python代码中调用方法如下:

复制代码
import ollama

res = ollama.chat(
	model="llava",
	messages=[
		{
			'role': 'user',
			'content': 'Describe this image:',
			'images': ['./art.jpg']
		}
	]
)

print(res['message']['content'])

在JavaScript中的调用方法如下所示:

复制代码
import ollama from 'ollama'

const res = await ollama.chat({
	model: 'llava',
	messages: [{
		role: 'user',
		content: 'Describe this image:'
		images: ['./art.jpg']
	}]
})

console.log(res.message.content)

注意:在 Ollama PythonJavaScript库以及 REST API 中,可以在 images 参数中提供 base64 编码的文件。有关向视觉模型提供图像的更多示例,请参阅完整的 API 文档

2、应用示例

对象检测:

复制代码
% ollama run llava "tell me what do you see in this picture? ./pic.jpg"
In the image, a man wearing blue and white is holding video game controllers in his hands while smiling. His arms are raised above his head as he plays with the virtual reality gaming devices. The man appears to be enjoying himself and immersed in his gaming experience.

文字识别:

复制代码
% ollama run llava "what does the text say? ./wordart.png"
This is an image with a capitalized, bolded text of "ollama." The background is black and the letters are yellow, which create a contrasting appearance. Although the words "ollama" make up the majority of the image, it could also be seen as part of a sign or advertisement due to its brightness and prominent font style.

原文链接:Ollama 运行视觉模型 - BimAnt

相关推荐
极智-9961 分钟前
GitHub 热榜项目-日榜精选(2026-02-03)| AI智能体、终端工具、RAG技术等 | claude-mem、99、termux-app等
人工智能·网络安全·github·ai智能体·llm应用·rag技术·torrent工具
跨境卫士苏苏5 分钟前
跨境电商:从“跑量”到“跑赢利润”的一套打法
大数据·人工智能·跨境电商·亚马逊·内容营销
maoku667 分钟前
LLaMA Factory全解析:让大模型“改装”像组装电脑一样简单
人工智能
袋鼠云数栈10 分钟前
让多模态数据真正可用,AI 才能走出 Demo
大数据·人工智能·数据治理·多模态
esmap11 分钟前
技术深度解析:ESMap引擎VS主流数字孪生竞品
人工智能·物联网·3d·编辑器·智慧城市·webgl
鹧鸪云光伏11 分钟前
光伏清洗-AI算法助你找到积尘位置
人工智能·光伏
星河耀银海31 分钟前
AI学习第一站:从感知到认知,AI到底是什么?
人工智能·学习·ai
小鸡吃米…33 分钟前
机器学习 - 堆叠集成(Stacking)
人工智能·python·机器学习
Faker66363aaa38 分钟前
YOLO11改进蚊虫目标检测模型,AttheHead注意力机制提升检测精度
人工智能·目标检测·计算机视觉
郝学胜-神的一滴38 分钟前
基于30年教学沉淀的清华大学AI通识经典:《人工智能的底层逻辑》
人工智能·程序人生·机器学习·scikit-learn·sklearn