harperreed / photo-similarity-search

Super simple MLX (apple silicon) CLIP based photo similarity web app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸ“Έ Embed-Photos πŸ–ΌοΈ

License

Welcome to Embed-Photos, a powerful photo similarity search engine built by @harperreed! πŸŽ‰ This project leverages the CLIP (Contrastive Language-Image Pre-training) model to find visually similar images based on textual descriptions. πŸ”πŸ–ΌοΈ

🌟 Features

  • πŸš€ Fast and efficient image search using the CLIP model
  • πŸ’» Works on Apple Silicon (MLX) only
  • πŸ’Ύ Persistent storage of image embeddings using SQLite and Chroma
  • 🌐 Web interface for easy interaction and exploration
  • πŸ”’ Secure image serving and handling
  • πŸ“Š Logging and monitoring for performance analysis
  • πŸ”§ Configurable settings using environment variables

Screenshot

image

πŸ“‚ Repository Structure

embed-photos/
β”œβ”€β”€ README.md
β”œβ”€β”€ generate_embeddings.py
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ start_web.py
└── templates
    β”œβ”€β”€ README.md
    β”œβ”€β”€ base.html
    β”œβ”€β”€ display_image.html
    β”œβ”€β”€ index.html
    β”œβ”€β”€ output.txt
    └── query_results.html
  • generate_embeddings.py: Script to generate image embeddings using the CLIP model
  • requirements.txt: Lists the required Python dependencies
  • start_web.py: Flask web application for the photo similarity search
  • templates/: Contains HTML templates for the web interface

πŸš€ Getting Started

  1. Clone the repository:

    git clone https://github.com/harperreed/photo-similarity-search.git
    
  2. Install the required dependencies:

    pip install -r requirements.txt
    
  3. Configure the application by setting the necessary environment variables in a .env file.

  4. Generate image embeddings:

    python generate_embeddings.py
    
  5. Start the web application:

    python start_web.py
    
  6. Open your web browser and navigate to http://localhost:5000 to explore the photo similarity search!

Todo

  • Use siglip instead of clip
  • add a more robust config
  • make mlx optional

πŸ™ Acknowledgments

The Embed-Photos project builds upon the work of the Apple (mlx!), the CLIP model and leverages various open-source libraries. We extend our gratitude to the authors and contributors of these projects.

Happy searching! πŸ”βœ¨

About

Super simple MLX (apple silicon) CLIP based photo similarity web app

License:MIT License


Languages

Language:Python 74.1%Language:HTML 25.9%