Flappy Bird, but the bird only flies when you smile.
Happy Bird is a feel-good twist on the classic Flappy Bird game. No tapping, no clicking β just smile to keep the bird in the air. Built with real-time face landmark detection and a machine learning pipeline, it's a simple yet powerful project that literally brings a smile to your face.
Your webcam feed is processed live using MediaPipe Face Mesh, which extracts 468 facial landmarks per frame. A subset of lip landmarks is fed into a scikit-learn pipeline (scaler + Random Forest classifier) trained to distinguish smiling from neutral/non-smiling expressions. The prediction is streamed to a browser-based Flappy Bird clone via FastAPI β smile and the bird flaps; stop smiling and it falls.
Webcam β OpenCV β MediaPipe Face Mesh β Lip Landmarks
β sklearn Pipeline (StandardScaler + RandomForestClassifier)
β Smile / No Smile
β FastAPI β Flappy Bird (HTML/JS)
| Layer | Technology |
|---|---|
| Face landmark detection | MediaPipe Face Mesh |
| Smile classification | scikit-learn (Random Forest + Pipeline) |
| Video capture | OpenCV |
| Backend / API | FastAPI |
| Frontend game | HTML, CSS, JavaScript |
Happy-Bird/
βββ smile/ # Training images β smiling faces
βββ non_smile/ # Training images β neutral faces
βββ templates/ # HTML frontend (the game)
βββ face_detection.py # MediaPipe landmark extraction
βββ train.py # Dataset builder + model training
βββ model.py # Pipeline definition
βββ model.pkl # Trained and serialized model
βββ lip_landmarks_dataset.csv # Extracted landmark features
βββ fast.py # FastAPI app + webcam inference loop
βββ smile.mp4 # Demo β smiling
βββ nosmile.mp4 # Demo β not smiling
Prerequisites: Python 3.8+, a webcam, and a working smile.
# Clone the repo git clone https://github.com/RijoSLal/Happy-Bird.git cd Happy-Bird # Install dependencies pip install fastapi uvicorn opencv-python mediapipe scikit-learn numpy # Run the app uvicorn fast:app --reload
Then open http://localhost:8000 in your browser. Allow webcam access, face the camera, and smile to fly.
If you want to retrain the classifier on your own data:
# Step 1: Extract landmarks from the smile/ and non_smile/ image folders python face_detection.py # Step 2: Train the Random Forest pipeline and save model.pkl python train.py
The pipeline applies standard scaling before classification, keeping things clean and portable via a single model.pkl file.
Most ML demos are impressive but impersonal. Happy Bird flips that β the model isn't just running in the background, it's you controlling something in real time. It turns a smile into an input device, which makes the whole experience oddly delightful.
Simple stack. Real-time inference. Zero buttons required.
MIT β fork it, smile at it, make it your own.