'issue to make TTS model from .pb file to TFlight AttributeError: 'AutoTrackable' object has no attribute 'inputs'
Am trying to make TTS model for arabic with tacotron and I have checkpoint successfully generated with training and I stop the train on this point .
I save the file to .pb file and when I try to convert it to tflite this error appear any help ?
Code to convert checkpoint to pb
import os
import tensorflow as tf
trained_checkpoint_prefix = '/home/kayandeveloper/tacotron/logs-tacotron/model.ckpt-4200'
export_dir = os.path.join('/home/kayandeveloper/tacotron/', '0')
graph = tf.Graph()
with tf.compat.v1.Session(graph=graph) as sess:
# Restore from checkpoint
loader = tf.compat.v1.train.import_meta_graph(trained_checkpoint_prefix + '.meta')
loader.restore(sess, trained_checkpoint_prefix)
# Export checkpoint to SavedModel
builder = tf.compat.v1.saved_model.builder.SavedModelBuilder(export_dir)
builder.add_meta_graph_and_variables(sess,
[tf.saved_model.TRAINING, tf.saved_model.SERVING],
strip_default_attrs=True)
builder.save()
Code that I use to convert pb file to tflight
import tensorflow as tf
# Convert the model
converter = tf.lite.TFLiteConverter.from_keras_model_file('/home/kayandeveloper/tacotron/0') # path to the SavedModel directory
tflite_model = converter.convert()
# Save the model.
with open('/home/kayandeveloper/tacotron/araby.tflite', 'wb') as f:
f.write(tflite_model)
Error log :
2022-02-20 10:30:43.207065: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:983] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2022-02-20 10:30:43.207567: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1639] Found device 0 with properties:
name: Tesla T4 major: 7 minor: 5 memoryClockRate(GHz): 1.59
pciBusID: 0000:00:04.0
2022-02-20 10:30:43.207651: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.11.0
2022-02-20 10:30:43.207699: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcublas.so.11
2022-02-20 10:30:43.207722: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcufft.so.10
2022-02-20 10:30:43.207742: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcurand.so.10
2022-02-20 10:30:43.207761: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusolver.so.10
2022-02-20 10:30:43.207789: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusparse.so.11
2022-02-20 10:30:43.207810: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudnn.so.8
2022-02-20 10:30:43.207912: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:983] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2022-02-20 10:30:43.208728: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:983] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2022-02-20 10:30:43.209109: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1767] Adding visible gpu devices: 0
2022-02-20 10:30:43.209168: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1180] Device interconnect StreamExecutor with strength 1 edge matrix:
2022-02-20 10:30:43.209181: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1186] 0
2022-02-20 10:30:43.209190: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1199] 0: N
2022-02-20 10:30:43.209328: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:983] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2022-02-20 10:30:43.209784: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:983] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2022-02-20 10:30:43.210145: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1325] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 14160 MB memory) -> physical GPU (device: 0, name: Tesla T4, pci bus id: 0000:00:04.0, compute capability: 7.5)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/tmp/ipykernel_27138/2295115983.py in <module>
2
3 # Convert the model
----> 4 converter = tf.lite.TFLiteConverter.from_keras_model_file('/home/kayandeveloper/tacotron/0') # path to the SavedModel directory
5 tflite_model = converter.convert()
6
/opt/conda/lib/python3.7/site-packages/tensorflow_core/lite/python/lite.py in from_keras_model_file(cls, model_file, input_arrays, input_shapes, output_arrays, custom_objects)
825 input_tensors = _get_tensors_from_tensor_names(sess.graph, input_arrays)
826 else:
--> 827 input_tensors = keras_model.inputs
828
829 if output_arrays:
AttributeError: 'AutoTrackable' object has no attribute 'inputs'
Solution 1:[1]
try to replace the : ( keras_model.inputs )
with : ( keras_model.Input )
capital i ( I )
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mr Dream |
