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

If you're not sure about the file name format, learn more about wheel file names.

pytorch_clip_interrogator-2023.2.19.6-py3-none-any.whl (788.9 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for pytorch_clip_interrogator-2023.2.19.6-py3-none-any.whl
Algorithm Hash digest
SHA256 c22a6faa9aa2de5d7c3a1f102205ac95006566a6ba2e3c20f5bb68b092582e69
MD5 d9f35b98ab066731b9d5cf95ab0c9b42
BLAKE2b-256 365362ac306aeed93ee33a6d79b8f23eb1a668d2d503d81a7a9ccca492911d63

See more details on using hashes here.

Supported by

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