😸

【ollama / LLaVA】Jetson AGXでLLaVAを動かし、画像を解説してもらう

2024/05/07に公開

やること

Jetson AGXでLLaVAを動かし、画像を解説してもらうまでの手順を紹介します。

前提

  • Jetson AGX Orin Developper Kit 32GB
  • JetPack5.1.2

LLavaとは?

一般的な視覚と言語の理解のために設計された新しいエンドツーエンドで訓練された大規模なマルチモーダルモデルです。
https://llava-vl.github.io/

参考資料

https://ollama.com/download/linux

https://ollama.com/blog/vision-models

Ollama Download 手順

  1. Terminalを立ち上げる
  2. 以下のコマンドを実行し、LLavaをinsatll
curl -fsSL https://ollama.com/install.sh | sh

LLavaをTerminalで動かす

  1. Desktopに画像(test.jpeg)を置く
    ※今回は弊社のロゴを使う
  2. 以下のコマンドを実行
cd Desktop
ollama run llava "describe this image: ./test.jpeg"
  1. 以下が出力される
Added image './test.jpeg'
 The image features a logo with a stylized graphic and text. At the center
of the design is a circular graphic resembling a compass rose, with a 
white "N" in the middle. Surrounding this central image are three 
concentric circles: the innermost circle appears to have a blue-green 
gradient, the second one is white, and the outermost ring is darker blue.

On top of the circles, there's text that reads "HEADWATTERS". Below the 
circles, another piece of text in a smaller font size states "MARINA 
CENTRAL". The overall design suggests it could be associated with marine 
or waterside services or property. 

LLavaをPythonで動かす

  1. 以下を実行し、ライブラリーをinstall
pip install ollama
  1. Desktop上に以下の内容を反映したpythonファイルを置く
import ollama

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

print(res['message']['content'])
  1. 2で作成したPythonファイルを実行
  2. 以下が出力される
The image is a logo featuring a stylized graphic that resembles the profile of a person's head, with one side being blue and the other side being white. Inside this circular shape, there is an icon representing a globe, which suggests a global aspect to the company or product. Above the graphic, there is text that reads "HEADWATTERS." The logo has a clean and modern design, using a minimalist approach with the use of only two colors and simple shapes.

ちなみに

Jetson Orin Nano Developer Kit 8GBでも同様に動かしてみました。
画像の解説まで5分ほど時間が掛かりましたが、一応動きました。。

ヘッドウォータース

Discussion