A Python tool to search your meme (or image) collection using text queries!
Powered by OpenAI’s CLIP model, it finds and ranks images that match your description—even for fuzzy, creative prompts.
- ✅ Search images with natural language queries
- 🤖 Uses OpenAI’s CLIP (ViT-B/32) model for zero-shot vision-language matching
- ⚡️ Caches extracted image features for instant future searches
- 🗂️ Supports multiple image formats: .jpg, .png, .gif, .bmp
- 🖼️ Displays top matching images in notebook/console
- Python 3.x
- PyTorch
- Transformers (Hugging Face)
- NumPy
- Pillow (PIL)
- scikit-learn
- pickle
- glob
Install required packages:
pip install torch torchvision
pip install transformers
pip install numpy pillow scikit-learnyour_project/
│
├── content/
│ └── memes/
│ ├── meme1.jpg
│ ├── meme2.png
│ └── ...
├── meme_features.pkl (auto-generated)
└── your_script.py
📌 All your images should be in
content/memes/.
1️⃣ Loads or extracts CLIP features for all images in your content/memes/ folder
2️⃣ Caches those features in meme_features.pkl for instant future runs
3️⃣ Processes your text query into CLIP embedding
4️⃣ Computes cosine similarity between query and images
5️⃣ Returns and displays the top matching images
from your_module_name import search_images
query = "funny cat with sunglasses"
result_path = search_images(query, top_k=5)
print("Best match:", result_path)- First run: Extracts and caches features
- Next runs: Loads cached features instantly
If you add new images, simply delete meme_features.pkl to regenerate features.
✅ See it in action here:
Md Shahriar Rahman Bhuiyan
🌐 LinkedIn Profile
If you have feedback or want to collaborate, feel free to reach out via LinkedIn!