Tensorflow saved model to Tensorflowjs model conversion
See original GitHub issueI have trained a model in Tensorflow and converting the model to Tensorflow.js
I used the following command:
tensorflowjs_converter --control_flow_v2=True --input_format=tf_saved_model --saved_model_tags=serve --signature_name=serving_default --skip_op_check --strip_debug_ops=True --weight_shard_size_bytes=4194304 . tfjs
My python model- Link Js model after conversion- Link
What do the warnings below mean? Do I lose accuracy of my model predictions on conversion?
WARNING:tensorflow:Didn't find expected Conv2D or DepthwiseConv2dNative input to 'StatefulPartitionedCall/functional_17/functional_11/deep_labv3lite/my_mobile_net/functional_9/block_7_depthwise_BN/FusedBatchNormV3' WARNING:tensorflow:Didn't find expected Conv2D or DepthwiseConv2dNative input to 'StatefulPartitionedCall/functional_17/functional_15/deep_labv3/my_mobile_net_1/functional_13/block_7_depthwise_BN/FusedBatchNormV3'
The full conversion log is:
(tfjs) tmk@vampire:~/Projects/WebDev/Uplara/SizingChart-TFJS-E2E/raw/pzero_model_2$ tensorflowjs_converter --control_flow_v2=True --input_format=tf_saved_model --saved_model_tags=serve --signature_name=serving_default --skip_op_check --strip_debug_ops=True --weight_shard_size_bytes=4194304 . tfjs 2020-11-11 01:55:44.509990: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcudart.so.10.1'; dlerror: libcudart.so.10.1: cannot open shared object file: No such file or directory 2020-11-11 01:55:44.510022: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine. 2020-11-11 01:55:46.329249: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory 2020-11-11 01:55:46.329275: W tensorflow/stream_executor/cuda/cuda_driver.cc:312] failed call to cuInit: UNKNOWN ERROR (303) 2020-11-11 01:55:46.329312: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (vampire): /proc/driver/nvidia/version does not exist 2020-11-11 01:55:46.329541: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations: AVX2 FMA To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. 2020-11-11 01:55:46.335162: I tensorflow/core/platform/profile_utils/cpu_utils.cc:104] CPU Frequency: 3299990000 Hz 2020-11-11 01:55:46.335382: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x55e3f1cfca40 initialized for platform Host (this does not guarantee that XLA will be used). Devices: 2020-11-11 01:55:46.335420: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version 2020-11-11 01:56:04.611672: I tensorflow/core/grappler/devices.cc:69] Number of eligible GPUs (core count >= 8, compute capability >= 0.0): 0 2020-11-11 01:56:04.611802: I tensorflow/core/grappler/clusters/single_machine.cc:356] Starting new session 2020-11-11 01:56:04.765576: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:816] Optimization results for grappler item: graph_to_optimize 2020-11-11 01:56:04.765618: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818] function_optimizer: Graph size after: 2828 nodes (2175), 2640 edges (1986), time = 79.521ms. 2020-11-11 01:56:04.765630: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818] function_optimizer: function_optimizer did nothing. time = 1.276ms. 2020-11-11 01:56:07.116145: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:816] Optimization results for grappler item: graph_to_optimize 2020-11-11 01:56:07.116181: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818] debug_stripper: debug_stripper did nothing. time = 0.725ms. 2020-11-11 01:56:07.116188: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818] model_pruner: Graph size after: 1321 nodes (-1280), 1344 edges (-1281), time = 17ms. 2020-11-11 01:56:07.116193: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818] constant_folding: Graph size after: 1319 nodes (-2), 1342 edges (-2), time = 98.689ms. 2020-11-11 01:56:07.116199: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818] arithmetic_optimizer: Graph size after: 1319 nodes (0), 1342 edges (0), time = 27.223ms. 2020-11-11 01:56:07.116204: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818] dependency_optimizer: Graph size after: 1315 nodes (-4), 1338 edges (-4), time = 12.049ms. 2020-11-11 01:56:07.116210: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818] model_pruner: Graph size after: 1315 nodes (0), 1338 edges (0), time = 7.399ms. 2020-11-11 01:56:07.116215: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818] constant_folding: Graph size after: 1315 nodes (0), 1338 edges (0), time = 32.807ms. 2020-11-11 01:56:07.116222: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818] arithmetic_optimizer: Graph size after: 1315 nodes (0), 1338 edges (0), time = 27.599ms. 2020-11-11 01:56:07.116228: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818] dependency_optimizer: Graph size after: 1315 nodes (0), 1338 edges (0), time = 13.628ms. 2020-11-11 01:56:07.116233: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818] debug_stripper: debug_stripper did nothing. time = 1.454ms. 2020-11-11 01:56:07.116239: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818] model_pruner: Graph size after: 1315 nodes (0), 1338 edges (0), time = 6.404ms. 2020-11-11 01:56:07.116245: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818] constant_folding: Graph size after: 1315 nodes (0), 1338 edges (0), time = 29.492ms. 2020-11-11 01:56:07.116250: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818] arithmetic_optimizer: Graph size after: 1315 nodes (0), 1338 edges (0), time = 26.115ms. 2020-11-11 01:56:07.116256: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818] dependency_optimizer: Graph size after: 1315 nodes (0), 1338 edges (0), time = 13.382ms. 2020-11-11 01:56:07.116261: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818] model_pruner: Graph size after: 1315 nodes (0), 1338 edges (0), time = 7.497ms. 2020-11-11 01:56:07.116266: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818] constant_folding: Graph size after: 1315 nodes (0), 1338 edges (0), time = 29.918ms. 2020-11-11 01:56:07.116272: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818] arithmetic_optimizer: Graph size after: 1315 nodes (0), 1338 edges (0), time = 26.138ms. 2020-11-11 01:56:07.116279: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818] dependency_optimizer: Graph size after: 1315 nodes (0), 1338 edges (0), time = 14.685ms. WARNING:tensorflow:Didn't find expected Conv2D or DepthwiseConv2dNative input to 'StatefulPartitionedCall/functional_17/functional_11/deep_labv3lite/my_mobile_net/functional_9/block_7_depthwise_BN/FusedBatchNormV3' WARNING:tensorflow:Didn't find expected Conv2D or DepthwiseConv2dNative input to 'StatefulPartitionedCall/functional_17/functional_15/deep_labv3/my_mobile_net_1/functional_13/block_7_depthwise_BN/FusedBatchNormV3' WARNING:tensorflow:Didn't find expected Conv2D or DepthwiseConv2dNative input to 'StatefulPartitionedCall/functional_17/functional_11/deep_labv3lite/my_mobile_net/functional_9/block_8_depthwise_BN/FusedBatchNormV3' WARNING:tensorflow:Didn't find expected Conv2D or DepthwiseConv2dNative input to 'StatefulPartitionedCall/functional_17/functional_15/deep_labv3/my_mobile_net_1/functional_13/block_8_depthwise_BN/FusedBatchNormV3' WARNING:tensorflow:Didn't find expected Conv2D or DepthwiseConv2dNative input to 'StatefulPartitionedCall/functional_17/functional_11/deep_labv3lite/my_mobile_net/functional_9/block_9_depthwise_BN/FusedBatchNormV3' WARNING:tensorflow:Didn't find expected Conv2D or DepthwiseConv2dNative input to 'StatefulPartitionedCall/functional_17/functional_15/deep_labv3/my_mobile_net_1/functional_13/block_9_depthwise_BN/FusedBatchNormV3' WARNING:tensorflow:Didn't find expected Conv2D or DepthwiseConv2dNative input to 'StatefulPartitionedCall/functional_17/functional_11/deep_labv3lite/my_mobile_net/functional_9/block_10_depthwise_BN/FusedBatchNormV3' WARNING:tensorflow:Didn't find expected Conv2D or DepthwiseConv2dNative input to 'StatefulPartitionedCall/functional_17/functional_15/deep_labv3/my_mobile_net_1/functional_13/block_10_depthwise_BN/FusedBatchNormV3' WARNING:tensorflow:Didn't find expected Conv2D or DepthwiseConv2dNative input to 'StatefulPartitionedCall/functional_17/functional_11/deep_labv3lite/my_mobile_net/functional_9/block_11_depthwise_BN/FusedBatchNormV3' WARNING:tensorflow:Didn't find expected Conv2D or DepthwiseConv2dNative input to 'StatefulPartitionedCall/functional_17/functional_15/deep_labv3/my_mobile_net_1/functional_13/block_11_depthwise_BN/FusedBatchNormV3' WARNING:tensorflow:Didn't find expected Conv2D or DepthwiseConv2dNative input to 'StatefulPartitionedCall/functional_17/functional_11/deep_labv3lite/my_mobile_net/functional_9/block_12_depthwise_BN/FusedBatchNormV3' WARNING:tensorflow:Didn't find expected Conv2D or DepthwiseConv2dNative input to 'StatefulPartitionedCall/functional_17/functional_15/deep_labv3/my_mobile_net_1/functional_13/block_12_depthwise_BN/FusedBatchNormV3' WARNING:tensorflow:Didn't find expected Conv2D or DepthwiseConv2dNative input to 'StatefulPartitionedCall/functional_17/functional_11/deep_labv3lite/my_mobile_net/functional_9/block_13_depthwise_BN/FusedBatchNormV3' WARNING:tensorflow:Didn't find expected Conv2D or DepthwiseConv2dNative input to 'StatefulPartitionedCall/functional_17/functional_15/deep_labv3/my_mobile_net_1/functional_13/block_13_depthwise_BN/FusedBatchNormV3' WARNING:tensorflow:Didn't find expected Conv2D or DepthwiseConv2dNative input to 'StatefulPartitionedCall/functional_17/functional_11/deep_labv3lite/my_mobile_net/functional_9/block_14_depthwise_BN/FusedBatchNormV3' WARNING:tensorflow:Didn't find expected Conv2D or DepthwiseConv2dNative input to 'StatefulPartitionedCall/functional_17/functional_15/deep_labv3/my_mobile_net_1/functional_13/block_14_depthwise_BN/FusedBatchNormV3' WARNING:tensorflow:Didn't find expected Conv2D or DepthwiseConv2dNative input to 'StatefulPartitionedCall/functional_17/functional_11/deep_labv3lite/my_mobile_net/functional_9/block_15_depthwise_BN/FusedBatchNormV3' WARNING:tensorflow:Didn't find expected Conv2D or DepthwiseConv2dNative input to 'StatefulPartitionedCall/functional_17/functional_15/deep_labv3/my_mobile_net_1/functional_13/block_15_depthwise_BN/FusedBatchNormV3' WARNING:tensorflow:Didn't find expected Conv2D or DepthwiseConv2dNative input to 'StatefulPartitionedCall/functional_17/functional_11/deep_labv3lite/my_mobile_net/functional_9/block_16_depthwise_BN/FusedBatchNormV3' WARNING:tensorflow:Didn't find expected Conv2D or DepthwiseConv2dNative input to 'StatefulPartitionedCall/functional_17/functional_15/deep_labv3/my_mobile_net_1/functional_13/block_16_depthwise_BN/FusedBatchNormV3' 2020-11-11 01:56:20.055959: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:816] Optimization results for grappler item: graph_to_optimize 2020-11-11 01:56:20.055989: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818] remapper: Graph size after: 1397 nodes (2), 1030 edges (22), time = 22.547ms. 2020-11-11 01:56:20.055995: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818] constant_folding: Graph size after: 827 nodes (-570), 850 edges (-180), time = 53.079ms. 2020-11-11 01:56:20.056000: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818] arithmetic_optimizer: Graph size after: 827 nodes (0), 850 edges (0), time = 20.648ms. 2020-11-11 01:56:20.056004: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818] dependency_optimizer: Graph size after: 827 nodes (0), 850 edges (0), time = 12.759ms. 2020-11-11 01:56:20.056008: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818] remapper: Graph size after: 827 nodes (0), 850 edges (0), time = 4.52ms. 2020-11-11 01:56:20.056013: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818] constant_folding: Graph size after: 827 nodes (0), 850 edges (0), time = 22.811ms. 2020-11-11 01:56:20.056018: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818] arithmetic_optimizer: Graph size after: 827 nodes (0), 850 edges (0), time = 19.165ms. 2020-11-11 01:56:20.056024: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:818] dependency_optimizer: Graph size after: 827 nodes (0), 850 edges (0), time = 8.309ms. Writing weight file tfjs/model.json...
TLDR
What is the best way to convert my tensorflow saved model without losing any accuracy?
Issue Analytics
- State:
- Created 3 years ago
- Comments:13
Top GitHub Comments
@rohanmuplara @purviljain we are adding support for bilinear resize in the UpSampling2D layer, please refer to the issue #4386
Thanks so much @pyu10055 !