ONNX segmentation becomes binary

302 views Asked by At

I had a segnet model I converted to ONNX using the most simple following python line:

onnx_model, _ = tf2onnx.convert.from_keras(model, [tf.TensorSpec([1,125,500,1], tf.float32)], output_path=out_path)

the ONNX works well, BUT I get an almost binary image [yes, I tested stretching issues, the ONNX output values were already in the range of 0-1, which means after multiplying by 255 I got the attached image].

Any idea why? output of segnet (top) vs onnx(buttom)

Attached also Netron inspection of both [ends] of models:

Netron (end of) model

1

There are 1 answers

0
ephraim On

Found the answer!

This link helped: https://github.com/onnx/tensorflow-onnx/issues/495

So I had a dropout layer in my Tensorflow model. for any reason my tf2onnx was VERY old, and since it didn't handle correctly the 0.5 value in that layer. Anyway - updating opset to 15 [not even 16] solved the problem