ModuleNotFoundError::没有名为inference
我尝试了pip安装推断并且安装成功,但是仍然发生相同的错误。
import tensorflow as tf
import inference
image_size = 128
MODEL_SAVE_PATH = "model/"
MODEL_NAME = "model.ckpt"
image_data = tf.gfile.FastGFile("./data/test/d.png", 'rb').read()
decode_image = tf.image.decode_png(image_data, 1)
decode_image = tf.image.convert_image_dtype(decode_image, tf.float32)
image = tf.reshape(decode_image, [-1, image_size, image_size, 1])
test_logit = inference.inference(image, train=False, regularizer=None)
probabilities = tf.nn.softmax(test_logit)
correct_prediction = tf.argmax(test_logit, 1)
saver = tf.train.Saver()
with tf.Session() as sess:
sess.run((tf.global_variables_initializer(),
tf.local_variables_initializer()))
ckpt = tf.train.get_checkpoint_state(MODEL_SAVE_PATH)
if ckpt and ckpt.model_checkpoint_path:
saver.restore(sess, ckpt.model_checkpoint_path)
print("Loading the model successfully:" + ckpt.model_checkpoint_path)
global_step = ckpt.model_checkpoint_path.split('/')[-1].split('-')[-1]
probabilities, label = sess.run([probabilities, correct_prediction])
probability = probabilities[0][label]
print("After %s training step(s),validation label = %d, has %g probability" % (global_step, label, probability))
else:
print("Model loading failed!" + ckpt.model_checkpoint_path)
ModuleNotFoundError::没有名为inference