How tahamerrtt/clip works
CLIP is a Python library for zero-shot image–text matching. A caller loads a pretrained model and image transform, preprocesses an image, tokenizes candidate text, and runs both through the model to obtain similarity scores. The implementation separates model acquisition/API handling, BPE tokenization, and neural-network encoding. The README documents the end-to-end scoring behavior; sampled source shows loading, preprocessing, tokenization, and model construction, but some model internals were excerpted only partially.
Main entry points: clip.py CLIP API · model.py CLIP model · simple_tokenizer.py BPE tokenizer · bpe_simple_vocab_16e6.txt.gz BPE vocabulary
Components 12
Loading and API
- CLIP API
clip/clip.py - Image preprocessing
clip/clip.py
Text Tokenization
- BPE tokenizer
clip/simple_tokenizer.py - BPE vocabulary
clip/bpe_simple_vocab_16e6.txt.gz
CLIP Network
- Model builder
clip/model.py - CLIP model
clip/model.py - Vision encoder
clip/model.py - Text encoder
clip/model.py - Similarity scores
clip/model.py
Other components
- Application caller
- OpenAI weights
- Model checkpoint
Connections 12
- Application caller → CLIP API: calls API
README.md - CLIP API → OpenAI weights: downloads weights
clip/clip.py - CLIP API → Model checkpoint: loads checkpoint
clip/clip.py - CLIP API → Model builder: builds model
clip/clip.py - CLIP API → BPE tokenizer: tokenizes text
clip/clip.py - CLIP API → Image preprocessing: returns transform
README.md - BPE tokenizer → BPE vocabulary: reads merges
clip/simple_tokenizer.py - Application caller → Image preprocessing: preprocesses image
README.md - Application caller → CLIP model: runs image and text
README.md - CLIP model → Vision encoder: encodes images
clip/model.py - CLIP model → Text encoder: encodes tokens
clip/model.py - CLIP model → Similarity scores: computes cosine scores
README.md