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.2.tar.gz (15.3 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.2-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gen_alt_text-0.2.tar.gz
  • Upload date:
  • Size: 15.3 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.2.tar.gz
Algorithm Hash digest
SHA256 103dd75c9a868310ab3ca41483a799bf149dc23caf85d2a06018c3f1047c129d
MD5 9f955c3e4ebee18b44f5114830930f47
BLAKE2b-256 70163c84ee76f91645349de866ef574122ebe88a16b0b34ad790e2bbc8258a82

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gen_alt_text-0.2-py3-none-any.whl
  • Upload date:
  • Size: 16.0 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b18e4cecbf2bc7335d06359daef9865c3db3cdf2e1612fdc4dbeaee0fc61527e
MD5 acf2e176cbeb254eaef0142124018264
BLAKE2b-256 c38d17222c8ecbb849c2bfb466d0f192bca0521f93046ad1beaa0d4596f230b2

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