本文整理汇总了Python中utility.Utility.get_patch方法的典型用法代码示例。如果您正苦于以下问题:Python Utility.get_patch方法的具体用法?Python Utility.get_patch怎么用?Python Utility.get_patch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utility.Utility
的用法示例。
在下文中一共展示了Utility.get_patch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: classify
# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import get_patch [as 别名]
def classify(self, image, mean=None, std=None):
#imSize = (1024,1024)
imSize = np.shape(image)
print 'imSize:', imSize
image = Utility.pad_image( image, self.patchSize )
imSizePadded = np.shape(image)
print 'mlp.classify mean:', mean, 'std:', std
start_time = time.clock()
row_range = 1
#imSize = np.shape(image)
#membraneProbabilities = np.zeros(np.shape(image))
membraneProbabilities = np.zeros(imSize)
patchSize = np.int(np.sqrt(self.hiddenLayers[0].W.eval().shape[0]))
print 'imSize:', imSize
print 'imSizePadded:', imSizePadded
print 'mp:', np.shape(membraneProbabilities)
data_shared = shared_single_dataset(np.zeros((imSize[0]*row_range,patchSize**2)), borrow=True)
classify = theano.function(
[],
self.p_y_given_x,
givens={self.x: data_shared}
)
for row in xrange(0,1024,row_range):
if row%100 == 0:
print row
#data = Utility.get_patch(image, row, row_range, patchSize )
#print 'data shape:', data.shape
'''
data = Utility.generate_patch_data_rows(
image,
rowOffset=row,
rowRange=row_range,
patchSize=patchSize,
imSize=imSizePadded,
data_mean=mean,
data_std=std)
'''
data = Utility.get_patch(
image,
row,
row_range,
patchSize,
data_mean=mean,
data_std=std)
#print 'data:', np.shape(data)
data_shared.set_value(np.float32(data))
result = classify()
#print 'results:', np.shape(result)
membraneProbabilities[row,:] = result[:,0]
end_time = time.clock()
total_time = (end_time - start_time)
print >> sys.stderr, ('Running time: ' +
'%.2fm' % (total_time / 60.))
return np.array(membraneProbabilities)