patlevin / tfjs-to-tf

A TensorFlow.js Graph Model Converter
MIT License
136 stars 19 forks source link

converting facemesh json and bin #7

Closed emedinac closed 4 years ago

emedinac commented 4 years ago

Hi, Thank you so much for this repository. I liked. I tried to run it with BodyPix and worked well, but when I use facemesh it generates the following problem:

attrs = _find_if_has_key(node[attr_key], key=str_key, of_type=list) KeyError: 'attr'

I tried to follow the reason, and I found some nodes in facemesh that have not this attribute (in attr_key), but it has input and the other 2 attrs (as common). Could you kindly check the reason why it is happening please? Follow the json.

https://storage.googleapis.com/tfhub-tfjs-modules/mediapipe/tfjs-model/facemesh/1/default/1/model.json

https://storage.googleapis.com/tfhub-tfjs-modules/mediapipe/tfjs-model/facemesh/1/default/1/group1-shard1of1.bin

patlevin commented 4 years ago

Hi! Thanks for providing the link to the model. The model contains layers that are not supported out-of-the-box by TensorFlow. Even fixing the problem with the node pre-processing won't help, as additional work needs to be done to support the custom layers.

I'm currently looking into this and trying to find whether I can find the package that provides the custom layer and load it if necessary.

This might take a bit,but I'll keep you posted.

patlevin commented 4 years ago

@emedinac Small update: I've added a check for unsupported layer types, so the converter will now display a proper error message instead of a misleading stack trace.

Unfortunately there's no easy way to convert the model without rewriting the graph. I will have a go at it again tonight and try to convert the Prelu-layers into standard TF-operations.

patlevin commented 4 years ago

@emedinac at long last support for facemesh made it into the converter. You can also install it directly using pip now: pip install tfjs-graph-converter should work now.

samuraiexx commented 4 years ago

Hello! I had the same problem converting other media pipe model, hand_landmark. https://tfhub.dev/mediapipe/tfjs-model/handskeleton/1/default/1

@patlevin

patlevin commented 3 years ago

@samuraiexx Hi!

The issue is fixed in the 1.x releases. I highly recommend using the PyPi version (currently version 1.2) as it fixes some other bugs as well.