better error parsing

This commit is contained in:
aliabd 2020-06-29 13:37:43 -07:00
parent 5cc19c283a
commit a04aca35f4

View File

@ -115,13 +115,18 @@ class Interface:
else: else:
try: try:
prediction = predict_fn(*processed_input, self.context) prediction = predict_fn(*processed_input, self.context)
except ValueError: except ValueError as exception:
print("It looks like you might be " if str(exception).endswith("is not an element "
"using tensorflow < 2.0. Please pass " "of this graph."):
"capture_session=True in Interface to avoid " print("It looks like you might be "
"a 'Tensor is not an element of this graph.' " "using tensorflow < 2.0. Please pass "
"error.") "capture_session=True in Interface to avoid "
prediction = predict_fn(*processed_input, self.context) "the 'Tensor is not an element of this "
"graph.' "
"error.")
prediction = predict_fn(*processed_input)
else:
prediction = predict_fn(*processed_input)
else: else:
if self.capture_session: if self.capture_session:
graph, sess = self.session graph, sess = self.session
@ -131,13 +136,17 @@ class Interface:
else: else:
try: try:
prediction = predict_fn(*processed_input) prediction = predict_fn(*processed_input)
except ValueError: except ValueError as exception:
print("It looks like you might be " if str(exception).endswith("is not an element "
"of this graph."):
print("It looks like you might be "
"using tensorflow < 2.0. Please pass " "using tensorflow < 2.0. Please pass "
"capture_session=True in Interface to avoid " "capture_session=True in Interface to avoid "
"a 'Tensor is not an element of this graph.' " "the 'Tensor is not an element of this graph.' "
"error.") "error.")
prediction = predict_fn(*processed_input) prediction = predict_fn(*processed_input)
else:
prediction = predict_fn(*processed_input)
if len(self.output_interfaces) / \ if len(self.output_interfaces) / \
len(self.predict) == 1: len(self.predict) == 1: