Image to prompt with BLIP and CLIP
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
pharmapsychotic 5aed16b011 Ability to swap CLIP models (takes about 5s for ViTL and 10s for ViTH), update Replicate cog 2 years ago
clip_interrogator Ability to swap CLIP models (takes about 5s for ViTL and 10s for ViTH), update Replicate cog 2 years ago
.gitignore Update notebook batch processing with option to rename files so can be used with [filewords] in Dreambooth! 2 years ago
LICENSE Initial commit 2 years ago
MANIFEST.in Add to pip! 2 years ago
README.md Update more stuff for open_clip switch 2 years ago
clip_interrogator.ipynb Update description with link to SD 2.0 announcement post 2 years ago
cog.yaml Ability to swap CLIP models (takes about 5s for ViTL and 10s for ViTH), update Replicate cog 2 years ago
predict.py Ability to swap CLIP models (takes about 5s for ViTL and 10s for ViTH), update Replicate cog 2 years ago
pyproject.toml Add to pip! 2 years ago
requirements.txt Update more stuff for open_clip switch 2 years ago
run_cli.py Update more stuff for open_clip switch 2 years ago
run_gradio.py Ability to swap CLIP models (takes about 5s for ViTL and 10s for ViTH), update Replicate cog 2 years ago
setup.py Update notebook batch processing with option to rename files so can be used with [filewords] in Dreambooth! 2 years ago

README.md

clip-interrogator

Want to figure out what a good prompt might be to create new images like an existing one? The CLIP Interrogator is here to get you answers!

Run it!

Run Version 2 on Colab, HuggingFace, and Replicate!

Open In Colab Generic badge Replicate


For Stable Diffusion 2.0 prompting use the ViT-H version:

Open In Colab Generic badge


Version 1 still available in Colab for comparing different CLIP models

Open In Colab

About

The CLIP Interrogator is a prompt engineering tool that combines OpenAI's CLIP and Salesforce's BLIP to optimize text prompts to match a given image. Use the resulting prompts with text-to-image models like Stable Diffusion on DreamStudio to create cool art!

Using as a library

Create and activate a Python virtual environment

python3 -m venv ci_env
source ci_env/bin/activate

Install with PIP

pip install -e git+https://github.com/pharmapsychotic/BLIP.git@lib#egg=blip
pip install clip-interrogator

You can then use it in your script

from PIL import Image
from clip_interrogator import Interrogator, Config
image = Image.open(image_path).convert('RGB')
ci = Interrogator(Config(clip_model_name="ViT-L-14/openai"))
print(ci.interrogate(image))

CLIP Interrogator uses OpenCLIP which supports many different pretrained CLIP models. For the best prompts for Stable Diffusion 1.X use ViT-L-14/openai for clip_model_name. For Stable Diffusion 2.0 use ViT-H-14/laion2b_s32b_b79k