GithubHelp home page GithubHelp logo

thepowerfuldeez / facemesh.pytorch Goto Github PK

View Code? Open in Web Editor NEW
288.0 288.0 64.0 3.9 MB

This is the PyTorch implementation of paper Real-time Facial Surface Geometry from Monocular Video on Mobile GPUs (https://arxiv.org/pdf/1907.06724.pdf)

License: Apache License 2.0

Jupyter Notebook 98.80% Python 1.20%

facemesh.pytorch's People

Contributors

thepowerfuldeez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

facemesh.pytorch's Issues

3D landmark ๏ผŸ

Hello, I would like to ask how to use the three-dimensional coordinates of the image. I see that the value range of the third dimension is all numbers less than zeros, I am not sure how to convert them
Thank you so much for your work.,you're so great.

Full img as input to model?

Hi,
is there a method put full img as input into model and get the right position of detections mapped into ori img?

size issue

Hi, thank you for providing useful code.

I ran predict_on_batch.
Input size is 128x128
but I didn't work because of tensor size...

you comment that size must be 128 pixel but it didn't work
I got this error
image
could you provide 128x128 pixel model??
[email protected]

Use facemesh for filters?

Interesting project. Is it possible to use facemesh to change face and make nose smaller? How can I do that?

Any idea how we can train facemesh model with our own dataset?

Thanks for wonderful work. However, i would like to train this facemesh model with our own dataset which has 98 keypoints.
Could you please help me how we can start?
What type of loss function we should use as we don't know what mediapipe has used during their training.
Although you have already mentioned that we should as the BatchNorm layer for fine tuning. Could you help me which places we should use BatchNorm. In both FaceMeshBlock and FaceMesh block?

Result too bad

This is your result.
result (13)
but the result from mediapipe is
result (27)
obviously, your reproduce result is tooooooo bad!

about pth results differ from orignal tfmodels

firstly, thanks for your excellent work, but I found torch result is slightly different from the original tflite model:

tensorflow and torch version:

(Pdb) tf.__version__
'2.2.1'
(Pdb) torch.__version__
'1.5.1'

test code:

import os
import numpy as np

import tensorflow as tf
import torch
import torch.nn as nn

from facemesh import FaceMesh

import cv2
sample_img = cv2.imread("test.jpg")
sample_img_192 = cv2.resize(sample_img, (192, 192))
input_data = np.expand_dims(sample_img_192, axis=0).astype(np.float32) / 127.5 - 1.0

interpreter = tf.lite.Interpreter(model_path="facemesh-lite.f16.tflite")
interpreter.allocate_tensors()

net = FaceMesh()
net.load_weights("facemesh.pth")

# Get input and output tensors.
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()
input_shape = input_details[0]['shape']
# input_data = np.array(np.random.random_sample(input_shape), dtype=np.float32)

# tf inference
interpreter.set_tensor(input_details[0]['index'], input_data)
interpreter.invoke()
tf_coord_res = interpreter.get_tensor(output_details[0]['index'])

# torch inference
torch_output_data = net(torch.from_numpy(input_data.transpose(0, 3, 1, 2)))
torch_coord_res = torch_output_data[0].detach().numpy()

print(["torch", torch_coord_res[0]])
print(["tflite", tf_coord_res[0, 0, 0]])
print("diff %f" % (np.abs(torch_coord_res[0] - tf_coord_res[0, 0, 0]).mean()))

results:

#==>
['torch', array([ 94.1816  , 140.77983 , -14.322037, ..., 136.51678 ,  88.71278 ,
         6.525924], dtype=float32)]
['tflite', array([ 92.17496 , 139.39285 , -14.361812, ..., 134.26816 ,  87.34091 ,
         5.629876], dtype=float32)]
diff 1.167073

I think this may caused by the option conv2d("padding=same" ) different from tensorflow, have you fixed this problem or some advise?

thanks!

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.