diff --git a/tfjs-converter/python/tensorflowjs/converters/keras_h5_conversion_test.py b/tfjs-converter/python/tensorflowjs/converters/keras_h5_conversion_test.py index 2c002c6bbdd..4c5fa0b2671 100644 --- a/tfjs-converter/python/tensorflowjs/converters/keras_h5_conversion_test.py +++ b/tfjs-converter/python/tensorflowjs/converters/keras_h5_conversion_test.py @@ -24,6 +24,7 @@ import shutil import tempfile import unittest +import six import h5py import numpy as np @@ -169,7 +170,10 @@ def testConvertMergedModelFromSimpleModelNoSplitByLayer(self): model = tf.keras.models.Model(inputs=[input_tensor], outputs=[output]) h5_path = os.path.join(self._tmp_dir, 'MyModelMerged.h5') model.save(h5_path) - config_json = json.loads(model.to_json(), encoding='utf8') + if six.PY3: + config_json = json.loads(model.to_json()) + else: + config_json = json.loads(model.to_json(), encoding='utf8') # Load the saved weights as a JSON string. out, groups = conversion.h5_merged_saved_model_to_tfjs_format( @@ -215,7 +219,10 @@ def testConvertMergedModelFromSimpleModelSplitByLayer(self): model = tf.keras.models.Model(inputs=[input_tensor], outputs=[output]) h5_path = os.path.join(self._tmp_dir, 'MyModelMerged.h5') model.save(h5_path) - config_json = json.loads(model.to_json(), encoding='utf8') + if six.PY3: + config_json = json.loads(model.to_json()) + else: + config_json = json.loads(model.to_json(), encoding='utf8') # Load the saved weights as a JSON string. out, groups = conversion.h5_merged_saved_model_to_tfjs_format(