1
votes

ModuleNotFoundError: No module named inference

I tried pip install inference and the installation was successful, but the same error still occurs.

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: No module named inference

1
Did you do pip install inference? or did you try pip3 install inference? - Mike
Are you using python 2 or 3? - drum
He's on python 3 considering the print has parenthesis @drum Edit: Never mind this isn't actually a certainty since its technically optional in 2.7 - Mike

1 Answers

0
votes

Looking the files of the package at https://pypi.org/project/inference/0.1/#files, the installation packages doesn't seem to have any actual source code using that module name.