Giter VIP home page Giter VIP logo

tf-blazepose's Introduction

BlazePose Tensorflow 2.x

This is an implementation of Google BlazePose in Tensorflow 2.x. The original paper is "BlazePose: On-device Real-time Body Pose tracking" by Valentin Bazarevsky, Ivan Grishchenko, Karthik Raveendran, Tyler Zhu, Fan Zhang, and Matthias Grundmann, which is available on arXiv. You can find some demonstrations of BlazePose from Google blog.

Currently, the model being developed in this repo is based on TFLite (.tflite) model from here. I use Netron.app to visualize the architecture and try to mimic that architecture in my implementation. The visualized model architecture can be found here. Other architectures will be added in the future.

Note: This repository is still under active development.

Update 14/12/2020: Our PushUp Counter App is using this BlazePose model to count pushups from videos/webcam. Read more.

TODOs

  • Implementation

    • Initialize code for model from .tflite file.

    • Basic dataset loader

    • Implement loss function.

    • Implement training code.

    • Advanced augmentation: Random occlusion (BlazePose paper)

    • Implement demo code for video and webcam.

    • Support PCK metric.

    • Implement testing code.

    • Add training graph and pretrained models.

    • Support offset maps.

    • Experiment with other loss functions.

    • Workout counting from keypoints.

    • Rewrite in eager mode.

  • Datasets

    • Support LSP dataset and LSPET dataset (partially). More.

    • Support PushUps dataset.

    • Support MPII dataset.

    • Support YOGA-82 dataset.

    • Custom dataset.

  • Convert and run model in TF Lite format.

  • Convert and run model in TensorRT.

  • Convert and run model in Tensorflow.js.

Demo

  • Download pretrained model for PushUp dataset here and put into trained_models/blazepose_pushup_v1.h5. Test with your webcam:
python run_video.py -c configs/mpii/config_blazepose_mpii_pushup_heatmap_bce_regress_huber.json  -m trained_models/blazepose_pushup_v1.h5 -v webcam --confidence 0.3

The pretrained model is only in experimental state now. It only detects 7 keypoints for Push Up counting and it may not produce a good result now. I will update other models in the future.

Training

NOTE: Currently, I only focus on PushUp datase, which contains 7 keypoints. Due to the copyright of this dataset, I don't have permission to publish it on the Internet. You can read the instruction and try with your own dataset.

  • Prepare dataset using instruction from DATASET.md.

  • Training heatmap branch:

python train.py -c configs/mpii/config_blazepose_mpii_pushup_heatmap_bce.json
  • After heatmap branch converged, set load_weights to true and update the pretrained_weights_path to the best model, and continue with the regression branch:
python train.py -c configs/mpii/config_blazepose_mpii_pushup_heatmap_bce_regress_huber.json

Reference

  • Cite the original paper:
@article{Bazarevsky2020BlazePoseOR,
  title={BlazePose: On-device Real-time Body Pose tracking},
  author={Valentin Bazarevsky and I. Grishchenko and K. Raveendran and Tyler Lixuan Zhu and Fangfang Zhang and M. Grundmann},
  journal={ArXiv},
  year={2020},
  volume={abs/2006.10204}
}

This source code uses some code and ideas from these repos:

Contributions

Please feel free to submit an issue or pull a request.

tf-blazepose's People

Contributors

noirmist avatar vietanhdev 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

tf-blazepose's Issues

Pose landmark annotations for Yoga-82 dataset

Hi @vietanhdev, thanks for your great work! I notice that you will support the Yoga-82 dataset in the future according to your TODO list. However, when I searched the Yogo-82 dataset, I found this dataset only contains the category labels without any pose landmark annotations. Do you have the pose landmark annotations of Yoga-82 dataset?

How to define the heatmap size wrt to input image size ?

Hi,
Thanks for the amazing work. Quick question : is there a way to determine the optimal heatmap shape given an input image ? My images are (512, 1024, 3) and have between 3 to 7 keypoints, what heatmap size should I use ?

Cheers

About BBox

Hi, great work

When I see your codes, Bbox is only needed for training but not testing.

is Bbox mandatory to use in training phase?? or can I just get rid of it to train the model?

convert to onnx fails

Hi author,

When I convert the model to onnx format, an error similar with following rises up:
ValueError: Graph disconnected: cannot obtain value for tensor Tensor("joints/conv2d_58_input:0", shape=(None, 2, 2, 288), dtype=float32) at layer "conv2d_58". The following previous layers were accessed without issue: []

Both tensorflow 2.3.0 and 2.5.0 have the same error. I did not find out ant possible reasons for this issue. Any suggestions? Thanks.

TypeError: len is not well defined for symbolic Tensors. (Shape_2:0)

/home/sa/workspace/temp/tf-blazepose-master/src/metrics/pck.py:46 update_state
if len(tf.shape(y_true)) == 4: # Heatmap
/home/sa/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py:754 len
"shape information.".format(self.name))

TypeError: len is not well defined for symbolic Tensors.

I am not able to run the split_lsp_lspet.py file

Hi there,
I am trying to run the split_lsp_lspet.py file, seems it's not able to locate the other files referenced. src module not found.
I tried even deleting the init.py file, still the same error.

request for pre-trained weights

If you have the pre-trained weights for this model trained on mpii datset to share would be nice to have them for testing use. Thanks

Push-up

the push up counter is not working properly what can be the reason

Inconsistent with the original Blazepose full model

Thanks for your great work! I have some questions about the network structure. By comparing blazepose_full.py with the visualization image of the original tflite model, I found some differences. First, your implementation omitted the "identity_1" output in the original tflite model. Second, the "identity_2" output size is 156, i. e. 4 * (33+6), but the corresponding output size in your implementation is 99, i.e. 3 * 33. Why your implementation is inconsistent with the original model in these aspects? And why the joints output size is 156 in the original model? Many thanks in advance.

getting KeyError: 'is_pushing_up' while training with custom dataset

hi i am converting LIP CSV file. but here i am getting this error. i preapred same format as you shown dataset.md

File "/home/siva/Documents/wellnesys/tf-blazepose/src/data_loaders/pose_recognition.py", line 90, in load_data
is_pushing_up = int(data["is_pushing_up"])
KeyError: 'is_pushing_up'

File "/home/sa/anaconda3/envs/py38/lib/python3.8/site-packages/tensorflow/python/keras/saving/hdf5_format.py", line 175, in load_model_from_hdf5 raise ValueError('No model found in config file.') ValueError: No model found in config file.

When I load the h5 model file, the code reports an error.
File "/home/sa/anaconda3/envs/py38/lib/python3.8/site-packages/tensorflow/python/keras/saving/hdf5_format.py", line 175, in load_model_from_hdf5
raise ValueError('No model found in config file.')
ValueError: No model found in config file.

Is it possible to run without CUDA?

Traceback (most recent call last):
File "run_video.py", line 93, in
draw = visualize_keypoints(draw, regress_kps[:, :2], visibility=regress_kps_visibility, edges=edges, point_color=(0, 255, 0), text_color=(255, 0, 0))
File "E:\tf-blazepose\src\utils\visualizer.py", line 33, in visualize_keypoints
cv2.line(draw, p1, p2, (0, 0, 255), 2)
cv2.error: OpenCV(4.5.5) 👎 error: (-5:Bad argument) in function 'line'

Overload resolution failed:

  • Can't parse 'pt1'. Sequence item with index 0 has a wrong type
  • Can't parse 'pt1'. Sequence item with index 0 has a wrong type

I got an error like this. I think it's about CUDA. My device doesn't support CUDA. Help please.

Training does not converge

Hi, big fan of your work
I have an issue durnig training heatmap on (lsp/lspet) that the heatmap pck1 is decreasing and the heatmap mae is increasing
What could be the problem?
Thanks!

Output issue after training

Hello! I saw your great TF realization. I would be thankful for your help. Now, I'm realizing a similar task for the BlazePose model in TF2. I use another architecture of the model, but it's the same as yours. I'm using this model with pre-trained weights by this graph. And I train this model on our specific dataset, after augmentation we have more 30 000 images.
But, one problem appears during this process: as an output, we have a set of points (coordinates), which is the same for any input, so all coordinates are constant. Perhaps, you have some ideas or direction of thinking for this?
Thank you for your work and help.

ValueError when running "run_video.py"

Hello.
When I am running the webcam demo with "python run_video.py -c configs/mpii/config_blazepose_mpii_pushup_heatmap_bce_regress_huber.json -m blazepose_pushup_v1.h5 -v webcam --confidence 0.3", an error occurs:

**Traceback (most recent call last):
File "run_video.py", line 45, in
model = trainer.load_model(config, args.model)
File "/home/hkuit155/Desktop/tf-blazepose/src/trainers/blazepose_trainer.py", line 162, in load_model
model.compile()
File "/home/hkuit155/anaconda3/lib/python3.7/site-packages/tensorflow_core/python/training/tracking/base.py", line 457, in _method_wrapper
result = method(self, *args, **kwargs)
File "/home/hkuit155/anaconda3/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/training.py", line 446, in compile
self._compile_weights_loss_and_weighted_metrics()
File "/home/hkuit155/anaconda3/lib/python3.7/site-packages/tensorflow_core/python/training/tracking/base.py", line 457, in _method_wrapper
result = method(self, *args, kwargs)
File "/home/hkuit155/anaconda3/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/training.py", line 1592, in _compile_weights_loss_and_weighted_metrics
self.total_loss = self._prepare_total_loss(masks)
File "/home/hkuit155/anaconda3/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/training.py", line 1691, in _prepare_total_loss
raise ValueError('The model cannot be compiled '
ValueError: The model cannot be compiled because it has no loss to optimize.

It seems that the model needs to be trained before running with webcam. And the error appears when training begins.
Are there any solutions for it? I am looking forward to your reply. Thans you so much.

mpii_annotations.json

你好 可不可以提供一下mpii_annotations.json文件或者这个文件在哪里下载,我想试一下mpii数据集,但运行不起来

evaluation on LSP

I tried using mediapipe version to evaluate blazepose on LSP(in which i took some random images),i found that when pose is complex,it doesn't really do a good job compared to other estimation algorithms.
Any thoughts on that?

Inferencing queries

Can the model infer on CPU or only on GPU?
Can it infer high resolution image or at max, what resolution of the image can be inferred
Can the model perform the 3D pose estimation.
Also let us know what is the Inference FPS.

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.