Loading repository data…
Loading repository data…
Aaryan2304 / repository
An AI-powered visual search engine that finds visually similar fashion items from a dataset of over 100,000 images with sub-100ms latency. The system uses CLIP embeddings for semantic understanding and a high-performance FAISS vector database for efficient similarity search. It features a Streamlit UI for user interaction and scalable FastAPI back.
A scalable visual search system that finds visually similar images using CLIP embeddings and FAISS vector database. This system is optimized for fashion images using the DeepFashion dataset and works efficiently on both CPU and GPU environments (RTX 3050+ recommended for optimal performance).
# Clone the repository
git clone https://github.com/Aaryan2304/visual-search-engine.git
cd visual-search-engine
# Create virtual environment
python -m venv venv
# Activate virtual environment
# Windows:
venv\Scripts\activate
# macOS/Linux:
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Verify setup
python scripts/verify_setup.py
Download the DeepFashion Category and Attribute Prediction Benchmark:
data/deepfashion/Expected folder structure:
data/deepfashion/
├── Anno_coarse/ # Main annotation files
│ ├── list_category_cloth.txt # 50 clothing categories
│ ├── list_category_img.txt # Image-category mappings
│ ├── list_attr_cloth.txt # 1000+ clothing attributes
│ ├── list_attr_img.txt # Image-attribute mappings
│ ├── list_bbox.txt # Bounding box annotations
│ └── list_landmarks.txt # Fashion landmark annotations (8 landmarks)
├── Anno_fine/ # Fine-grained train/val/test splits
│ ├── train.txt, val.txt, test.txt # Data partition files
│ ├── train_*.txt, val_*.txt, test_*.txt # Split-specific annotations
│ └── list_*.txt # Category and attribute definitions
├── Eval/ # Evaluation protocols
│ └── list_eval_partition.txt # Overall train/val/test splits
├── Img/ # ~289K fashion images (~5,620 categories)
│ └── [clothing_category_folders]/ # Images organized by item names
└── README.txt # Official dataset documentation
# Navigate to project directory
cd visual-search-engine
# Option 1: Quick test with 1000 images
python scripts/run_pipeline.py --data-dir ./data/deepfashion --max-images 1000 --complete
# Option 2: Full pipeline with all images (slow, 2+ hours)
python scripts/run_pipeline.py --data-dir ./data/deepfashion --complete
If you prefer to run individual steps:
# Step 1: Process dataset metadata
python scripts/run_pipeline.py --data-dir ./data/deepfashion --step data
# Step 2: Generate embeddings
python scripts/run_pipeline.py --data-dir ./data/deepfashion --step embeddings
# Step 3: Setup vector database
python scripts/run_pipeline.py --data-dir ./data/deepfashion --step database
# Step 4: Validate system
python scripts/run_pipeline.py --data-dir ./data/deepfashion --step validate
After completing the pipeline, start both services:
Option 1: Quick Start (Recommended)
# Terminal 1: Start API server
python -m uvicorn src.api.main:app --reload --host 0.0.0.0 --port 8001
# Terminal 2: Start web interface
streamlit run frontend/streamlit_app.py --server.port 8501 --server.address 0.0.0.0
Option 2: Background Services
# Start API in background
start /b python -m uvicorn src.api.main:app --host 0.0.0.0 --port 8001
# Start Streamlit in background
start /b streamlit run frontend/streamlit_app.py --server.port 8501 --server.address 0.0.0.0
🌐 Access Your Application:
data/processed/| Parameter | Description | Example |
|---|---|---|
--max-images | Limit number of images (for testing) | 1000 |
--batch-size | Images per batch (adjust for your GPU) | 16 |
--step | Run specific step only | data, embeddings, database, validate |
--complete | Run all pipeline steps | (flag only) |
Import Error Fix:
# Ensure you're in the project root directory
cd visual-search-engine
# If still failing, set Python path explicitly
set PYTHONPATH=%CD% && python scripts/run_pipeline.py --data-dir ./data/deepfashion
Memory Issues:
# Reduce batch size for lower VRAM
python scripts/run_pipeline.py --data-dir ./data/deepfashion --batch-size 8 --max-images 500 --complete
Database Issues:
# Clear database and start fresh (if needed)
rmdir /s /q data\processed\faiss_db
Quick Setup Verification:
# Run verification script to check setup
python scripts/verify_setup.py
The system uses FAISS (Facebook AI Similarity Search) for vector storage:
data/processed/faiss_db/
├── faiss_index.bin # FAISS index with embeddings
├── metadata.json # Image metadata
└── id_mapping.json # ID mappings
# Start API server (Terminal 1)
python -m uvicorn src.api.main:app --reload --host 0.0.0.0 --port 8001
# Start web interface (Terminal 2)
streamlit run frontend/streamlit_app.py --server.port 8501
visual-search-engine/
├── 📁 data/ # Dataset and processed files
│ ├── deepfashion/ # DeepFashion dataset (download required)
│ └── processed/ # Generated embeddings and database
│ ├── embeddings.npy # CLIP embeddings
│ ├── metadata.csv # Image metadata
│ ├── image_mappings.json # Image path mappings
│ └── faiss_db/ # FAISS vector database
├── 📁 src/ # Core application code
│ ├── api/ # FastAPI backend
│ │ ├── main.py # API application entry point
│ │ ├── endpoints.py # API route definitions
│ │ └── schemas.py # Pydantic models
│ ├── embeddings/ # CLIP model and embedding generation
│ │ ├── clip_model.py # CLIP model wrapper
│ │ └── generator.py # Embedding generation pipeline
│ ├── database/ # Vector database operations
│ │ ├── vector_db.py # FAISS database wrapper
│ │ └── indexer.py # Indexing operations
│ ├── data/ # Data processing utilities
│ │ └── preprocessor.py # Dataset preprocessing
│ └── utils/ # Shared utilities
│ ├── image_utils.py # Image processing helpers
│ └── logger.py # Logging configuration
├── 📁 frontend/ # Streamlit web interface
│ └── streamlit_app.py # Main web application
├── 📁 scripts/ # Automation and setup scripts
│ ├── run_pipeline.py # Main pipeline orchestrator
│ └── verify_setup.py # Setup verification
├── 📁 tests/ # Test suite
│ ├── test_api.py # API tests
│ ├── test_embeddings.py # Embedding tests
│ ├── test_database.py # Database tests
│ └── test_api_integration.py # Integration tests
├── 📁 docs/ # Documentation
│ └── DATASET_ANALYSIS.md # Dataset structure analysis
├── 📁 extras/ # Optional features
│ └── monitoring/ # Prometheus/Grafana configs
├── 📁 docker/ # Docker configurations (optional)
│ ├── api.Dockerfile # API container
│ └── frontend.Dockerfile # Frontend container
├── 📁 logs/ # Application logs
├── 📄 requirements.txt # Python dependencies
├── 📄 docker_compose.yml # Docker Compose configuration
└── 📄 README.md # This file
pytest tests/
If you use this system or the DeepFashion dataset, please cite:
@inproceedings{liu2016deepfashion,
author = {Ziwei Liu, Ping Luo, Shi Qiu, Xiaogang Wang, and Xiaoou Tang},
title = {DeepFashion: Powering Robust Clothes Recognition and Retrieval with Rich Annotations},
booktitle = {Proceedings of IEEE Conference on Computer Vision and Pa