本文整理汇总了Python中detector.Detector.get_classmap方法的典型用法代码示例。如果您正苦于以下问题:Python Detector.get_classmap方法的具体用法?Python Detector.get_classmap怎么用?Python Detector.get_classmap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类detector.Detector
的用法示例。
在下文中一共展示了Detector.get_classmap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from detector import Detector [as 别名]
# 或者: from detector.Detector import get_classmap [as 别名]
def __init__(self, modelNb=3):
"""Load the tensorflow model of VGG16-GAP trained on caltech
Keyword arguments:
modelNb -- iteration of the model to consider
"""
dataset_path = '/home/cuda/datasets/perso_db/'
trainset_path = dataset_path+'train.pkl'
testset_path = dataset_path+'test.pkl'
weight_path = '../caffe_layers_value.pickle'
model_path = '../models/perso/model-'+str(modelNb)
# load labels
testset = pickle.load( open(testset_path, "rb") )
self.label_dict = testset.keys()
n_labels = len(self.label_dict)
# Initialize some tensorflow variables
batch_size = 1
self.images_tf = tf.placeholder( tf.float32, [None, 224, 224, 3], name="images")
self.labels_tf = tf.placeholder( tf.int64, [None], name='labels')
detector = Detector( weight_path, n_labels )
c1,c2,c3,c4,conv5, self.conv6, gap, self.output = detector.inference( self.images_tf )
self.classmap = detector.get_classmap( self.labels_tf, self.conv6 )
self.sess = tf.InteractiveSession()
saver = tf.train.Saver()
saver.restore( self.sess, model_path )
示例2: listdir
# 需要导入模块: from detector import Detector [as 别名]
# 或者: from detector.Detector import get_classmap [as 别名]
jpg_folder_path = "../img_test"
imgPath = [join(jpg_folder_path, f) for f in listdir(jpg_folder_path) if isfile(join(jpg_folder_path, f))]
# load the caltech model
f = open(model_label_path,"rb")
label_dict = pickle.load(f)
n_labels = len(label_dict)
batch_size = 1
images_tf = tf.placeholder( tf.float32, [None, 224, 224, 3], name="images")
labels_tf = tf.placeholder( tf.int64, [None], name='labels')
detector = Detector( weight_path, n_labels )
c1,c2,c3,c4,conv5, conv6, gap, output = detector.inference( images_tf )
classmap = detector.get_classmap( labels_tf, conv6 )
sess = tf.InteractiveSession()
saver = tf.train.Saver()
saver.restore( sess, model_path )
# Fast forward images & save them
for idx,imgP in enumerate(imgPath):
img = Image.open(imgP)
img = img.resize([224,224])
img = np.array(img)
img = img.reshape(1,224,224,3)
feed_dict = {}