Skip to main content

blip-caption

PyPI Changelog Tests License

A CLI tool for generating captions for images using Salesforce BLIP.

Installation

Install this tool using pip or pipx:

pipx install blip-caption

The first time you use the tool it will download the model from the Hugging Face model hub.

The small model is 945MB. The large model is 1.8GB. The models will be downloaded and stored in ~/.cache/huggingface/hub/ the first time you use them.

Usage

To generate captions for an image using the small model, run:

blip-caption IMG_5825.jpeg

Example output:

a lizard is sitting on a branch in the woods

To use the larger model, add --large:

blip-caption IMG_5825.jpeg --large

Example output:

there is a chamelon sitting on a branch in the woods

Here's the image I used:

It is ineded a chameleon

If you pass multiple files the path to each file will be output before its caption:

blip-caption /tmp/photos/*.jpeg
/tmp/photos/IMG_2146.jpeg
a man holding a bowl of salad and laughing
/tmp/photos/IMG_0151.jpeg
a cat laying on a red blanket

JSON output

The --json flag changes the output to look like this:

blip-caption /tmp/photos/*.* --json
[{"path": "/tmp/photos/IMG_2146.jpeg", "caption": "a man holding a bowl of salad and laughing"},,
 {"path": "/tmp/photos/IMG_0151.jpeg", "caption": "a cat laying on a red blanket"},
 {"path": "/tmp/photos/IMG_3099.MOV", "error": "cannot identify image file '/tmp/photos/IMG_3099.MOV'"}]

Any errors are returned as a {"path": "...", "error": "error message"} object.

Development

To set up this plugin locally, first checkout the code. Then create a new virtual environment:

cd blip-caption
python3 -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

pytest

Metadata

Release files for blip-caption 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for blip-caption 0.1
File Size Uploaded Provenance Actions
blip-caption-0.1.tar.gz 3.8 kB Without provenance Details for blip-caption-0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for blip-caption 0.1
File Interpreter ABI Platform Actions
blip_caption-0.1-py3-none-any.whl Python 3 none any Details for blip_caption-0.1-py3-none-any.whl

Total release size: 7.1 kB

Release files / blip-caption-0.1.tar.gz

Download URL blip-caption-0.1.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3c63350b0b595bcbe14cd879e0f1ca9ef38ba85d75ef903a9808275f6494248a
BLAKE2b-256 checksum
How to use checksums
398d29fd9679683a1e974effa8db0fbe85798aaa88bb82cedfc4f387fc2f5aad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Release files / blip_caption-0.1-py3-none-any.whl

Download URL blip_caption-0.1-py3-none-any.whl
Size 3.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7a45a04d1ea01ef636871ffe078f0d3102c7a689fedefdc72329d4bba8e183d1
BLAKE2b-256 checksum
How to use checksums
22a6ebf7a0b8022fe1b1fa40176498e16cd4c652521c7c199135e4638b9eff87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Security for blip-caption 0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page