microsoft / MMdnn

MMdnn is a set of tools to help users inter-operate among different deep learning frameworks. E.g. model conversion and visualization. Convert models between Caffe, Keras, MXNet, Tensorflow, CNTK, PyTorch Onnx and CoreML.
MIT License
5.78k stars 968 forks source link

Proposed update MMdnn for TensorFlow v2 compatibility #918

Closed vladmandic closed 2 years ago

vladmandic commented 3 years ago

I've created PR #917 that updates MMdnn for TensorFlow v2 compatibility by utilizing legacy support in TF2

Main reason is that TF1 requires Python 3.7 or lower and new systems come with Python 3.8 which I did not want to downgrade

Change is basically switching imports from tensorflow to tensorflow.compat.v1 and setting appropriate flags
Only additional change needed is definition of flatten layer as it has to be explicitly defined as legacy since contrib namespace no longer exists

Additional change in this PR is that emitted code does not use Inf constant as any constant may be undefined depending on the backend used

For example, Python or NodeJS with Tensorflow backend will resolve it fine, but GLSL code generated by TensorFlow/JS WebGL backend does not handle constants as constants in general do not exist in GLSL

I've tested this with converting Places365 ResNet152 model from Caffe to Tensorflow saved model and further using tensorflowjs_convert to convert this new TF saved model to TFJS graph model and then tested inference using NodeJS TensorFlow backend, WASM backend and WebGL backend

vladmandic commented 2 years ago

closing as no update from maintainer for over a year.