@@ -44,15 +44,15 @@ The downloaded zip file contains a model.pb and a labels.txt. These files repres
44
44
import tensorflow as tf
45
45
import os
46
46
47
- graph_def = tf.GraphDef()
47
+ graph_def = tf.compat.v1. GraphDef()
48
48
labels = []
49
49
50
50
# These are set to the default names from exported models, update as needed.
51
51
filename = " model.pb"
52
52
labels_filename = " labels.txt"
53
53
54
54
# Import the TF graph
55
- with tf.gfile.GFile(filename, ' rb' ) as f:
55
+ with tf.io. gfile.GFile(filename, ' rb' ) as f:
56
56
graph_def.ParseFromString(f.read())
57
57
tf.import_graph_def(graph_def, name = ' ' )
58
58
@@ -112,7 +112,7 @@ augmented_image = resize_to_256_square(max_square_image)
112
112
113
113
``` Python
114
114
# Get the input size of the model
115
- with tf.Session() as sess:
115
+ with tf.compat.v1. Session() as sess:
116
116
input_tensor_shape = sess.graph.get_tensor_by_name(' Placeholder:0' ).shape.as_list()
117
117
network_input_size = input_tensor_shape[1 ]
118
118
@@ -176,7 +176,7 @@ Once the image is prepared as a tensor, we can send it through the model for a p
176
176
output_layer = ' loss:0'
177
177
input_node = ' Placeholder:0'
178
178
179
- with tf.Session() as sess:
179
+ with tf.compat.v1. Session() as sess:
180
180
try :
181
181
prob_tensor = sess.graph.get_tensor_by_name(output_layer)
182
182
predictions, = sess.run(prob_tensor, {input_node: [augmented_image] })
0 commit comments