本文整理汇总了Python中chainer.links.caffe.CaffeFunction方法的典型用法代码示例。如果您正苦于以下问题:Python caffe.CaffeFunction方法的具体用法?Python caffe.CaffeFunction怎么用?Python caffe.CaffeFunction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chainer.links.caffe
的用法示例。
在下文中一共展示了caffe.CaffeFunction方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_i2v_with_chainer
# 需要导入模块: from chainer.links import caffe [as 别名]
# 或者: from chainer.links.caffe import CaffeFunction [as 别名]
def make_i2v_with_chainer(param_path, tag_path=None, threshold_path=None):
# ignore UserWarnings from chainer
with warnings.catch_warnings():
warnings.simplefilter('ignore')
net = CaffeFunction(param_path)
kwargs = {}
if tag_path is not None:
tags = json.loads(open(tag_path, 'r').read())
assert(len(tags) == 1539)
kwargs['tags'] = tags
if threshold_path is not None:
fscore_threshold = np.load(threshold_path)['threshold']
kwargs['threshold'] = fscore_threshold
return ChainerI2V(net, **kwargs)
示例2: LoadCaffeModel
# 需要导入模块: from chainer.links import caffe [as 别名]
# 或者: from chainer.links.caffe import CaffeFunction [as 别名]
def LoadCaffeModel(path):
print("Loading %s"%path)
root, ext = os.path.splitext(path)
cachepath = 'cache/'+hashlib.sha224(root.encode('utf-8')).hexdigest()+".pkl"
if path in __Model_cache:
print("Cache hit")
func = __Model_cache[path]
if os.path.exists(cachepath):
func = pickle.load(open(cachepath,'rb'))
else:
print("Converting from %s"%path)
#func = caffe.CaffeFunction('misc/'+path)
func = CaffeFunction('misc/'+path)
pickle.dump(func, open(cachepath, 'wb'))
__Model_cache[path]=func
if Deel.gpu>=0:
func = func.to_gpu(Deel.gpu)
return func
示例3: load
# 需要导入模块: from chainer.links import caffe [as 别名]
# 或者: from chainer.links.caffe import CaffeFunction [as 别名]
def load(self, path):
root, ext = os.path.splitext(path)
if ext == '.pkl':
with open(path, 'rb') as f:
self.func = pickle.load(f)
else:
self.func = caffe.CaffeFunction(path)
示例4: init_func
# 需要导入模块: from chainer.links import caffe [as 别名]
# 或者: from chainer.links.caffe import CaffeFunction [as 别名]
def init_func(self):
self.func = caffe.CaffeFunction(self.temp_file_path)