本文整理匯總了Python中dataset.resizeNormalize方法的典型用法代碼示例。如果您正苦於以下問題:Python dataset.resizeNormalize方法的具體用法?Python dataset.resizeNormalize怎麽用?Python dataset.resizeNormalize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dataset
的用法示例。
在下文中一共展示了dataset.resizeNormalize方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: data_loader
# 需要導入模塊: import dataset [as 別名]
# 或者: from dataset import resizeNormalize [as 別名]
def data_loader():
# train
train_dataset = dataset.lmdbDataset(root=args.trainroot)
assert train_dataset
if not params.random_sample:
sampler = dataset.randomSequentialSampler(train_dataset, params.batchSize)
else:
sampler = None
train_loader = torch.utils.data.DataLoader(train_dataset, batch_size=params.batchSize, \
shuffle=True, sampler=sampler, num_workers=int(params.workers), \
collate_fn=dataset.alignCollate(imgH=params.imgH, imgW=params.imgW, keep_ratio=params.keep_ratio))
# val
val_dataset = dataset.lmdbDataset(root=args.valroot, transform=dataset.resizeNormalize((params.imgW, params.imgH)))
assert val_dataset
val_loader = torch.utils.data.DataLoader(val_dataset, shuffle=True, batch_size=params.batchSize, num_workers=int(params.workers))
return train_loader, val_loader
示例2: crnn_recognition
# 需要導入模塊: import dataset [as 別名]
# 或者: from dataset import resizeNormalize [as 別名]
def crnn_recognition(cropped_image, model):
converter = utils.strLabelConverter(alphabet)
image = cropped_image.convert('L')
##
# w = int(image.size[0] / (280 * 1.0 / 160))
transformer = dataset.resizeNormalize((280, 32))
image = transformer(image)
# if torch.cuda.is_available():
# image = image.cuda()
image = image.view(1, *image.size())
image = Variable(image)
model.eval()
preds = model(image)
_, preds = preds.max(2)
preds = preds.transpose(1, 0).contiguous().view(-1)
preds_size = Variable(torch.IntTensor([preds.size(0)]))
sim_pred = converter.decode(preds.data, preds_size.data, raw=False)
print('results: {0}'.format(sim_pred))
return sim_pred