Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Face Meme Matcher

调用电脑摄像头检测人脸表情,并自动匹配最适合当前表情的本地表情包。

安装

建议先创建虚拟环境:

python3 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt

requirements.txt 是基础轻量版依赖,适合当前 Python 3.13 环境。如果你想用 DeepFace 模型版,建议使用 Python 3.10-3.12 的虚拟环境后再安装:

python -m pip install -r requirements-deepface.txt

运行

python app.py

如果 DeepFace/TensorFlow 安装太慢,或第一次下载模型暂时不可用,可以用轻量模式:

python app.py --no-deepface

联网下载表情包模板

程序会根据识别到的表情,从 memes/<emotion>/ 目录里挑最匹配的图片显示在人脸旁边。你可以先用内置脚本从 Imgflip 热门 meme 模板里下载一批图片:

python scripts/fetch_memes.py --limit 2

--limit 表示每种表情下载几张。下载后直接运行:

python app.py --no-deepface

窗口快捷键:

  • QEsc:退出
  • R:重新扫描 memes/ 目录里的表情包

macOS 第一次运行时可能会弹出摄像头权限;如果没弹出但摄像头打不开,请到“系统设置 -> 隐私与安全性 -> 摄像头”里给 Terminal、iTerm 或你的 Python 运行环境授权。

添加自己的表情包

把图片放进对应目录即可:

memes/
  happy/      开心
  sad/        难过
  angry/      生气
  surprise/   震惊
  fear/       害怕
  disgust/    嫌弃
  neutral/    平静

支持 .jpg.jpeg.png.webp。每次检测到某个表情,程序会从对应目录随机挑一张图;如果目录为空,会显示内置占位图。

说明

程序优先使用 DeepFace 做表情识别,支持 happysadangrysurprisefeardisgustneutral。如果 DeepFace 没安装或运行失败,会自动退回到基于 OpenCV 的简单启发式模式。启发式模式能跑通演示,但准确率明显低于模型模式。

About

recognize your expression and match suitable meme

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages