Skip to content

Repository files navigation

Telegram Face Recognition

A Telegram bot that recognizes faces from a live webcam feed and checks them against a list of known people — built as a simple attendance/presence tool.

It combines two models:

  • A face detector (OpenCV DNN, Caffe-based) that finds where faces are in a frame.
  • ArcFace (ONNX) that turns each detected face into a numeric "fingerprint" and compares it against known faces to identify who it is.

How to use

Once the bot is running and you open a chat with it on Telegram:

  1. Send /start — you'll see three buttons:
    • List registered students — shows everyone the bot currently knows, by name.
    • Check attendance (list) — takes a snapshot from the webcam and sends back a list marking each known person present (+) or absent (-), plus a count of unrecognized faces.
    • Photo of the class — takes a snapshot, draws a labeled box around every face it finds (name + confidence, or "Unknown"), and sends you the annotated photo.
  2. Send /about at any time for a short description of how the bot works.

Note: the bot only recognizes people whose photos were added before it was started — see Known limitations.

Setup

  1. Clone the repo and install dependencies:
   pip install -r requirements.txt
  1. Download arcface.onnx — see MODEL_SETUP.md for instructions. (deploy.prototxt and the .caffemodel face detector are already included in this repo.)
  2. Add a Telegram bot token: open face_reco.py and replace token = "YOUR TOKEN" with your own from @BotFather.
  3. Add known faces: inside known_faces/, create one folder per person, named after them, with one or more clear face photos inside: known_faces/ ├── John Smith/ │ └── photo1.jpg └── Bob Red/ └── photo1.jpg
  4. Run it:
   python face_reco.py

Known limitations

  • Known faces are loaded once, when the bot starts. Adding or removing photos in known_faces/ while it's running has no effect — restart to pick up changes.
  • Uses the machine's default webcam (cv2.VideoCapture(0)), so it needs a device with a camera attached — not usable as-is on a headless/cloud server.

License

MIT — see LICENSE.

About

Face Recognition in a Telegram bot with OpenCV and python-telegram-bot

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages