[英]Tensorflow pretrained model import error
I am working on an object detection model in tensorflow. 我正在研究tensorflow中的对象检测模型。 I have a file model.py
: 我有一个文件model.py
:
from PIL import Image
import cv2
import numpy as np
import tensorflow as tf
from .squeezenet import SqueezeNet
save_path = "sqnet/squeezenet.ckpt"
sess = tf.Session()
model = SqueezeNet(save_path=save_path, sess=sess)
class Finder(object):
def __init__(self, image_path):
self.image_path = image_path
def predict(self):
image = process(self.image_path)
ans = sess.run(model.classifier, feed_dict={model.image:
image})
return ans
def process(path):
image = Image.open(path)
# image.show()
image = np.array(image)
image = cv2.resize(image, dsize=(224, 224),
interpolation=cv2.INTER_CUBIC)
image = image.reshape((1, 224, 224, 3))
#print(image.shape)
#img = Image.fromarray(image, 'RGB')
return image
image_path = "/home/jatin/ai.jpeg"
object_detector = Finder(image_path)
ans = object_detector.predict()
print(np.argmax(ans))
sess.close()
I have a folder named sqnet
alongside the model.py
file within which I have squuezenet.cpkt
file. 我在model.py
文件旁边有一个名为sqnet
的文件夹,其中有squuezenet.cpkt
文件。 But running this gives the error: 但是运行此命令会出现错误:
InvalidArgumentError (see above for traceback): Unsuccessful TensorSliceReader constructor: Failed to get matching files on sqnet/squeezenet.ckpt: Not found: sqnet; InvalidArgumentError(请参见上面的回溯):TensorSliceReader构造函数失败:无法在sqnet / squeezenet.ckpt上获取匹配文件:找不到:sqnet; No such file or directory. 没有相应的文件和目录。
What could be the issue? 可能是什么问题?
Seems like a simple IO error to me. 对我来说似乎是一个简单的IO错误。 Have you tried using absolute path? 您是否尝试过使用绝对路径?
save_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'sqnet', 'squeezenet.ckpt')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.