wuhao2343 GitHub avatar

face-emotion-app

wuhao2343

Face Emotion App is a local emotion recognition application that uses YOLOv8-face for face detection and a Vision Transformer (ViT) for 7-class emotion classification, providing a dark glassmorphism UI and a complete REST API.

Stars

8

7-day growth

No data

Forks

5

Open issues

0

License

MIT

Last updated

2026-07-11

AI repository intelligence
FR-AI / ANALYSIS

Why it is worth attention

It offers a fully offline, ONNX-based pipeline without requiring PyTorch or Ultralytics, includes one-click setup with automatic model download and resume, and features a polished dark UI with real-time camera streaming and video processing.

Who it is for

  • Python developers building local AI applications
  • Privacy-conscious users needing offline facial emotion analysis
  • Researchers or hobbyists exploring on-device emotion recognition
  • System integrators requiring a self-contained REST API for emotion detection

Use cases

  • Real-time emotion monitoring via webcam in a browser
  • Batch analysis of facial expressions in uploaded images
  • Generating emotion-tagged video clips from uploaded videos
  • Integrating emotion detection into other applications via REST endpoints

Strengths

  • No external GPU libraries required for inference (pure ONNX Runtime)
  • One-click launch script that sets up the environment and downloads models
  • Dark glassmorphism UI with SVG icons and animations
  • Comprehensive API with Swagger docs and support for image, video, and camera inputs

Considerations

  • Requires ≥8 GB RAM and may be memory-intensive on image uploads
  • Video processing uses disk streaming but image endpoint loads full image into memory
  • GPU acceleration currently limited to DirectML on Windows; no built-in CUDA support
  • Model download may fail on restrictive networks despite retry logic

README quick start

Face Emotion App

本地人脸情绪识别 · YOLOv8-face 检测 + ViT 7 类情绪分类 · 暗色玻璃拟态 UI · 完整本地 API


✨ 功能

  • 图片识别:拖入或上传图片,返回带人脸框 + 情绪标签的图,并统计情绪分布
  • 视频处理:上传视频,后台逐帧推理,完成后下载带标注的 MP4
  • 摄像头实时:选择摄像头,浏览器看带标注的实时画面 (MJPEG 流)
  • 本地 API:完整的 REST API + Swagger 文档,供其他程序调用
  • 暗色玻璃拟态 UI:深色主题、毛玻璃 + 渐变 + 动画
  • 纯 ONNX 推理:无 torch / 无 ultralytics / 无 transformers

🏗️ 架构

face-emotion-app/
├── app/                  # FastAPI 后端
│   ├── main.py
│   ├── config.py
│   ├── schemas.py
│   ├── models/
│   │   ├── detector.py   # YOLOv8-face ONNX (akanametov/yolo-face)
│   │   ├── classifier.py # ViT ONNX (trpakov/vit-face-expression)
│   │   └── pipeline.py
│   ├── services/
│   │   ├── video_processor.py
│   │   └── camera_service.py
│   └── routers/          # health / image / detect / video / camera
├── static/               # 暗色玻璃拟态前端 (无 emoji,纯 SVG 图标)
│   ├── index.html
│   ├── style.css
│   └── app.js
├── models/               # yolov8n-face.onnx + trpakov-vit-face.onnx
├── outputs/              # 生成的 MP4
├── .venv/                # 项目本地虚拟环境 (自动创建)
├── requirements.txt
├── check_env.py
├── run.py                # 一键启动
└── README.md

🚀 快速开始

1. 环境要求

项目要求
Python3.10 ~ 3.13
内存≥ 8 GB
系统Windows / macOS / Linux

2. 一键启动

cd face-emotion-app
python run.py

run.py 会自动:

  1. 找到系统里的 Python 3.10+ (优先 3.12)
  2. .venv/ 下创建虚拟环境
  3. requirements.txt 装进 venv
  4. 下载两个 ONNX 模型到 models/
  5. 启动 uvicorn + 自动打开浏览器

如果想用 GPU 加速(推荐):

.venv\Scripts\pip install onnxruntime-directml

然后启动,默认会优先使用 DmlExecutionProvider

3. 手动启动(可选)

# 创建 venv
python -m venv .venv
.venv\Scripts\activate          # Windows
# source .venv/bin/activate     # macOS/Linux

# 装依赖
pip install -r requirements.txt

# 跑环境检查
python check_env.py

# 启动服务
uvicorn app.main:app --host 0.0.0.0 --port 8000

打开 。


🤖 模型与下载

模型用途大小来源
yolov8n-face.onnx人脸检测~12 MBakanametov/yolo-face v1.0.0
trpakov-vit-face.onnx7 类情绪分类~327 MBtrpakov/vit-face-expression onnx/

模型在首次运行时自动下载。自带断点续传 — 如果公司网络 SSL 频繁断,会自动从断点续下,最多 8 次重试。

手动下载(如网络不通):

# YOLO
curl -L -o models/yolov8n-face.onnx \
  https://github.com/akanam

Description

本地人脸情绪识别

Related repositories

Similar projects matched by category, topics, and programming language.

lopopolo
Featured
lopopolo GitHub avatar

harness-engineering

Harness Engineering is a methodology for improving coding agent outputs by carefully crafting the environment around them—providing curated context, tools, and executable constraints that encode an organization’s nonfunctional requirements and cumulative lessons.

AI & Machine LearningAI Agents
2,390
slvDev
Featured
slvDev GitHub avatar

esp32-ai

A 28.9 million parameter language model runs on an $8 ESP32-S3 microcontroller entirely on-device, generating simple stories at about 9.5 tokens per second.

AI & Machine LearningLarge Language Models
1,960
littledivy
Featured
littledivy GitHub avatar

mimic

mimic captures traffic from any iOS or web app and automatically generates a Python client library that lets you call the app's API like a regular library.

AI & Machine Learning
1,482