Prompt engineering tool using BLIP 1/2 + CLIP Interrogate approach.
Project description
pytorch_clip_interrogator: Image-To-Promt.
Install package
pip install pytorch_clip_interrogator
Install the latest version
pip install --upgrade git+https://github.com/bes-dev/pytorch_clip_interrogator.git
Features
- Fully compatible with models from Huggingface.
- Supports BLIP 1/2 model.
- Support batch processing.
Usage
Simple code
import torch
import requests
from PIL import Image
from pytorch_clip_interrogator import PromptEngineer
# build pipeline
pipe = PromptEngineer(
blip_model="Salesforce/blip2-opt-2.7b",
clip_model="openai/clip-vit-base-patch32",
device="cuda",
torch_dtype=torch.float16
)
# load image
img_url = 'https://storage.googleapis.com/sfr-vision-language-research/BLIP/demo.jpg'
image = Image.open(requests.get(img_url, stream=True).raw).convert('RGB')
# generate caption
print(pipe(image))
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for pytorch_clip_interrogator-2023.2.19.16-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f94c2b5258ef9fb7a05e89e096dfed48499046ec2fcd300c10452ccddb5e1252 |
|
MD5 | 9cd023a4dbc2ae0a1d787d4c2c34f3af |
|
BLAKE2b-256 | 2e19c77046c8c74f225ca2e9b6ae138d51ed9fa294cef21a0175503d0578de26 |