本文整理匯總了Python中utils.augmentations.SSDAugmentation方法的典型用法代碼示例。如果您正苦於以下問題:Python augmentations.SSDAugmentation方法的具體用法?Python augmentations.SSDAugmentation怎麽用?Python augmentations.SSDAugmentation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類utils.augmentations
的用法示例。
在下文中一共展示了augmentations.SSDAugmentation方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: DatasetSync
# 需要導入模塊: from utils import augmentations [as 別名]
# 或者: from utils.augmentations import SSDAugmentation [as 別名]
def DatasetSync(dataset='VOC',split='training'):
if dataset=='VOC':
#DataRoot=os.path.join(args.data_root,'VOCdevkit')
DataRoot=args.data_root
dataset = VOCDetection(DataRoot, train_sets, SSDAugmentation(
args.dim, means), AnnotationTransform())
elif dataset=='kitti':
DataRoot=os.path.join(args.data_root,'kitti')
dataset = KittiLoader(DataRoot, split=split,img_size=(1000,300),
transforms=SSDAugmentation((1000,300),means),
target_transform=AnnotationTransform_kitti())
return dataset
示例2: validate
# 需要導入模塊: from utils import augmentations [as 別名]
# 或者: from utils.augmentations import SSDAugmentation [as 別名]
def validate(args, net, criterion, cfg):
validation_batch_size = 1
try:
# Turn off learning. Go to testing phase
net.eval()
dataset = GTDBDetection(args, args.validation_data, split='validate',
transform=SSDAugmentation(cfg['min_dim'], mean=MEANS))
data_loader = data.DataLoader(dataset, validation_batch_size,
num_workers=args.num_workers,
shuffle=False, collate_fn=detection_collate,
pin_memory=True)
total = len(dataset)
done = 0
loc_loss = 0
conf_loss = 0
start = time.time()
for batch_idx, (images, targets, ids) in enumerate(data_loader):
done = done + len(images)
logging.debug('processing {}/{}'.format(done, total))
if args.cuda:
images = images.cuda()
targets = [ann.cuda() for ann in targets]
else:
images = Variable(images)
targets = [Variable(ann, volatile=True) for ann in targets]
y = net(images) # forward pass
loss_l, loss_c = criterion(y, targets)
loc_loss += loss_l.item() # data[0]
conf_loss += loss_c.item() # data[0]
end = time.time()
logging.debug('Time taken for validation ' + str(datetime.timedelta(seconds=end - start)))
return (loc_loss + conf_loss) / (total/validation_batch_size)
except Exception as e:
logging.error("Could not validate", exc_info=True)
return 0