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