Search code examples
pythontensorflowtensorflowjs-converter

Tensorflowjs Conversion Error: "ValueError: Unsupported Ops"


I was converting my tensorflow model to tensorflowjs form, using the following command

tensorflowjs_converter 
    --input_format=tf_saved_model 
    --output_node_names="my_output_node" \
    --saved_model_tags=serve my_saved_model_dir \
    ./web_model

I encourtered the following mysterious error:

ValueError: Unsupported Ops in the model before optimization NonMaxSuppression, ResizeArea

I do have those operations in my graph. Do I need to swap them out for something more tensorflowjs friendly?

I went deep google, and only came across a reference to the following flag I could add to the tensorflowjs_converter command --skip_op_check=SKIP_OP_CHECK \ This did indeed compile, but then when trying to serve the js model I encountered a js error similar to the above:

Error: Tensorflow Op is not supported: ResizeArea

Any ideas how to modify my graph or my command to navigate this?

Thank you


Solution

  • The short answer is yes, you will need to change them. TensorflowJS will change the ops for optimisation purposes, but not all the ops have an equivalent TFJS version. The full list of supported ops is here: https://github.com/tensorflow/tfjs-converter/blob/master/docs/supported_ops.md

    Oddly 'NonMaxSuppression' does seem to be on the list, but ResizeArea is not, and will 100% not work.

    An alternative is to create a custom operation yourself, and use that code, but I'm not sure how to do that in TFJS.