Skip to content

Commit 1d642f9

Browse files
committed
better style
Signed-off-by: xavier dupré <[email protected]>
1 parent d9abc4c commit 1d642f9

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

examples/end2end_tfhub.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,26 @@
77
"""
88
from onnxruntime import InferenceSession
99
import os
10+
import sys
1011
import subprocess
1112
import timeit
1213
import numpy as np
1314
import tensorflow as tf
1415
from tensorflow import keras
15-
from tensorflow.keras import layers, Input
16-
from tensorflow.python.saved_model import tag_constants
17-
import tensorflow_hub as tfhub
16+
from tensorflow.keras import Input
17+
try:
18+
import tensorflow_hub as tfhub
19+
except ImportError:
20+
# no tensorflow_hub
21+
print("tensorflow_hub not installed.")
22+
sys.exit(0)
1823

1924
########################################
2025
# Downloads the model.
2126
hub_layer = tfhub.KerasLayer(
2227
"https://tfhub.dev/google/efficientnet/b0/classification/1")
2328
model = keras.Sequential()
24-
model.add(tf.keras.Input(shape=(224, 224, 3), dtype=tf.float32))
29+
model.add(Input(shape=(224, 224, 3), dtype=tf.float32))
2530
model.add(hub_layer)
2631
print(model.summary())
2732

examples/end2end_tfkeras.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
import tensorflow as tf
1414
from tensorflow import keras
1515
from tensorflow.keras import layers, Input
16-
from tensorflow.python.saved_model import tag_constants
17-
from tensorflow.python.tools import freeze_graph
1816

1917
########################################
2018
# Creates the model.

0 commit comments

Comments
 (0)