| title | FasRec |
|---|---|
| emoji | 👗 |
| colorFrom | blue |
| colorTo | green |
| sdk | docker |
| app_port | 8000 |
| pinned | false |
| license | mit |
FasRec is a production-grade, AI-powered fashion recommendation and styling platform. It uses a state-of-the-art hybrid multimodal offline pipeline to find visually and semantically similar items, coupled with a dynamic LLaMA 3.3-70B integration that generates real-time, catalog-grounded outfit recommendations.
This engine is built on the Fashion Product Images Dataset. It utilizes both the rich JSON metadata files (for deep semantic text features like Fit, Occasion, and Descriptions) and the high-resolution product imagery.
graph TD
subgraph Offline_Pipeline ["Offline AI Pipeline (Local GPU)"]
INPUTS["JSON Metadata<br/>Product Images"] --> DL["Data Loader<br/>Builds Canonical Text"]
DL -->|Canonical Text| TE["Text Embeddings<br/>BAAI/bge-base-en-v1.5"]
DL -->|Images| IE["Image Embeddings<br/>google/siglip-base-patch16-224"]
TE --> FT[FAISS Text Index]
IE --> FI[FAISS Image Index]
FT & FI --> FUSE["Reciprocal Rank Fusion<br/>RRF Algorithm"]
FUSE --> PRE[precomputed_recs.json]
DL --> CACHE[parsed_products.csv]
end
subgraph Backend ["Production Backend (Render)"]
API[FastAPI Server]
DB[("Supabase PostgreSQL<br/>Users, Favorites, Outfits")]
LLM["Groq API<br/>LLaMA 3.3 70B"]
PRE & CACHE -.->|Loaded at Startup| API
API <--> DB
API <-->|Generates Outfits| LLM
end
subgraph Frontend ["Production Frontend (Vercel)"]
UI["React + Vite SPA<br/>Glassmorphism UI"]
UI <-->|REST / JSON| API
end
- SOTA Multimodal Retrieval: Generates text embeddings using
BAAI/bge-base-en-v1.5(from rich canonical JSON text) and image embeddings using Google'ssiglip-base-patch16-224. - Reciprocal Rank Fusion (RRF): Replaces static score weights with rank-based mathematical fusion, perfectly balancing visual and semantic similarity (normalized for UI percentage matching).
- GenAI Outfit Stylist: Integrates Groq (LLaMA 3.3-70B) to act as a personal stylist. The LLM is grounded using actual database
articleTypes, ensuring suggested outfit pieces perfectly match items available in the 44k catalog. - Smart Catalog Search: Multi-strategy fallback search (Exact → Word-by-Word → Fuzzy) maps LLM text generations back to real database items.
- User Persistence & Dashboards: Full authentication system (bcrypt/JWT) with Supabase PostgreSQL to save favorite items and AI-generated outfits.
- Monorepo Structure: Clean separation of concerns with independent deployability to Render (Backend) and Vercel (Frontend).
- Machine Learning: PyTorch, HuggingFace Transformers, FAISS
- Backend: Python 3.11, FastAPI, SQLAlchemy, PostgreSQL (Supabase)
- Frontend: React 18, Vite, React Router, Custom CSS (Glassmorphism)
- Generative AI: Groq (LLaMA 3.3-70B-Versatile)
- Deployment: Render (API), Vercel (Web), Cloudflare R2 (Image CDN)
FasRec/
├── backend/ # FastAPI Application & AI Pipeline
│ ├── artifacts/ # Generated assets (precomputed_recs.json, FAISS indexes)
│ ├── data/ # Raw dataset (styles/, images/)
│ ├── scripts/ # Offline AI processing scripts (01 to 03)
│ ├── src/ # API, Auth, LLM Orchestration, DB Models
│ └── requirements.txt # Slimmed deps for Render deployment
├── frontend/ # React Web Application
│ ├── src/ # React Components, Pages, AuthContext
│ ├── index.html # Vite entry point
│ └── package.json # Node dependencies
├── render.yaml # Render deployment blueprint
└── vercel.json # Vercel SPA routing rules
To precompute the recommendations using your local GPU:
cd backend
pip install -r requirements_ml.txt # Install torch, transformers, faiss
python scripts/01_generate_embeddings.py
python scripts/02_build_faiss_index.py
python scripts/03_precompute_recommendations.pyNote: This generates precomputed_recs.json and parsed_products.csv which are tracked in git for the production server.
cd backend
pip install -r requirements.txt
uvicorn src.api:app --reload --host 0.0.0.0 --port 8000Requires .env with DATABASE_URL (Supabase), GROQ_API_KEY, and JWT_SECRET_KEY.
cd frontend
npm install
npm run dev- Backend: Deployed to Render via the included
render.yamlblueprint. It installs only the lightweight serving dependencies (no PyTorch/FAISS required) and loads the precomputed JSON artifacts into memory. - Frontend: Deployed to Vercel via the Vercel GitHub integration. Configured with
vercel.jsonto support React Router SPA navigation. EnsureVITE_API_URLis set to the Render backend URL.
This backend can also run as a Docker Space. Hugging Face reads the YAML block at the top of this README; the important values are:
sdk: docker
app_port: 8000Required Space secrets / variables:
R2_PUBLIC_URL: Public Cloudflare R2 base URL for product images. Do not commit image files frombackend/data/images/.GROQ_API_KEY: Required only for/recommend/{item_id}/narration.JWT_SECRET_KEY: Required for auth token signing.DATABASE_URL: Optional. If omitted, the backend falls back to SQLite. For persistent users/favorites/outfits, use a hosted PostgreSQL URL.
Files that must be included in the Docker image:
backend/data/styles.csvbackend/artifacts/parsed_products.csvbackend/artifacts/precomputed_recs.json
Files intentionally ignored because they are local/offline or served from R2:
backend/data/images/backend/data/styles/backend/artifacts/text_embeddings.npybackend/artifacts/image_embeddings.npybackend/artifacts/product_ids.npybackend/artifacts/text_index.faissbackend/artifacts/image_index.faiss
When deployment logs stop at Uvicorn running on http://0.0.0.0:8000, the API process is running and waiting for requests. Check the Space root URL or /products; startup is not expected to print more logs until traffic arrives.