{"id":6566,"library":"clip-interrogator","title":"CLIP Interrogator","description":"CLIP Interrogator is a Python library that generates text prompts from images, leveraging large language and vision models like CLIP and BLIP. It's particularly useful for generating prompts for text-to-image AI models. The current version is 0.6.0, and it has an active but infrequent release cadence, with major updates addressing model support and performance optimizations.","status":"active","version":"0.6.0","language":"en","source_language":"en","source_url":"https://github.com/pharmapsychotic/clip-interrogator","tags":["image-to-text","ai-art","prompt-engineering","vision-language-models","clip","blip"],"install":[{"cmd":"pip install clip-interrogator","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"Config","correct":"from clip_interrogator import Config"},{"symbol":"Interrogator","correct":"from clip_interrogator import Interrogator"},{"note":"Added in v0.6.0 for custom term ranking","symbol":"LabelTable","correct":"from clip_interrogator import LabelTable"},{"note":"Added in v0.6.0","symbol":"list_caption_models","correct":"from clip_interrogator import list_caption_models"},{"note":"Added in v0.6.0","symbol":"list_clip_models","correct":"from clip_interrogator import list_clip_models"}],"quickstart":{"code":"import os\nfrom PIL import Image\nfrom clip_interrogator import Config, Interrogator\n\n# Create a dummy image for the example to be runnable\ndummy_image_path = \"dummy_image_for_ci.jpg\"\ntry:\n    Image.new('RGB', (224, 224), color = 'red').save(dummy_image_path)\nexcept ImportError:\n    # Fallback if Pillow is not available for some reason (unlikely for this lib)\n    with open(dummy_image_path, 'w') as f:\n        f.write(\"dummy content\")\n\n# Configure CLIP Interrogator\nci_config = Config()\n# Set model names (these will be downloaded on first run and cached)\nci_config.clip_model_name = \"ViT-L-14/openai\"\nci_config.caption_model_name = \"blip-large\" # Other options: blip-base, blip2-2.7b, blip2-flan-t5-xl, git-large-coco\n\n# Apply low VRAM settings if available (recommended for GPUs with <12GB VRAM)\n# This method was introduced in v0.5.4\nif hasattr(ci_config, 'apply_low_vram_defaults'):\n    ci_config.apply_low_vram_defaults()\n\n# Initialize the Interrogator. This will download models if not already cached.\nprint(\"Initializing CLIP Interrogator (models may download on first run)...\")\ntry:\n    ci = Interrogator(ci_config)\n    print(\"CLIP Interrogator initialized.\")\n\n    # Load an image\n    image = Image.open(dummy_image_path).convert(\"RGB\")\n\n    # Perform interrogation\n    prompt = ci.interrogate(image)\n    print(f\"Generated prompt: {prompt}\")\nexcept Exception as e:\n    print(f\"Error during interrogation: {e}. Please ensure sufficient VRAM and disk space for models.\")\nfinally:\n    # Clean up the dummy image\n    if os.path.exists(dummy_image_path):\n        os.remove(dummy_image_path)\n","lang":"python","description":"This quickstart initializes the CLIP Interrogator, downloads necessary models (on first run), and then generates a text prompt from a dummy image. It includes best practices for VRAM management."},"warnings":[{"fix":"Delete old `.pkl` cache files (typically in `~/.cache/clip_interrogator`) or allow the library to redownload models in the `safetensors` format.","message":"Support for `.pkl` cache files was dropped in favor of `safetensors` format. Users upgrading from versions prior to 0.5.4 may need to clear their old cache or re-download models.","severity":"breaking","affected_versions":"<0.5.4 to 0.5.4+"},{"fix":"Use `Config.apply_low_vram_defaults()` (available since v0.5.4) or select a less VRAM-intensive `caption_model_name` like `blip-base` or `git-large-coco`.","message":"CLIP Interrogator, especially with larger caption models like `blip-large` or `blip2-flan-t5-xl`, requires significant VRAM (10GB+). If you experience out-of-memory errors, switch to smaller models or use `apply_low_vram_defaults()`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure you have sufficient disk space and a stable internet connection for the initial setup. Subsequent runs will use cached models.","message":"Models are downloaded to the user's cache directory (e.g., `~/.cache/clip_interrogator` or Hugging Face cache) on first initialization. This can take time and consume several GBs of disk space.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}