當前位置: 首頁>>代碼示例>>Python>>正文


Python augmentations.SSDAugmentation方法代碼示例

本文整理匯總了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 
開發者ID:qijiezhao,項目名稱:pytorch-ssd,代碼行數:16,代碼來源:train.py

示例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 
開發者ID:MaliParag,項目名稱:ScanSSD,代碼行數:49,代碼來源:train.py


注:本文中的utils.augmentations.SSDAugmentation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。