You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have trained a .pb model which is in tf1.2 and I want to use it in the environment of tf2.0, but I fail to use it successfully. Anyone knows how to solve the problem?
#7508
Closed
Govan111 opened this issue
Aug 29, 2019
· 1 comment
from future import division
from future import print_function
try:
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
except (ImportError, AttributeError):
import tensorflow as tf
import tensorflow as tf
import numpy as np
import os
with tf.Graph().as_default():
output_graph_def = tf.GraphDef()
with open('./myModel.pb', "rb") as f:
output_graph_def.ParseFromString(f.read())
tf.import_graph_def(output_graph_def, name="")
gpu_options = tf.GPUOptions(
per_process_gpu_memory_fraction=self.gpu_memory_fraction,
visible_device_list=self.visible_device_list,
allow_growth=self.allow_growth)
tfconfig = tf.ConfigProto(gpu_options=gpu_options, allow_soft_placement=False)
tfconfig.gpu_options.allow_growth = True
with tf.Session(config=tfconfig) as sess:
sess.run(tf.global_variables_initializer())
input_photo = sess.graph.get_tensor_by_name('placeholder/photo:0')
output_photo = sess.graph.get_tensor_by_name('decoder/Sigmoid:0')
################################## erros are as follows:
Traceback (most recent call last):
File "/Users/govan/Project/test.py", line 31, in call
output_graph_def = tf.GraphDef()
AttributeError: module 'tensorflow' has no attribute 'GraphDef'
The text was updated successfully, but these errors were encountered:
from future import division
from future import print_function
try:
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
except (ImportError, AttributeError):
import tensorflow as tf
import tensorflow as tf
import numpy as np
import os
with tf.Graph().as_default():
################################## erros are as follows:
Traceback (most recent call last):
File "/Users/govan/Project/test.py", line 31, in call
output_graph_def = tf.GraphDef()
AttributeError: module 'tensorflow' has no attribute 'GraphDef'
The text was updated successfully, but these errors were encountered: