Code Monkey home page Code Monkey logo

deconstruct-mediapipe's Introduction

convert-mediapipe-blendshapes-model-to-pytorch

This repository contains the code for converting the blendshapes component of MediaPipe's facemesh model to PyTorch.

Converting the model

Run the following commands:

conda create -y -n deconstruct-mediapipe python=3.9
conda activate deconstruct-mediapipe
pip install torch==2.1.2 torchvision==0.16.2 torchaudio==2.1.2 --index-url https://download.pytorch.org/whl/cpu
pip install -r requirements.txt
python mediapipe_blendshapes_model_to_pytorch.py

Checking the converted model

If you want to check the converted model, you need to pip install mediapipe. Then run python test_converted_model.py.

The outputs should look as follows, showing that the PyTorch model gives the same results for the (first 12) blendshapes as MediaPipe itself.

--------------------------------- Face 1 --------------------------------
Blendshapes from MediaPipe:
[0.    0.242 0.217 0.001 0.018 0.014 0.    0.    0.    0.098 0.048 0.017]
Blendshapes from PyTorch:
[0.    0.242 0.217 0.001 0.018 0.014 0.    0.    0.    0.098 0.048 0.017]
Blendshapes from TFLite:
[0.    0.242 0.217 0.001 0.018 0.014 0.    0.    0.    0.098 0.048 0.017]
--------------------------------- Face 2 --------------------------------
Blendshapes from MediaPipe:
[0.    0.085 0.169 0.008 0.032 0.013 0.    0.    0.    0.063 0.092 0.216]
Blendshapes from PyTorch:
[0.    0.085 0.169 0.008 0.032 0.013 0.    0.    0.    0.063 0.092 0.216]
Blendshapes from TFLite:
[0.    0.085 0.169 0.008 0.032 0.013 0.    0.    0.    0.063 0.092 0.216]

deconstruct-mediapipe's People

Stargazers

 avatar

Watchers

 avatar  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.