This guide explains how to deploy and run the AI Fashion Assistant v2.0 demo using the provided Colab notebook.
Demo Notebook: E_Ticaret_Chatbot_DEMO.ipynb
Components:
- FastAPI backend with search endpoints
- Streamlit frontend interface
- ngrok tunnel for public access
- FAISS vector search with 44,417 products
- Google Account (for Colab)
- ngrok Account (free tier) - Sign up here
- Google Drive with sufficient space (~2GB for models/embeddings)
- CUDA-capable GPU (for faster inference)
- Premium Colab (for better GPU access)
- Go to ngrok.com
- Sign up / Log in
- Go to "Your Authtoken" section
- Copy your authtoken
Required Files in Google Drive:
/MyDrive/ai-fashion-assistant-v2/
├── models/
│ ├── mpnet_model/ # sentence-transformers model
│ ├── clip_model/ # CLIP model
│ └── advanced_ranker.pkl # LightGBM ranker
│
├── embeddings/
│ ├── text_embeddings.npy # Text embeddings (44,417 x 1280)
│ └── image_embeddings.npy # Image embeddings (44,417 x 768)
│
├── data/
│ └── styles_processed.csv # Product metadata
│
└── faiss_index/
└── product_index.faiss # FAISS index
Note: These files should already exist from your v2.0 baseline research. If not, run the preprocessing notebooks first.
- Go to Google Colab
- File → Upload notebook
- Upload
E_Ticaret_Chatbot_DEMO.ipynb - Connect to runtime: Runtime → Change runtime type → GPU (T4 recommended)
# Mount Google Drive
from google.colab import drive
drive.mount('/content/drive')Action: Click authorization link, sign in, copy code, paste
# Install system dependencies
!apt-get update -qq
!apt-get install -y -qq python3-opencvWait for: Installation to complete (~30 seconds)
# Install Python packages
!pip install -q fastapi uvicorn pyngrok streamlit ...Wait for: Package installation (~2 minutes)
These cells load models, embeddings, and create the FastAPI backend.
No action needed - Just run sequentially
Watch for:
- ✅ Models loaded successfully
- ✅ FAISS index loaded (44,417 vectors)
- ✅ Backend initialized
from pyngrok import ngrok
NGROK_TOKEN = "YOUR_NGROK_TOKEN_HERE" # ← REPLACE THIS!
ngrok.set_auth_token(NGROK_TOKEN)
print("✅ ngrok yapılandırıldı!")Action: Replace YOUR_NGROK_TOKEN_HERE with your actual ngrok token
These cells create the Streamlit UI.
No action needed - Just run sequentially
# Start FastAPI backend + Streamlit frontend + ngrok tunnelThis cell will:
- Start FastAPI on port 8000
- Start Streamlit on port 8501
- Create ngrok tunnel
- Print public URL
Output:
🚀 Backend çalışıyor: http://localhost:8000
🎨 Frontend çalışıyor: http://localhost:8501
🌐 Dışarıdan erişim için ngrok URL'si:
https://xxxx-xxxx-xxxx.ngrok-free.app
✅ Sistem hazır! URL'ye tıklayarak erişebilirsiniz.
Action: Click the ngrok URL to access the demo!
# Stop services and clean upRun this when you're done to free resources.
-
Search Box
- Enter product queries in Turkish or English
- Examples: "kırmızı elbise", "nike running shoes"
-
Filters
- Gender: Erkek, Kadın, Unisex
- Category: Giyim, Ayakkabı, Aksesuar, etc.
- Color: Kırmızı, Mavi, Siyah, etc.
- Season: Yaz, Kış, Sonbahar, İlkbahar
-
Search Type
- Text Search: Semantic search using mpnet + CLIP
- Image Search: Upload image for visual similarity
- Hybrid Search: Combination of text + image
-
Results
- Product images with metadata
- Similarity scores
- Product details (name, color, category, etc.)
Solution:
- Check token is correct (no extra spaces)
- Get new token from ngrok dashboard
- Update Cell 9 and re-run
Solution:
- Check Google Drive paths are correct
- Ensure all model files are uploaded
- Re-run Phase 2 notebooks to generate embeddings
Solution:
- Restart runtime: Runtime → Restart runtime
- Use smaller batch size
- Use CPU-only mode (slower but works)
Solution:
- Run cleanup cell (Cell 14)
- Wait 30 seconds
- Re-run ngrok setup (Cell 9)
- Re-run services (Cell 13)
Solution:
# Kill existing processes
!pkill -9 uvicorn
!pkill -9 streamlit
!pkill -9 ngrokThen re-run service cells
-
Use GPU Runtime
- T4 GPU (free tier)
- V100/A100 (premium tier)
-
Optimize Batch Size
- Smaller batches = less memory
- Default: 32 products per search
-
Cache Embeddings
- Embeddings are precomputed
- Only query embedding is generated on-the-fly
-
Use FAISS Efficiently
- Default: top-10 retrieval
- Increase for more results (slower)
-
Never commit ngrok tokens to GitHub
- Tokens are personal and should be kept secret
- Replace with placeholder before sharing
-
ngrok URLs are temporary
- URLs expire when session ends
- New URL generated each time
-
Rate Limits
- Free ngrok: Limited requests/minute
- Free Colab: Session timeout after 12 hours
-
Data Privacy
- Demo runs in your Colab instance
- No data leaves your environment
- ngrok only tunnels requests
| Metric | Value |
|---|---|
| Startup Time | ~3-5 minutes |
| Search Latency | <200ms (p95) |
| Embedding Generation | ~50ms per query |
| FAISS Retrieval | ~10ms for top-10 |
| Total Response Time | ~100-150ms |
| Metric | Value |
|---|---|
| NDCG@10 | 97.43% |
| Recall@10 | 51.11% |
| Precision@10 | 97.73% |
| MRR | 100% |
Before starting demo:
- Google Drive files uploaded
- ngrok token obtained
- Colab GPU runtime selected
- All cells executed in order
- ngrok URL generated
- Interface accessible
During demo:
- Search works (text queries)
- Filters work (gender, category, etc.)
- Results display correctly
- Performance is acceptable (<300ms)
This demo is part of:
- Program: TÜBİTAK 2209-A
- Institution: Karamanoğlu Mehmetbey Üniversitesi
- Student: Hatice Baydemir
- Advisor: İlya Kuş
For academic presentations:
- Run demo beforehand to test
- Share ngrok URL with audience
- Prepare example queries
- Have backup screenshots ready
Issues or Questions?
- Check troubleshooting section above
- Review v2.0-baseline notebooks for details
- Check GitHub issues for common problems
For Research Inquiries:
- See main README.md for contact information
To use latest models/embeddings:
- Re-run Phase 2 notebooks (embeddings)
- Re-run Phase 5 notebooks (ranker)
- Upload new files to Drive
- Update paths in Cell 4-5 if needed
- Restart and re-run demo
Version: 2.0 Demo
Last Updated: December 30, 2024
Status: ✅ Stable and tested