ParshvPatel commited on
Commit
5b6fdc0
·
1 Parent(s): d992912

fix: add HuggingFace Spaces metadata to README

Browse files
Files changed (1) hide show
  1. README.md +182 -0
README.md ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Interlace Multimodal Fashion Search
3
+ emoji: 👗
4
+ colorFrom: purple
5
+ colorTo: pink
6
+ sdk: docker
7
+ app_port: 7860
8
+ pinned: false
9
+ ---
10
+
11
+ # Interlace — Multimodal Fashion Search Engine
12
+
13
+ A semantic fashion search engine built on FashionCLIP, FAISS, and BM25, with a Next.js frontend. Supports text search, image upload search, and multimodal queries against an ASOS product catalog.
14
+
15
+ ---
16
+
17
+ ## Prerequisites
18
+
19
+ | Tool | Version | Install |
20
+ |------|---------|---------|
21
+ | Python | 3.11 | [python.org](https://python.org) |
22
+ | Node.js | 18+ | [nodejs.org](https://nodejs.org) |
23
+ | npm | 9+ | bundled with Node.js |
24
+
25
+ ---
26
+
27
+ ## Project Structure
28
+
29
+ ```
30
+ Asos_Engine_Project/
31
+ backend/ FastAPI backend (ML engine + REST API)
32
+ app/
33
+ engine/ FashionCLIP encoder, FAISS index, BM25, reranker
34
+ routers/ API route handlers
35
+ services/ Search orchestration
36
+ models/ Pydantic schemas
37
+ requirements.txt
38
+ Dockerfile
39
+ frontend/ Next.js 15 App Router frontend
40
+ src/
41
+ app/ Pages (/, /search, /products/[sku])
42
+ components/ UI components
43
+ lib/ API client, types, mock data
44
+ asos_clean.csv Product catalog (not in repo — required for backend)
45
+ asos_engine/ FAISS indexes + embeddings (auto-generated on first run)
46
+ ```
47
+
48
+ ---
49
+
50
+ ## Running Locally
51
+
52
+ There are two modes:
53
+
54
+ - **Mock mode** — frontend only, uses hardcoded sample products. No backend needed. Good for UI demos.
55
+ - **Full stack** — frontend + backend, returns real ASOS search results with images.
56
+
57
+ ---
58
+
59
+ ### Option A: Frontend only (mock mode)
60
+
61
+ Use this if you just want to demo the UI without running the ML backend.
62
+
63
+ **Terminal 1:**
64
+ ```bash
65
+ cd frontend
66
+ npm install
67
+ npm run dev
68
+ ```
69
+
70
+ Open [http://localhost:3000](http://localhost:3000)
71
+
72
+ The app detects that no backend URL is configured and falls back to mock data automatically.
73
+
74
+ ---
75
+
76
+ ### Option B: Full stack (backend + frontend)
77
+
78
+ Use this for a real demo with live search results.
79
+
80
+ #### Step 1: Set up the backend
81
+
82
+ > **Important:** All backend commands must be run from the **project root** (`Asos_Engine_Project/`), not from inside `backend/`. The module imports use the `backend.` prefix and require the project root on the Python path.
83
+
84
+ **Terminal 1 — install and start the backend:**
85
+ ```bash
86
+ # From Asos_Engine_Project/
87
+ python -m pip install -r backend/requirements.txt
88
+ python -m uvicorn backend.app.main:app --reload --port 8000
89
+ ```
90
+
91
+ > **Windows note:** Use `python -m uvicorn` (not bare `uvicorn`). PowerShell does not automatically add Python's `Scripts/` folder to PATH, so the bare command is not found.
92
+
93
+ On first run, the engine will build FAISS indexes from `asos_clean.csv`. This takes a few minutes and produces files in `asos_engine/`. Subsequent runs skip this and load directly.
94
+
95
+ Expected output when ready:
96
+ ```
97
+ Engine ready with 46,000+ products
98
+ INFO: Uvicorn running on http://0.0.0.0:8000
99
+ ```
100
+
101
+ Verify it is running:
102
+ ```bash
103
+ curl http://localhost:8000/api/v1/health
104
+ # Expected: {"status":"ok","engine_ready":true,"product_count":...}
105
+ ```
106
+
107
+ Interactive API docs: [http://localhost:8000/docs](http://localhost:8000/docs)
108
+
109
+ #### Step 2: Set up the frontend
110
+
111
+ **Terminal 2 — configure and start the frontend:**
112
+ ```bash
113
+ cd frontend
114
+
115
+ # Create local env file pointing to the running backend
116
+ # Use printf, not echo -- PowerShell's echo writes UTF-16 which Next.js cannot read
117
+ printf 'NEXT_PUBLIC_API_URL=http://localhost:8000\n' > .env.local
118
+
119
+ npm install
120
+ npm run dev
121
+ ```
122
+
123
+ Open [http://localhost:3000](http://localhost:3000)
124
+
125
+ ---
126
+
127
+ ## Data File
128
+
129
+ `asos_clean.csv` is not stored in this repository (too large for Git). It must be present in the project root for the backend to start. The config auto-detects it:
130
+
131
+ ```
132
+ Asos_Engine_Project/
133
+ asos_clean.csv <-- place it here
134
+ ```
135
+
136
+ If you have the `.parquet` version instead (`asos_clean.parquet`), that also works and is preferred (faster to load).
137
+
138
+ ---
139
+
140
+ ## Environment Variables
141
+
142
+ ### Backend
143
+
144
+ Set via shell environment or a `.env` file in `backend/`:
145
+
146
+ | Variable | Default | Description |
147
+ |----------|---------|-------------|
148
+ | `ASOS_DATA_PATH` | auto-detected | Path to `asos_clean.csv` / `.parquet` |
149
+ | `ASOS_PERSISTENT_DIR` | `./asos_engine` | Where FAISS indexes are saved |
150
+ | `ASOS_LOG_LEVEL` | `INFO` | Logging verbosity |
151
+ | `HF_TOKEN` | (none) | HuggingFace token — needed to download FashionCLIP on first run if rate-limited |
152
+
153
+ ### Frontend
154
+
155
+ Set in `frontend/.env.local` (this file is gitignored):
156
+
157
+ | Variable | Example | Description |
158
+ |----------|---------|-------------|
159
+ | `NEXT_PUBLIC_API_URL` | `http://localhost:8000` | Backend base URL. If unset, app uses mock data. |
160
+
161
+ ---
162
+
163
+ ## API Endpoints
164
+
165
+ All routes are prefixed with `/api/v1`.
166
+
167
+ | Method | Endpoint | Description |
168
+ |--------|----------|-------------|
169
+ | GET | `/health` | Engine status and product count |
170
+ | POST | `/search` | Text, image (base64), or multimodal search |
171
+ | POST | `/search/image` | Image file upload search |
172
+ | GET | `/search/similar/{sku}` | Visually similar products |
173
+ | GET | `/products/{sku}` | Product detail by SKU |
174
+ | GET | `/products/{sku}/outfit` | Outfit recommendations for a product |
175
+
176
+ ---
177
+
178
+ ## Tech Stack
179
+
180
+ **Backend:** Python 3.11 · FastAPI · FashionCLIP · FAISS · BM25 · PyTorch · Pydantic v2 · Pandas · Uvicorn
181
+
182
+ **Frontend:** Next.js 15 (App Router) · TypeScript · Tailwind CSS v4 · Framer Motion · GSAP