尚未偵測到更新。GitHub 發布版本後會顯示在這裡。
個人 GitHub 帳號下公開儲存庫的擁有者可以登入並驗證所有權,自行管理介紹,無需管理員核准。
登入並產生驗證檔案,在 30 分鐘內將其提交至此儲存庫的預設分支。其他分支或分叉儲存庫中的檔案無效。然後在下方檢查檔案,即可無需管理員核准直接管理專案。請保留檔案以維持管理權限。
如需登入,將前往登入頁面。登入後請回到此處,再次點擊所選的驗證按鈕。
在專案資料夾中執行 /nomorevibe verify,即可驗證所有權並自行管理介紹。
一分鐘完成驗證Emotion-based food recommendation web application
翻譯準備中
取自儲存庫 README
正在載入完整 README。 以下為已儲存的摘錄。
AI-Powered Facial Emotion Recognition & Food Recommendation Web Application
FaceFood is a full-stack web application that analyzes a user's facial expression through their camera, classifies it into one of four supported emotion categories, and recommends food, drinks, ingredients, and fruits suited to that category.檢視完整 README ↗AI-Powered Facial Emotion Recognition & Food Recommendation Web Application
FaceFood is a full-stack web application that analyzes a user's facial expression through their camera, classifies it into one of four supported emotion categories, and recommends food, drinks, ingredients, and fruits suited to that category.
Food choices are often influenced by mood, but most food-discovery apps ignore that signal entirely. FaceFood explores a different entry point: instead of asking the user what they want, it analyzes their facial expression, classifies it into one of four emotion categories, and surfaces food recommendations mapped to that category — food, drinks, ingredients, and fruit — along with basic nutrition information for each item.
This is a 2-person university project built to explore the full pipeline end-to-end: training and serving a facial emotion recognition model, wiring it into a REST API, and building a camera-based web experience around it.
Camera Feed
→ Face Detection (Haar Cascade)
→ Emotion Classification (ResNet18 + Multi-head Attention)
→ Emotion Category Result
→ Food Recommendation Lookup (Firebase Realtime Database)
→ Nutrition Information Display
FaceFood analyzes facial expressions and classifies them into one of four supported emotion categories: Anger, Happiness, Neutral, and Sadness. That classification result is what drives which food category is recommended — the system does not claim to know a user's actual internal emotional state, only the visual category their expression was classified into.
Next.js Frontend → Flask REST API → Emotion Recognition Model (PyTorch)
→ Firebase Realtime Database (food/menu data)
[Architecture Diagram – to be added]
src/lib/api.ts)./api/analyze, /api/recommendations) exposing the emotion model and recommendation lookups. Also serves a legacy server-rendered UI (templates/) from earlier in the project.GCS_MODEL_BUCKET) — used so the ~48MB weight file doesn't need to be baked into the deploy image or committed to git.Dockerfile built for Google Cloud Run (gunicorn, PORT=8080, .gcloudignore) and a Procfile. The frontend's .gitignore includes Vercel-specific entries, indicating Vercel was used for frontend deployment, but no live URL is present in the repo to confirm the current deployment — [needs user confirmation].Frontend
Backend
AI / Machine Learning
torch, torchvision)Database
firebase-admin SDK)Deployment / Infrastructure
nn.MultiheadAttention (8 heads) applied over the embedding → fully-connected classification head (Linear → BatchNorm → ReLU → Dropout → Linear).Training scripts/notebooks are not part of this repository; only the trained weights, class list, and evaluation artifacts (confusion matrix, training curves) are included.
Evaluated on a held-out test set:
Test Accuracy: ~90.5% Weighted F1-score: ~90.5% (derived from the confusion matrix below — no separate saved classification report exists in the repository)
Confusion Matrix:
Training History (accuracy & loss):
| Home | Analyze / Camera |
|---|---|
docs/screenshots/home.png (not yet added) | docs/screenshots/analyze.png (not yet added) |
| Emotion Result | Food Recommendation |
|---|---|
docs/screenshots/result.png (not yet added) | docs/screenshots/recommendations.png (not yet added) |
| Error State |
|---|
docs/screenshots/error.png (not yet added) |
Screenshots to be added.
FaceFood/
├── backend/ # Flask API, emotion model, Firebase integration
├── frontend/ # Next.js web application
├── DEPLOY_CHECKLIST.md # Internal pre-deploy checklist
└── README.md
Primary API used by the frontend (see backend/app.py):
| Method | Endpoint | Purpose |
|---|---|---|
POST | /api/analyze | Accepts a base64-encoded camera frame, runs face detection + emotion classification, returns the classified emotion category and confidence scores |
POST | /api/recommendations | Returns food/drink/ingredient/fruit recommendations for a given emotion category, pulled from Firebase |
Error responses use a structured { "success": false, "error": { "code", "message" } } shape, with codes including INVALID_REQUEST, INVALID_IMAGE, NO_FACE_DETECTED, MODEL_ERROR, INVALID_EMOTION, DATABASE_ERROR.
The backend also serves a small set of legacy server-rendered routes (/, /analyze, /menu, etc.) from an earlier iteration of the project, alongside the JSON API used by the current Next.js frontend.
Team size: 2 (university project)
My responsibilities:
Frontend implementation was primarily handled by my teammate.
cd frontend
npm install
cp .env.example .env.local
npm run dev
Runs at http://localhost:3000. Requires the backend to be running separately — there is currently no mock-data mode implemented.
cd backend
pip install -r requirements.txt
python app.py
Runs at http://localhost:5000 by default. Requires the trained model weights (backend/models/best_resnet18_attention_emotion.pth) to be present locally, or GCS_MODEL_BUCKET configured to fetch them from Cloud Storage, plus Firebase credentials configured (see Environment Variables below).
Frontend — see frontend/.env.example:
NEXT_PUBLIC_API_BASE_URLNEXT_PUBLIC_API_TIMEOUT_MSBackend — configured via environment variables (no backend/.env.example exists yet; recommended as a follow-up):
FIREBASE_KEY_PATH — path to the Firebase service account credentialsALLOWED_ORIGINS — comma-separated CORS whitelistGCS_MODEL_BUCKET — Cloud Storage bucket to download model weights from, if not present locallyFLASK_SECRET_KEY — Flask session secretFLASK_DEBUG — enables Flask debug mode (defaults to off)No secret values are included here or anywhere in this repository.
Backend: containerized with Docker and built for Google Cloud Run (gunicorn, PORT=8080). Model weights are loaded from Google Cloud Storage at container startup rather than baked into the image.
Frontend: configured for Vercel deployment (inferred from repo .gitignore entries).
Live Demo: [URL to be confirmed]
low-light, distance) exist in the UI but are not yet wired up to real detection logic on either the frontend or backend.low-light/distance client error states to real detection logicFaceFood is an academic/educational project built for a university course/internship portfolio. It is not a clinical or diagnostic tool: it classifies facial expressions into one of four fixed categories and does not diagnose mental health conditions or determine a user's true emotional state. Food recommendations are informational only — not medical, psychological, or nutritional treatment advice.
MIT — see LICENSE.