当前位置: 首页>>代码示例>>Python>>正文


Python Detector.get_classmap方法代码示例

本文整理汇总了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 )
开发者ID:marc-moreaux,项目名称:Weakly_detector,代码行数:31,代码来源:forward_perso.py

示例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 = {}
开发者ID:marc-moreaux,项目名称:Weakly_detector,代码行数:33,代码来源:forward_image.py


注:本文中的detector.Detector.get_classmap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。