本文整理匯總了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)