This project enables visual search for an e-commerce store, where users can upload an image and receive similar product recommendations. Instead of typing a text query, the user simply uploads an image (e.g., a pair of swimming trunks π©³), and the system will analyze the image and return matching products from the catalog.
-
Frontend:
- Tools: HTML, CSS, JavaScript
- Function: The user interface where users upload images. The frontend sends the image to the backend for processing and displays the results.
-
Backend:
- Tool: Flask (Python)
- Function: Handles incoming requests, processes the uploaded image, interacts with Pinecone to search for similar products, and sends results back to the frontend.
-
Image Embedding:
- Tool: ResNet50 (Pre-trained deep learning model)
- Function: Converts the uploaded image into an embedding (a vector of numbers) that captures its unique features, making it comparable with other product images.
-
Embedding Storage & Similarity Search:
- Tool: Pinecone
- Function: Stores embeddings for all catalog items, enabling fast similarity searches.
- Search Criteria: The system retrieves the top 5 similar items based on cosine similarity, with a threshold score of 0.70 to ensure relevance.
-
Metadata Storage:
- Tool: SQLite
- Function: Stores metadata for each product (e.g., ID, name, price). After retrieving similar embeddings from Pinecone, Flask uses the product IDs to fetch complete details from SQLite.
-
Result Display:
- Function: The backend sends the product details (name, price, etc.) and images back to the frontend, which displays the top-matching products.
Visual Search/
βββ app.py # Main Flask backend file
βββ templates/
β βββ index.html # Frontend HTML file
βββ static/
β βββ Images/ # Folder containing product images
β βββ script.js # JavaScript for frontend functionality
β βββ style.css # CSS for frontend styling
βββ catalogs/ # Product catalog images and metadata
βββ Product.db # SQLite database with product metadata
βββ .env # Environment file with Pinecone API key
βββ requirements.txt # List of required Python packages
- Python (>= 3.6)
- Flask (Web framework)
- ResNet50 (Pre-trained deep learning model)
- Pinecone (Vector database for similarity search)
- SQLite (Relational database for metadata)
-
Clone the repository to your local machine.
-
Install the required dependencies:
pip install -r requirements.txt
-
Create a
.envfile in the root directory and add your Pinecone API Key:PINECONE_API_KEY=your_pinecone_api_key
-
Start the Flask app:
python app.py
-
Open your browser and go to http://127.0.0.1:5000 to interact with the visual search.