Abril - Text-Image Comparison using CLIP
Abril is a Python library that makes it easy to compare text and images using OpenAI's CLIP model. It provides a simple interface for calculating similarity scores between text descriptions and images.
Installation
# First, install CLIP:
pip install git+https://github.com/openai/CLIP.git
# Then install abril:
pip install abril
Usage
from abril import ClipComparer
from PIL import Image
# Initialize the comparer
comparer = ClipComparer()
# Compare a single text with an image
score = comparer.compare_text_with_image(
"a photo of a dog",
"path/to/image.jpg"
)
print(f"Similarity score: {score}")
# Find the best matching text for an image
texts = [
"a photo of a dog",
"a photo of a cat",
"a photo of a car"
]
best_text, score = comparer.find_best_match(texts, "./image.jpg")
print(f"Best match: {best_text} (score: {score})")
Features
- Easy-to-use interface for text-image comparison
- Support for both single and multiple text comparisons
- Uses CLIP's ViT-B/32 model by default (can be changed)
- Automatically uses GPU if available for faster processing
- Handles both file paths and PIL Images flexibly
- Normalizes features for better comparison
- Returns scores between 0 and 1 for easy interpretation
- Built on OpenAI's CLIP model
- GPU acceleration when available
Requirements
- Python ≥ 3.7
- PyTorch ≥ 1.7.1
- Other dependencies are handled automatically during installation
License
MIT License - see LICENSE file for details.
Metadata
Release files for abril 0.1.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| abril-0.1.9.tar.gz | 4.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| abril-0.1.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.4 kB
Release files / abril-0.1.9.tar.gz
| Download URL | abril-0.1.9.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
db968148c5c81fd899a8dc701375ec58c0dfb60246b365b2f84f6b7641c0a522
|
|
BLAKE2b-256 checksum How to use checksums |
74ceaddaec25a2381442b422aba02f954bb149d979f9a431c4ea0570f5671660
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.10.13
|
Release files / abril-0.1.9-py3-none-any.whl
| Download URL | abril-0.1.9-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7f16eb1d8495c225248993ba04e74b80178e4f77d1ebdf4158b16bd84014856a
|
|
BLAKE2b-256 checksum How to use checksums |
37e0fb5dffa5b2fe9f0a9dd34f080e68490a7dad7fe6d288ba7f96584e3c067e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.10.13
|
Security for abril 0.1.9
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.