Keras to Tensorflowjs - Unknown layer: TFOpLambda

764 views Asked by At

I'm new to machine learning and I'm trying to get keypoint detection working in the browser. I found this Keras tutorial: https://keras.io/examples/vision/keypoint_detection/

I got it working in Python, and then added a line to export it to .h5: model.save('keypoint.h5')

I then converted it to tfjs: tensorflowjs_converter --input_format=keras /keypoint.h5 /tfjs_model

However when I try and run it in the browser like so: const model = await tf.loadLayersModel(‘path/to/model.json’);

I get the following error: Error: Unknown layer: TFOpLambda

Looking inside model.json I can see the following Lambda layers:

{"class_name": "TFOpLambda", "config": {"name": "tf.math.truediv_1", "trainable": true, "dtype": "float32", "function": "math.truediv"}, "name": "tf.math.truediv_1", "inbound_nodes": [["input_4", 0, 0, {"y": 127.5, "name": null}]]}, 
{"class_name": "TFOpLambda", "config": {"name": "tf.math.subtract_1", "trainable": true, "dtype": "float32", "function": "math.subtract"}, "name": "tf.math.subtract_1", "inbound_nodes": [["tf.math.truediv_1", 0, 0, {"y": 1.0, "name": null}]]}

I've read that I need to create a custom layer, but this is where I'm completely stumped. How do I go about this? This is well beyond my current understanding but I'm keen to learn - any help appreciated.

Thanks

0

There are 0 answers