AnandInguva commented on code in PR #27186:
URL: https://github.com/apache/beam/pull/27186#discussion_r1237090993
##########
sdks/python/apache_beam/ml/inference/tensorflow_inference.py:
##########
@@ -56,7 +56,15 @@ class ModelType(enum.Enum):
def _load_model(model_uri, custom_weights, load_model_args):
- model = tf.keras.models.load_model(hub.resolve(model_uri), **load_model_args)
+ try:
+ model = tf.keras.models.load_model(
+ hub.resolve(model_uri), **load_model_args)
+ except Exception as e:
+ raise ValueError(
+ "Unable to load the TensorFlow model: {exception}. Make sure you've \
+ saved the model with TF2 format. Check out the list of TF2 Models on \
+ TensorFlow Hub -
https://tfhub.dev/s?subtype=module,placeholder&tf-version=tf2." # pylint:
disable=line-too-long
+ .format(exception=e))
Review Comment:
Can we use f-strings instead of format? also can we remove the `\` at the
end?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]