ModuleNotFoundError:没有名为“推理”的模块

时间:2019-08-29 03:37:47

标签: python python-3.x python-2.7

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

的模块

1 个答案:

答案 0 :(得分:0)

https://pypi.org/project/inference/0.1/#files中查看软件包的文件,安装软件包似乎没有使用该模块名称的实际源代码。