Skip to main content

Generate alt-text for images from a local or remote Ollama server running LLM vision models.

Project description

gen-alt-text

  • This program generates alt-text for images using a local or remote Ollama server.
  • The Ollama server must be running before using this program.
  • See Ollama for installation and usage instructions.

Installation

pipx install gen-alt-text

Usage

gen-alt-text -m "llama3.2-vision:11b" ~/pictures/autumn-scenery.jpg
gen-alt-text ~/pictures/winter-scenery.jpg
gen-alt-text -m "llama3.2-vision:90b" ~/pictures/coffee.jpg

If the model supplied to the -m argument is not currently available on the Ollama server, gen-alt-text will pull it for you, and then you must re-run the program to use it.

Remote Ollama server

For remote Ollama servers, the server must be configured to listen on 0.0.0.0:11434 and port 11434 must be open in the firewall. Edit the systemd service file as follows:

sudo systemctl edit ollama.service

Add the following:

[Service]
Environment="OLLAMA_HOST=0.0.0.0:11434"

Save the file and exit the editor.

I personally use a remote server that is not public-facing and is only accessible through my Tailscale network, or tailnet.

On the local machine that you're running this program on, set the OLLAMA_HOST environment variable to use a remote Ollama server.

export OLLAMA_HOST="http://ollama.tailnet.ts.net:11434"
gen-alt-text ~/pictures/goth_hacker_girl.jpg

Local Ollama server

The ollama.service systemd unit should already be configured to listen on localhost:11434 by default, so no additional configuration is necessary.

Example

I fed the image below to the llama3.2-vision:11b model.

fall-leaves-cover-photo.jpg

This was the alt-text it generated:

The image depicts a serene autumnal scene, with a cup of coffee placed on a stone surface amidst fallen leaves. In the foreground, a dark brown ceramic mug filled with black coffee sits atop a large, flat gray stone. The mug's handle is positioned towards the right side of the image. Surrounding the mug are vibrant red and orange fallen leaves, which have accumulated in a pile to the left of the stone. Some of these leaves appear to be scattered across the surface of the stone as well. The background of the image features more fallen leaves, creating a sense of depth and atmosphere. The overall mood of the scene is one of tranquility and coziness, evoking feelings of relaxation and comfort.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gen_alt_text-0.1.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gen_alt_text-0.1-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file gen_alt_text-0.1.tar.gz.

File metadata

  • Download URL: gen_alt_text-0.1.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.0

File hashes

Hashes for gen_alt_text-0.1.tar.gz
Algorithm Hash digest
SHA256 99c1ef737a9395f95f5f79b7a9561442018c052dc5cd123311633679119ee099
MD5 4a481cf02b5303dcd7848f16e815a8a5
BLAKE2b-256 f44d1bbbc02300ecdf60fd2f9611ce42ee959b684e81bce5acefa8828f3c8fc9

See more details on using hashes here.

File details

Details for the file gen_alt_text-0.1-py3-none-any.whl.

File metadata

  • Download URL: gen_alt_text-0.1-py3-none-any.whl
  • Upload date:
  • Size: 15.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.0

File hashes

Hashes for gen_alt_text-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7507badb3f745df0c2fae44663b1b99b5a77a1f40cf95caf066bfc8ad75691c2
MD5 5a314281b0c07b9c43448a6d8a9708c4
BLAKE2b-256 3ea96861104b489290f8d9715e6ca60b8e9df38024894bd86f6b3b1bb4878acc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page