{"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":"python","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,"search_vec":"'0.6.0':43 'activ':48 'address':56 'ai':37,67 'ai-art':66 'art':68 'blip':24,77 'cadenc':52 'clip':1,3,22,76 'current':40 'engin':71 'generat':10,30 'imag':14,36,63 'image-to-text':62 'infrequ':50 'interrog':2,4 'languag':17,74 'larg':16 'leverag':15 'librari':8 'like':21 'major':54 'model':20,38,57,75 'optim':61 'particular':27 'perform':60 'prompt':12,31,70 'prompt-engin':69 'python':7 'releas':51 'support':58 'text':11,34,65 'text-to-imag':33 'updat':55 'use':28 'version':41 'vision':19,73 'vision-language-model':72","created_at":"2026-04-15T18:33:23.888400+00:00","updated_at":"2026-04-16T02:35:22.669636+00:00","problems":[{"fix":"Install the library using pip: `pip install clip-interrogator==0.6.0`.","cause":"This error occurs when the `clip-interrogator` package is not installed or not accessible in the current Python environment.","error":"ModuleNotFoundError: No module named 'clip_interrogator'"},{"fix":"Reduce the image size, switch to a lower memory mode if available (e.g., `--lowvram` option in some interfaces), or run on a CPU by setting the device configuration to 'cpu'.","cause":"The GPU has insufficient memory to process the image and models, which require a significant amount of VRAM (typically 12GB or more).","error":"RuntimeError: CUDA out of memory"},{"fix":"Ensure the correct CLIP library is installed by following the `clip-interrogator`'s specific installation instructions for its dependencies, often involving installing `openai/CLIP` or checking for conflicting `clip` installations.","cause":"This typically happens when there's a conflict with the `clip` library installation, or an incorrect `clip` package is installed instead of the one expected by `clip-interrogator` (which often relies on `openai/CLIP`).","error":"AttributeError: module 'clip' has no attribute 'load'"},{"fix":"Update the `transformers` library to the specified version or higher: `pip install transformers>=4.36.0`.","cause":"This indicates that the installed `transformers` library version is older than what `clip-interrogator` requires, leading to issues with importing necessary components like `AutoProcessor` or `BlipForConditionalGeneration`.","error":"pls check transformers.__version__>=4.36.0:: AutoProcessor, BlipForConditionalGeneration"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.6.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/pharmapsychotic/clip-interrogator","docs":null,"changelog":null,"pypi":"https://pypi.org/project/clip-interrogator/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["ai-ml","llm-agents"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}