/googly-eyes

Googly Eyes is a fun project that adds a touch of humour to faces by making them look funnier with googly eyes.

Primary LanguagePythonMIT LicenseMIT

Unit tests


Googly Eyes

Make faces look funnier!

DescriptionGetting StartedSystem DetailsResultsMake It More FunReferences

Description

Googly Eyes is a fun project that adds a touch of humour to faces by making them look funnier with googly eyes.

Getting Started

Run via Docker

  • Install docker
  • Navigate to the project directory: cd googly-eyes
  • Run application:
docker-compose up --build

Run via Setting Up Dev Environment

  • Install poetry
  • Navigate to the project directory: cd googly-eyes
  • Install necessary dependencies:
poetry config virtualenvs.in-project true                  
poetry install 
  • Run the backend server
poetry run uvicorn googly_eyes.backend.server:app --reload   
  • On new terminal, run the frontend viewer:
cd googly-eyes/googly_eyes/frontend
poetry run streamlit run view.py

FastAPI docs

Go to http://localhost:8000/docs to see and try available backend api

Run via Python Script

  • Install poetry
  • Navigate to the project directory: cd googly-eyes
  • Install necessary dependencies:
poetry config virtualenvs.in-project true                  
poetry install 
poetry run python example.py <path-to-image-file>

System Details

High-Level Architecture

Backend

The backend system handles the googlification of eyes with the following steps:

  • Detects faces using BlazeFace.
  • Extracts facial landmarks using FaceMesh for all detected faces.
  • Googlify eyes
    • Extracts eyes - eye centers and eye sizes; this is randomized to make it fun.
    • Adds a googly eyes image filter based on the extracted eye centers and sizes, with random rotation for added humor.

Frontend

The frontend is a Streamlit viewer providing an interactive interface for users to enjoy the googly eyes effect on faces.

Results

Make It More Fun

There's a config file available! Check out config.yaml and feel free to experiment with the variables. These variables have specific roles:

  • Variables under face_detection_settings:
    • score_threshold - face detection confidence score between 0 and 1. A higher value may result in more accurate but fewer detections.
    • iou_threshold - intersection over union threshold for face detection to balance precision and recall, value between 0 and 1.
  • Variables under googly_eye_settings:
    • path - image path to googly eye image filter
    • size_multiplier- value to scale to get bigger googly eyes
    • size_inc_percent - to control the maximum random increase in each googly eye's size
    • centre_offset_percent - to change the offset of the googly eyes' centres, makes the googly eyes placement more dynamic.

References

  1. BlazeFace Paper
  2. FaceMesh Paper
  3. MediaPipe

author: Shubham M Wagh