How krishnakaushik25/similar-images-finder works
Project type and purpose
• This is an open-source computer vision tool (“Similar Images Finder”) that implements an image-to-image search engine.
• It ingests a product image dataset, extracts deep features via a pretrained MobileNetV2, indexes them in Elasticsearch with a KNN plugin, and allows querying a new image to retrieve its top-k visually similar images.
Main components
a. Data Ingestion & Storage
• Input: input/train.json metadata and downloaded product images (in input/ or a data folder created by downloading_images.py).
• Output: Raw image files on disk.
b. ML Pipeline (src/ML_Pipeline)
• downloading_images.py: parses the Kaggle JSON, fetches images, writes to local disk.
• feature_extraction.py: loads MobileNetV2 (TensorFlow/Keras), computes and flattens image embeddings.
• elasticsearch_indexing.py: connects to an Elasticsearch cluster with the KNN plugin, creates an index per label or a unified index, and ingests embedding vectors with metadata (image ID, path).
c. Query Engine (Engine.py)
• Reads a user-specified input image, invokes feature_extraction on it, then calls Elasticsearch’s KNN search API to retrieve the top-N similar vectors.
• Formats results (image URLs/paths + similarity scores) into output/response.json.
d. External Services
• Elasticsearch cluster with the KNN plugin (hosted locally or remotely).
• Optional: if images are downloaded from external URLs (web requests).
e. Notebooks (for prototyping)
• Jupyter notebooks under notebooks/ illustrate each pipeline stage interactively (downloading, feature extraction, indexing, querying).
Relationships & data flow
1) Dataset JSON → downloading_images.py → Local image store
2) Image store → feature_extraction.py → Numeric embedding vectors
3) Embeddings + metadata → elasticsearch_indexing.py → ES index
4) User image → Engine.py → feature_extraction → ES KNN query → JSON output
Architectural patterns and design principles
• Modular pipeline: Each stage is encapsulated in its own Python module.
• Separation of concerns: Data ingestion, feature computation, indexing, and query logic are distinct.
• Reproducibility & prototyping: Jupyter notebooks parallel the src pipeline.
• Externalized state: Elasticsearch holds the indexed vectors rather than in-memory.
Technologies & frameworks
• Python 3.x
• TensorFlow & Keras (MobileNetV2 pretrained on ImageNet)
• NumPy, Pandas for data handling
• Elasticsearch with KNN plugin (e.g., elasticsearch-py)
• requests or urllib for HTTP image downloads
• Optional environment: virtualenv or Conda