Skip to content

Commit 6fd63a2

Browse files
Merge pull request #40279 from madmuffin1/patch-1
Tensorflow 2.0 compatibility
2 parents 7efb2a6 + 3b33c78 commit 6fd63a2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

articles/cognitive-services/Custom-Vision-Service/export-model-python.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ The downloaded zip file contains a model.pb and a labels.txt. These files repres
4444
import tensorflow as tf
4545
import os
4646

47-
graph_def = tf.GraphDef()
47+
graph_def = tf.compat.v1.GraphDef()
4848
labels = []
4949

5050
# These are set to the default names from exported models, update as needed.
5151
filename = "model.pb"
5252
labels_filename = "labels.txt"
5353

5454
# Import the TF graph
55-
with tf.gfile.GFile(filename, 'rb') as f:
55+
with tf.io.gfile.GFile(filename, 'rb') as f:
5656
graph_def.ParseFromString(f.read())
5757
tf.import_graph_def(graph_def, name='')
5858

@@ -112,7 +112,7 @@ augmented_image = resize_to_256_square(max_square_image)
112112

113113
```Python
114114
# Get the input size of the model
115-
with tf.Session() as sess:
115+
with tf.compat.v1.Session() as sess:
116116
input_tensor_shape = sess.graph.get_tensor_by_name('Placeholder:0').shape.as_list()
117117
network_input_size = input_tensor_shape[1]
118118

@@ -176,7 +176,7 @@ Once the image is prepared as a tensor, we can send it through the model for a p
176176
output_layer = 'loss:0'
177177
input_node = 'Placeholder:0'
178178

179-
with tf.Session() as sess:
179+
with tf.compat.v1.Session() as sess:
180180
try:
181181
prob_tensor = sess.graph.get_tensor_by_name(output_layer)
182182
predictions, = sess.run(prob_tensor, {input_node: [augmented_image] })

0 commit comments

Comments
 (0)