Skip to content

DittoOne/meme_search

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

🖼️ CLIP-Powered Meme Search

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.


✨ Features

  • ✅ 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

📦 Tech Stack

  • Python 3.x
  • PyTorch
  • Transformers (Hugging Face)
  • NumPy
  • Pillow (PIL)
  • scikit-learn
  • pickle
  • glob

🚀 Getting Started

🛠️ Prerequisites

Install required packages:

pip install torch torchvision
pip install transformers
pip install numpy pillow scikit-learn

📁 Folder Structure

your_project/
│
├── content/
│   └── memes/
│       ├── meme1.jpg
│       ├── meme2.png
│       └── ...
├── meme_features.pkl        (auto-generated)
└── your_script.py

📌 All your images should be in content/memes/.


🧠 How It Works

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


⚙️ Example Usage

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)

✅ Caching

  • 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.


🎥 Demo

✅ See it in action here:

👉 Watch Demo


🌐 Author

Md Shahriar Rahman Bhuiyan
🌐 LinkedIn Profile


💬 Feedback

If you have feedback or want to collaborate, feel free to reach out via LinkedIn!

About

It returns the image of the memes based on user text based queries

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published