Giter Site home page Giter Site logo

andresprados / spiga Goto Github PK

View Code? Open in Web Editor NEW
262.0 18.0 30.0 128.87 MB

SPIGA: Shape Preserving Facial Landmarks with Graph Attention Networks.

Home Page: https://bmvc2022.mpi-inf.mpg.de/155/

License: BSD 3-Clause "New" or "Revised" License

Python 13.97% Jupyter Notebook 86.03%
bmvc2022 face-alignment gnn headpose-estimation cnn head-pose-estimation pytorch wflw 300w cofw

spiga's People

Contributors

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

spiga's Issues

3D Pose Estimation

@andresprados Hello, does the 3d pose estimated also sota compare with previously methods? How's the accuracy and speed tradeoff? Can it in realtime on CPU?
Originally posted by @jinfagang in #1 (comment)

We outperformed the current SOTA in 300W and WFLW. In addition, SPIGA is currently being tested on AFLW2000 and BIWI, with promising results. In terms of speed, we are able to run in real time with an RTX3060, as you will see in the upcoming demo video.

Problems running in a thread on Linux/Mac (with solution)

Just adding this note in case anyone else runs into this. I tried to run this code in a thread on Mac/Linux and was met with a bus error, no stack trace. Really not fun to debug. You can fix this with:

# Need this setting because of this issue:
# https://github.com/numpy/numpy/issues/654
os.environ["OPENBLAS_NUM_THREADS"] = "1"

Make sure that its called before anything else, well maybe mostly Numpy. This is due to this line in utils.py:

inv_A = np.linalg.inv(A)  # we assume A invertible!

Also, I do have this codebase running on Mac M1 if anyone has use, happy to post a PR.

Dog Face Cases (requesting the training script)

Hello,

my name is Jeong Hwan Lee. This is a great repository.

I am trying to implement a landmark detector for dog facial features. For this, I think I need to train the new model. Would it be possible to update the repository that includes training script? If it is possible, it will be great helpful.

I will look forward to your feedback.

Best regards,

Jeong Hwan Lee

RuntimeError: Found no NVIDIA driver on your system

Error when running the demo app.py

I install the latest pytorch from https://pytorch.org/:
pip3 install torch torchvision torchaudio

Then I run the install instructions:

pip install -e .  
pip install -e .[demo]

The error I get is:

app.py:3: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  import pkg_resources
Loading pretrained model from https://drive.google.com/uc?export=download&confirm=yes&id=1nxhtpdVLbmheUTwyIb733MrL53X4SQgQ
Traceback (most recent call last):
  File "app.py", line 107, in <module>
    main()
  File "app.py", line 47, in main
    video_app(args.input, spiga_dataset=args.dataset, tracker=args.tracker, fps=args.fps,
  File "app.py", line 80, in video_app
    faces_tracker = tr.get_tracker(tracker)
  File "/home/user/eclipse-workspace/111_SPIGA (face landmark detection)/spiga/demo/analyze/track/get_tracker.py", line 9, in get_tracker
    model = zoo.get_tracker(model_name)
  File "/home/user/eclipse-workspace/111_SPIGA (face landmark detection)/spiga/demo/analyze/track/retinasort/zoo.py", line 10, in get_tracker
    return tr.RetinaSortTracker()
  File "/home/user/eclipse-workspace/111_SPIGA (face landmark detection)/spiga/demo/analyze/track/retinasort/face_tracker.py", line 18, in __init__
    self.detector = retinaface.RetinaFaceDetector(model=config['retina']['model_name'],
  File "/home/user/miniconda3/envs/SPIGA5/lib/python3.8/site-packages/retinaface/inference_framework.py", line 48, in __init__
    net = rf_detect.load_model(net, trained_model, cpu_flag, url_file_name=url_model_name)
  File "/home/user/miniconda3/envs/SPIGA5/lib/python3.8/site-packages/retinaface/detect.py", line 47, in load_model
    device = torch.cuda.current_device()
  File "/home/user/miniconda3/envs/SPIGA5/lib/python3.8/site-packages/torch/cuda/__init__.py", line 674, in current_device
    _lazy_init()
  File "/home/user/miniconda3/envs/SPIGA5/lib/python3.8/site-packages/torch/cuda/__init__.py", line 247, in _lazy_init
    torch._C._cuda_init()
RuntimeError: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx

During installation, all nvidia necessary packages are installed:

Installing collected packages: mpmath, lit, cmake, zipp, typing-extensions, threadpoolctl, sympy, six, 
scipy, pyparsing, packaging, opencv-python, nvidia-nvtx-cu11, nvidia-nccl-cu11, nvidia-cusparse-cu11, 
nvidia-curand-cu11, nvidia-cufft-cu11, nvidia-cuda-runtime-cu11, nvidia-cuda-nvrtc-cu11, 
nvidia-cuda-cupti-cu11, nvidia-cublas-cu11, networkx, MarkupSafe, kiwisolver, joblib, fonttools, filelock, 
cycler, contourpy, scikit-learn, python-dateutil, nvidia-cusolver-cu11, nvidia-cudnn-cu11, jinja2, 
importlib-resources, matplotlib, triton, torch, torchaudio, spiga

I tried installing older versions of pytorch without any luck. Any ideas please?

showing only the face with highest confidence

Hi Andrés
Thanks a lot for the great repository. I have a mp4 video and some frames it shows two predicted face while there is only one face. When I am getting inference using your ipynb for video, is there a way I could force it to show only faces with probably of detection higher than 90%?

Head pose estimation Only

Thanks for sharing your incredible work with us. Your algorithm runs at ~3 frames/sec on GPU. So,
I am asking about getting the headpose prediction only using network architecture, is it possible? and how?
and the running time per frame will reduce and we can reach the real time execution ?

Performance improvement

what do you recommend for half profile pictures?
Also I could not figure how to filter out the bad results ? can you recommend ?

Unable to generate an ONNX that works in ONNXRuntime

Hi,

I tried to generate the ONNX model as in #3 but when using it with ONNXRuntime I can't get it to work, because I get this failure:

"Fail: [ONNXRuntimeError] : 1 : FAIL : Load model from model.onnx failed:Node (/Squeeze) Op (Squeeze) [ShapeInferenceError] Dimension of input 1 must be 1 instead of 2"

Any idea what is going on?

Thanks.

Code release

Code release will be available within the next two weeks, we expect to release the inference and the realtime demo before November and the training source before December.

sort_tracker and retinaface not found

Thanks for your great work. It seems that some of the necessary modules are missing here to run the demo.
Traceback (most recent call last):
File "/data1/zengwenzheng/code/SPIGA/./spiga/demo/app.py", line 7, in
import spiga.demo.analyze.track.get_tracker as tr
File "/data1/zengwenzheng/code/SPIGA/spiga/demo/analyze/track/get_tracker.py", line 2, in
import spiga.demo.analyze.track.retinasort.zoo as zoo_rs
File "/data1/zengwenzheng/code/SPIGA/spiga/demo/analyze/track/retinasort/zoo.py", line 2, in
import spiga.demo.analyze.track.retinasort.face_tracker as tr
File "/data1/zengwenzheng/code/SPIGA/spiga/demo/analyze/track/retinasort/face_tracker.py", line 4, in
import sort_tracker
ModuleNotFoundError: No module named 'sort_tracker'

Can you help me to figure out this issue? Thanks.

Onnx output and pytorch output are inconsistent

Thanks for open-sourcing this great work. I have encountered a problem now. When I convert the model to onnx and tensorrt, the landmark result of trt/onnx is different from the result of pytorch model. I find the problem is self.conv_window in onnx,you can see the result before self.conv_window and after self.conv_window. I print the crops[0, :5, :5] before self.conv_window[0] of torch and onnx,they are same,
image
image
After self.conv_window[0],the visual_fts[0,:5,:5] are different,
image
image

Importing retinaface causes all torch tensors to lack gradient function

Expected behavior of torch Tensors is to have a gradient function if it requires gradient.

Shortest example I have on what is happening for me.

import torch
x = torch.randn(1, requires_grad=True)
print(x + 1)
tensor([1.3468], grad_fn=<AddBackward0>)
import torch
import retinaface
x = torch.randn(1, requires_grad=True)
print(x + 1)
tensor([1.3468])

How to test an image by model?

Does the repository have a script for testing single images?
I noticed that the repository's test scripts are only available for specific datasets.

Fit FLAME model to Landmarks

Does anyone know how to fit the FLAME 3DMM to these landmarks?

I’d be interested in hiring someone who could build something like DECA or 3DDFA_V2 using these landmarks.

UnpicklingError: While running in Local and Colab

While Running demo I am encountering UnpicklingError. I have used latest pytorch and pytorch 1.4. It gave same error. I am encountering this in colab and local machine both.

`UnpicklingError                           Traceback (most recent call last)
<ipython-input-3-d26975ab34c8> in <cell line: 10>()
      8 
      9 # Process video
---> 10 video_app(video_path,
     11           spiga_dataset='wflw',               # Choices=['wflw', '300wpublic', '300wprivate', 'merlrav']
     12           tracker='RetinaSort',               # Choices=['RetinaSort', 'RetinaSort_Res50']

5 frames
/usr/local/lib/python3.10/dist-packages/torch/serialization.py in _legacy_load(f, map_location, pickle_module, **pickle_load_args)
   1256             "functionality.")
   1257 
-> 1258     magic_number = pickle_module.load(f, **pickle_load_args)
   1259     if magic_number != MAGIC_NUMBER:
   1260         raise RuntimeError("Invalid magic number; corrupt file?")

UnpicklingError: invalid load key, '<'.`

Have a problem in colab, UnpicklingError: invalid load key, '<'

When run in colab, this section have a problem and i haven't ideas to solve it

from spiga.inference.config import ModelConfig
from spiga.inference.framework import SPIGAFramework
dataset = 'wflw'
# Process image
processor = SPIGAFramework(ModelConfig(dataset))
features = processor.inference(image, [bbox])

image

Downloading: "https://drive.google.com/uc?export=download&confirm=yes&id=1h0qA5ysKorpeDNRXe9oYkVcVe8UYyzP7" to /content/SPIGA/spiga/models/weights/spiga_wflw.pt
100%|██████████| 2.37k/2.37k [00:00<00:00, 6.09MB/s]
---------------------------------------------------------------------------
UnpicklingError                           Traceback (most recent call last)
[<ipython-input-3-8d6ce5d787c3>](https://localhost:8080/#) in <cell line: 6>()
      4 # Process image
      5 dataset = 'wflw'
----> 6 processor = SPIGAFramework(ModelConfig(dataset))
      7 features = processor.inference(image, [bbox])

3 frames
[/usr/local/lib/python3.10/dist-packages/torch/serialization.py](https://localhost:8080/#) in _legacy_load(f, map_location, pickle_module, **pickle_load_args)
   1244             "functionality.")
   1245 
-> 1246     magic_number = pickle_module.load(f, **pickle_load_args)
   1247     if magic_number != MAGIC_NUMBER:
   1248         raise RuntimeError("Invalid magic number; corrupt file?")

UnpicklingError: invalid load key, '<'.

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.