Code Monkey home page Code Monkey logo

tinytracker's Introduction

πŸ‘€ TinyTracker: Gaze Estimation on Edge Devices πŸ‘€

PWC

TinyTracker: Ultra-Fast and Ultra-Low-Power Edge Vision In-Sensor for Gaze Estimation
πŸ§‘πŸ»β€πŸš€ Pietro Bonazzi *1, πŸ§‘πŸΌβ€πŸš€ Thomas RΓΌegg*1, Sizhen Bian 1, Yawei Li1, Michele Magno1

*denotes equal contribution
ETH Zurich, Switzerland
in IEEE Sensor 2023 (Lecture Presentation)

πŸš€ TL;DR quickstart πŸš€

  1. Install requirements
python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt
  1. Install tensorflow
  2. get haarcascade detector for the face and store it in a new directory called "haarcascade"
mkdir haarcascade
cd haarcascade
wget https://github.com/opencv/opencv/blob/master/data/haarcascades/haarcascade_frontalface_default.xml
  1. run WebcamDemoTflite.py
python WebcamDemoTflite.py 

If everything works without errors, you can now track your gaze with your webcam and compare TinyTracker to TinyTrackerS. Red point: TinyTracker Pink point: TinyTrackerS

What is a TinyTracker?

TinyTracker and TinyTrackerS are highly efficient, fully quantized models for 2D gaze estimation designed to maximize the performance of the edge vision systems considered in the study (i.e Sony IMX500, Sony Spresense and Coral Dev Micro).

Name Input res. Params MAC Size [Kb]
TinyTracker 112x112 455k 11.8M 608
TinyTrackerS 96x96 85.8k 5.3M 169

How to train your TinyTracker :)

Here we show how to train our code on the GazeCapture Dataset. You can download the data used in the paper here.

Unzip dataset by:

mkdir GazeCapture
tar -xf GazeCapture.tar -C ./GazeCapture
cd GazeCapture
ls | grep ".tar.gz$" | xargs -I {} tar -xf {}
ls | grep ".tar.gz$" | xargs -I {} rm {}

Process dataset by running:

python prepareDataset.py --dataset_path /path/to/Dataset --output_path /path/to/Processed/Dataset

To train TinyTracker:

python train_TinyTracker.py --data-path /path/to/Processed/Dataset

To train TinyTrackerS:

python train_TinyTrackerS.py --data-path /path/to/Processed/Dataset

You can control other arguments with these commands:

    --data-path # Path to the dataset
    --num-epochs # Number of epochs to train
    --batch-size # Batch size for training
    --image-size # Image input size
    --learning-rate # Learning rate for training
    --pretrained # Path to pretrained model
    --backbone # Choosing which backbone to use
    --grid-emb # If grid embedding should be used
    --grey # If input images are greyscale

How to export TinyTracker on tflite

python convert_tlfite.py --path path/to/model.htf5

To convert tflite to .cc you can use this command

xxd -i path/to/model.tflite > path/to/model.cc

🌲 Navigation on the repo 🌲

The project structured as following :

.
β”œβ”€β”€ demo                                # Demo Script folder
β”‚    └── SpresenseDemo.py               # Spresense Demo Script
β”œβ”€β”€ models                              # Model Checkpoints
β”‚   β”œβ”€β”€ TinyTracker.tflite              # TinyTracker model checkpoint
β”‚   └── TinyTrackerS.tflite             # TinyTrackerS model checkpoint
β”œβ”€β”€ src                                 # assets, instructions, requirements file for virtual environments
β”‚   β”œβ”€β”€ evaluate_tflite.py              # Evaluation script for tflite models
β”‚   β”œβ”€β”€ ITrackerDataTF.py               # Dataloader for GazeCapture dataset
β”‚   β”œβ”€β”€ json_utils.py                   # Helper functions for json files
β”‚   β”œβ”€β”€ TinyTrackerS.py                 # TinyTrackerS model class
β”‚   β”œβ”€β”€ TinyTrackerTF.py                # TinyTracker model classes
β”œβ”€β”€ convert_tflite.py                   # Tflite conversion Script
β”œβ”€β”€ prepareDataset.py                   # Dataset processing script
β”œβ”€β”€ train_TinyTracker.py                # Training script for TinyTracker
β”œβ”€β”€ train_TinyTrackerS.py               # Training script for TinyTrackerS
β”œβ”€β”€ WebcamDemoTflite.py                 # Webcam Demo for both TinyTracker and TinyTrackerS
.

βœ‰οΈ Citation ❀️

@INPROCEEDINGS{bonazzi2023tinytracker,
  author={Bonazzi, Pietro and RΓΌegg, Thomas and Bian, Sizhen and Li, Yawei and Magno, Michele},
  booktitle={2023 IEEE SENSORS}, 
  title={TinyTracker: Ultra-Fast and Ultra-Low-Power Edge Vision In-Sensor for Gaze Estimation}, 
  year={2023},
  pages={1-4},
  keywords={Energy consumption;Computer vision;Machine vision;Estimation;AI accelerators;Vision sensors;Cameras},
  doi={10.1109/SENSORS56945.2023.10325167}}
@inproceedings{ruegg2023tinytrackers,
  title={Gaze Estimation on Spresense},
  author={Thomas RΓΌegg, Pietro Bonazzi, Andrea Ronco},
  year={2023},
  booktitle={Sony Challenge},
}

tinytracker's People

Contributors

pbonazzi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.