Skip to content

Commit 2ee6e54

Browse files
committed
better error messages
1 parent 6131c95 commit 2ee6e54

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

examples/benchmark_tfmodel_ort.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import numpy
77
from tqdm import tqdm
88
import tensorflow_hub as hub
9-
import tf2onnx
109
import onnxruntime as ort
1110

1211

tests/run_pretrained_models.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,11 @@ benchtf-gru:
117117
##
118118

119119
esrgan-tf2:
120+
# FIXME: fails because of google.protobuf.message.DecodeError: Error parsing message
121+
disabled: true
120122
# url: https://tfhub.dev/captain-pool/esrgan-tf2/1/esrgan-tf2_1.tar.gz
121123
url: https://github.com/captain-pool/GSOC/releases/download/1.0.0/esrgan.tar.gz
122-
model: fixme
124+
model: saved_model.pb
123125
input_get: get_beach
124126
inputs:
125127
"input_0:0": [1, 50, 50, 3]

tf2onnx/tf_loader.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,17 @@ def from_graphdef(model_path, input_names, output_names):
168168
with tf_session() as sess:
169169
graph_def = tf_graphdef()
170170
with tf_gfile.GFile(model_path, 'rb') as f:
171-
graph_def.ParseFromString(f.read())
171+
try:
172+
content = f.read()
173+
except UnicodeDecodeError as e:
174+
raise OSError(
175+
"Unable to load file '{}'.".format(model_path)) from e
176+
try:
177+
graph_def.ParseFromString(content)
178+
except Exception as e:
179+
print(content[:100])
180+
raise RuntimeError(
181+
"Unable to parse file '{}'.".format(model_path)) from e
172182
tf.import_graph_def(graph_def, name='')
173183
input_names = inputs_without_resource(sess, input_names)
174184
frozen_graph = freeze_session(sess, input_names=input_names, output_names=output_names)

0 commit comments

Comments
 (0)