自分用の覚え書きです。
ローカルに保存した写真を Google フォトのようなキーワードで検索できたらいいねってことで、ollama を使う。
インストールは次のコマンドを実行する。
sudo su -
curl -fsSL https://ollama.com/install.sh | sh
出力は次のようになる。インストールが楽チンで便利。
# curl -fsSL https://ollama.com/install.sh | sh
>>> Cleaning up old version at /usr/local/lib/ollama
>>> Installing ollama to /usr/local
>>> Downloading Linux amd64 bundle
######################################################################## 100.0%
>>> Adding ollama user to render group...
>>> Adding ollama user to video group...
>>> Adding current user to ollama group...
>>> Creating ollama systemd service...
>>> Enabling and starting ollama service...
>>> NVIDIA GPU installed.
#
実行時に使用するモデルを指定する。今回は llama3.2-vision を指定した。初めて使うモデルは初回実行時にダウンロード(数百MB〜数GB)されるため、実行に少し時間がかかる。llama3.2-vision のほか、より高速で小さい llava というモデルも使えた。
$ ollama run llama3.2-vision
pulling manifest
pulling 9999d473417a: 100% ▕██████████████████████████████████████████████████████████████████▏ 7.8 GB
pulling 715415638c9c: 100% ▕██████████████████████████████████████████████████████████████████▏ 269 B
pulling d3ed60b91757: 100% ▕██████████████████████████████████████████████████████████████████▏ 6.0 KB
pulling fcc5a6bec9da: 100% ▕██████████████████████████████████████████████████████████████████▏ 7.7 KB
pulling fefc914e46e6: 100% ▕██████████████████████████████████████████████████████████████████▏ 32 B
pulling 1506fb8a7284: 100% ▕██████████████████████████████████████████████████████████████████▏ 564 B
verifying sha256 digest
writing manifest
success
>>>
プロンプトが表示されれば利用可能。次のテスト用の画像ファイルを test.jpg として準備しておく。

プロンプトに質問してみる。
>>> what is this ./test.jpg
しばらくすると、答えが返ってくる。
>>> what is this ./test.jpg
Added image './test.jpg'
This is a portable pop-up tent that can be set up quickly and easily. It
is designed to provide shade and shelter from the sun, wind, and rain, and
can be used for various outdoor activities such as camping, hiking, or
picnicking. The tent is typically made of lightweight and durable
materials, such as nylon or polyester, and can be easily packed away and
transported when not in use.
ポップアップテントを認識して、それについての説明をしてくれた。
質問を変える。「見えているもの全てを説明して」
>>> Please describe everything you see in this ./test.jpg
Added image './test.jpg'
The image shows a white pop-up tent on a sandy beach, with a body of water in the
background and a hill covered with trees in the distance. The tent is made of a
lightweight material and has a simple, compact design. It is set up on the sand, with
its entrance facing towards the water. The tent has a small window on one side and a
door on the other, which is open to allow people to enter and exit. The tent is
surrounded by a few people, who are sitting or standing nearby, enjoying the sun and
the view. In the background, there is a body of water, possibly a lake or a river,
with a few boats or ships visible on the horizon. The water is calm and peaceful,
reflecting the sky above. On the other side of the water, there is a hill covered
with trees, which adds to the natural beauty of the scene. The overall atmosphere of
the image is one of relaxation and tranquility, with the warm sun, the sound of the
waves, and the peaceful surroundings creating a sense of calm and serenity.
「この写真に相応しいタグ(キーワード)をいくつかリストアップしてJSONの配列で印字してください。」
>>> Please list some tags (keywords) that are appropriate for this photo and print them as
... a JSON array.
Here is a JSON array of tags that are appropriate for this photo:
[ "beach", "tent", "water", "hill", "trees", "relaxation", "tranquility", "peaceful",
"serene", "natural", "scenic", "outdoor", "summer", "vacation", "recreation",
"leisure", "sun", "waterfront", "coastal", "ocean", "waves", "seagulls",
"watercraft", "waterway", "waterfront", "waterfront property", "waterfront living",
"waterfront living", "waterfront living", "waterfront living", "waterfront living",
"waterfront living", "waterfront living", "waterfront living", "waterfront living",
"waterfront living", "waterfront living", "waterfront living", "waterfront living",
"waterfront living", "waterfront living", "waterfront living", "waterfront living",
"waterfront living", "waterfront living", "waterfront living", "waterfront living",
"waterfront living", "waterfront living", "waterfront living", "waterfront living",
"waterfront living", "waterfront living", "waterfront living", "waterfront living",
"waterfront living", "waterfront living", "waterfront living", "waterfront living",
"waterfront living", "waterfront living", "waterfront living", "waterfront living",
"waterfront living", "waterfront living", "waterfront living", "waterfront living",
"water^C
>>> Send a message (/? for help)
途中までは良かったが、”waterfront living” が延々と出力されるようになった。安定的な出力をしてもらえるプロンプトの設計が必要。
gemini とペアプロしてもらったが、なかなか癖があるみたい。(モデルによっても癖が違うみたい)