A library for comparing text and images using CLIP
Project description
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
# Método recomendado de instalación:
pip install abril[all]
# Si encuentras problemas, puedes instalar las dependencias manualmente:
pip install torch>=1.7.1 pillow>=7.1.2 numpy>=1.18.5
pip install git+https://github.com/openai/CLIP.git@v0.1.3
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, "path/to/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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
abril-0.1.6.tar.gz
(4.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
abril-0.1.6-py3-none-any.whl
(4.9 kB
view details)
File details
Details for the file abril-0.1.6.tar.gz.
File metadata
- Download URL: abril-0.1.6.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c28999e6b926612a1a0157bfdd18ee27dbd69762dd65ae6fc7b8b6efe3d43e6c
|
|
| MD5 |
c7ef3f2d4a838d2c5e987f30d889b531
|
|
| BLAKE2b-256 |
53aad751492aee3abec0c162aecb788cc6e45db2984e1ed2d27612b7b542fc09
|
File details
Details for the file abril-0.1.6-py3-none-any.whl.
File metadata
- Download URL: abril-0.1.6-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a79a9b0c18e5eef3a1da626b7674101473e9b2bf0120755959d89f8efa09379
|
|
| MD5 |
1d6b9cf1b5f731c85f9981eabdced66f
|
|
| BLAKE2b-256 |
e2ddd018c9daf6b28f4794587998ad042d884297f3ad29f55195576269d98df2
|