Skip to main content

Prompt engineering tool using BLIP 1/2 + CLIP Interrogate approach.

Project description

pytorch_clip_interrogator: Image-To-Promt.

Downloads Downloads Downloads

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


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

File details

Details for the file pytorch_clip_interrogator-2023.2.19.17-py3-none-any.whl.

File metadata

File hashes

Hashes for pytorch_clip_interrogator-2023.2.19.17-py3-none-any.whl
Algorithm Hash digest
SHA256 f20d2e6a63fceb6adb6fc0e53c1f35f423ba31ad58cd0c9ef9b428f12b8396d7
MD5 c1054c3e2f8573b21ad9ab3225fa914c
BLAKE2b-256 e854aeb8f45119d3cbb39a96861697f552bb8b37a8b281ddb656e85647fca2f3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page