Master Thesis Project - University of Zurich
A fashion recommender system that uses Heterogeneous Graph Attention Networks (HGAT) to suggest compatible clothing items with explainable recommendations in pairs.
This system analyzes fashion items and their attributes to provide pairing recommendations. Using machine learning and graph neural networks, it understands the relationships between different clothing items, colors, patterns, and styles to suggest compatible combinations.
- Intelligent Recommendations: Heterogeneous Graph Attention Network model for fashion compatibility
- Explainable AI: Understand why certain items are recommended together
- Interactive UI: Vue.js frontend for easy item selection and exploration
- Real-time Processing: FastAPI backend for fast recommendation generation
- Comprehensive Dataset: Fashion items with detailed attributes and metadata
- Docker (version 20.10+)
- Docker Compose (version 2.0+)
- At least 4GB RAM available for Docker
Note for Windows users: This guide includes both Windows (PowerShell/CMD) and Linux/Mac commands. The
makecommands are only available on Linux/Mac systems.
-
Clone the repository
git clone https://github.com/your-username/Explanable-Item-Pairing-in-Fashion-Domain.git cd "Explanable Item Pairing in Fashion Domain"
-
Quick setup
Windows (PowerShell/CMD):
# first time docker-compose up --build # after built docker-compose upLinux/Mac:
make setup # or # firsttime docker-compose up --build # after built docker-compose up
-
Access the application
- Frontend: http://localhost
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
Windows (PowerShell/CMD):
# Development mode (with hot reloading)
docker-compose -f docker-compose.dev.yml up
# View logs
docker-compose logs
# Stop services
docker-compose down
# Clean up
docker-compose down -v
docker system prune -fLinux/Mac:
# Development mode (with hot reloading)
make dev
# View logs
make logs
# Stop services
make down
# Clean up
make clean-
Navigate to backend directory
cd backend -
Create virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Run the backend
python -m uvicorn main:app --host 0.0.0.0 --port 8000 --reload
-
Navigate to frontend directory
cd frontend -
Install dependencies
npm install
-
Run development server
npm run dev
-
Build for production
npm run build
Explanable Item Pairing in Fashion Domain/
βββ backend/ # FastAPI backend service
β βββ data/ # Data processing and ML models
β β βββ model_data/ # Trained models and datasets
β β βββ Enhancement.py # Recommendation enhancement logic
β β βββ Recommender.py # GAT model implementation
β βββ models/ # Pydantic data models
β βββ controller.py # API endpoints
β βββ service.py # Business logic
β βββ repository.py # Data access layer
β βββ main.py # FastAPI application entry point
βββ frontend/ # Vue.js frontend application
β βββ src/
β β βββ components/ # Vue components
β β βββ views/ # Page views
β β βββ services/ # API services
β β βββ stores/ # State management
β βββ public/ # Static assets
β βββ package.json # Node.js dependencies
βββ docker-compose.yml # Production Docker setup
βββ docker-compose.dev.yml # Development Docker setup
βββ Makefile # Convenient commands
βββ DOCKER_SETUP.md # Detailed Docker instructions
The system uses a custom Heterogeneous Graph Attention Network to learn fashion item relationships:
- Input: Fashion items with attributes (color, pattern, type, etc.)
- Graph Structure: Items and attributes as nodes, relationships as edges
- Output: Compatibility scores between item pairs
- Explainability: Attention weights show which attributes influence recommendations
- Multi-head attention mechanism
- Heterogeneous graph processing
- Attribute importance scoring
- Real-time inference capability
- Item Selection: Browse and select fashion items
- Recommendation Display: View compatible item suggestions
- Explanation Visualization: Understand recommendation reasoning
- Interactive Exploration: Filter and explore different categories
- Vue.js 3: Progressive JavaScript framework
- Vite: Fast build tool and development server
- Pinia: State management
- Axios: HTTP client for API communication
- D3.js: Data visualization
GET /- Health checkGET /api/test- Backend connectivity testPOST /api/recommendations- Get item recommendationsGET /api/items/{item_id}- Get item detailsPOST /api/sessions- Create user session
Currently configured for development with open CORS. For production deployment, implement proper authentication mechanisms.
Ensure these files exist in backend/data/model_data/:
gat_model.pt- Trained HGAT model weightsfashion_graph.pkl- Fashion item graph structurenode_mapping.pkl- Node ID mappingsfull_data.csv- Complete fashion datasettraining_data.csv- Training dataset
-
Production deployment
docker-compose up -d
-
Development deployment
docker-compose -f docker-compose.dev.yml up
See DOCKER_SETUP.md for detailed deployment instructions.
cd backend
python -m pytestcd frontend
npm run testAccess interactive API documentation at http://localhost:8000/docs
-
Port conflicts: Change ports in docker-compose.yml
-
Memory issues: Increase Docker memory allocation
-
Backend import errors: If you see "ImportError: attempted relative import with no known parent package":
# Rebuild the backend container docker-compose build --no-cache backend docker-compose up
-
Model loading errors: Verify model files in
backend/data/model_data/ -
Frontend build failures: If you see npm dependency errors:
Option 1 - Update lock file:
# Navigate to frontend directory cd frontend # Update package-lock.json npm install # Return to root and rebuild cd .. docker-compose build --no-cache frontend
Option 2 - Delete lock file and rebuild:
# Remove the problematic lock file del frontend\package-lock.json # Windows # rm frontend/package-lock.json # Linux/Mac docker-compose build --no-cache frontend -
General build failures: Try
docker system prune -fand rebuild
- Check application logs:
docker-compose logs(ormake logson Linux/Mac) - Verify all dependencies are installed
- Ensure model data files are present and accessible
- Check Docker resources and system requirements
This project is part of a Master's Thesis at the University of Zurich. Please contact the author for usage permissions.
For detailed Docker setup instructions, see DOCKER_SETUP.md.