Open vladmandic opened 3 years ago
so it breaks the compatibility with older versions of the framework.
Handling both tensorflow v2 and v1 could be done with
try:
import tensorflow.compat.v1 as tf
except ImportError:
import tensorflow as tf
(I hate that concept, but it works)
However, it can still only be used with TensorFlow 1 models
Not really as tensorflow.compat.v1
has access to all ops from v2
so only v2
models that could not be converted are ones that use new execution flow - and that is really a) very rare, b) outside of the scope of this change
So, the name "update for TensorFlow v2 compatibility" is not so correct.
True. I'm ok with naming it anything else...
Is there a reason why this is not merged yet? would be cool to have it in the master branch.
Is there a reason why this is not merged yet? would be cool to have it in the master branch.
Because this project is abandoned.
This PR updates
MMdnn
forTensorFlow
v2 compatibility by utilizing legacy support in TF2Main 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
totensorflow.compat.v1
and setting appropriate flagsOnly additional change needed is definition of
flatten
layer as it has to be explicitly defined as legacy sincecontrib
namespace no longer existsAdditional change in this PR is that emitted code does not use
Inf
constant as any constant may be undefined depending on the TF backend usedFor 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 both saved model and graph model using NodeJSTensorFlow
backend,WASM
backend andWebGL
backend