class config:
    dataset_name = 'COCO'
    network = 'resnet50_retinanet'
    pretrained = False
    num_classes = 80
    input_image_size = 800

    model = retinanet.__dict__[network](**{
        'pretrained': pretrained,
        'num_classes': num_classes,
    })

    decoder = RetinaDecoder()

    val_dataset = CocoDetection(COCO2017_path,
                                set_name='val2017',
                                transform=transforms.Compose([
                                    Normalize(),
                                    RetinaStyleResize(
                                        resize=input_image_size,
                                        multi_scale=False,
                                        multi_scale_range=[0.8, 1.0]),
                                ]))

    seed = 0
    batch_size = 16
    num_workers = 16
    trained_model_path = 'detection_training/coco/retinanet_res50_resize800_multi_ciou/checkpoints/resnet50_retinanet-epoch12-mAP0.355.pth'
class config:
    dataset_name = 'COCO'
    network = 'resnet50_fcos'
    pretrained = False
    num_classes = 80
    input_image_size = 800

    model = fcos.__dict__[network](**{
        'pretrained': pretrained,
        'num_classes': num_classes,
    })

    decoder = FCOSDecoder()

    val_dataset = CocoDetection(COCO2017_path,
                                set_name='val2017',
                                transform=transforms.Compose([
                                    Normalize(),
                                    RetinaStyleResize(
                                        resize=input_image_size,
                                        multi_scale=False,
                                        multi_scale_range=[0.8, 1.0]),
                                ]))

    seed = 0
    # when testing,using nn.DataParallel mode,batch_size is total size
    batch_size = 16
    num_workers = 16
    trained_model_path = 'detection_training/coco/fcos_res50_resize800_multi_ciou/checkpoints/resnet50_fcos-epoch12-mAP0.37735844188817935.pth'
示例#3
0
class config:
    dataset_name = 'COCO'
    network = 'resnet18_centernet'
    pretrained = False
    num_classes = 80
    input_image_size = 512

    model = centernet.__dict__[network](**{
        'pretrained': pretrained,
        'num_classes': num_classes,
    })

    decoder = CenterNetDecoder()

    val_dataset = CocoDetection(COCO2017_path,
                                set_name='val2017',
                                transform=transforms.Compose([
                                    Normalize(),
                                    YoloStyleResize(
                                        resize=input_image_size,
                                        multi_scale=False,
                                        multi_scale_range=[0.6, 1.4]),
                                ]))

    seed = 0
    batch_size = 64
    num_workers = 16
    trained_model_path = ''
示例#4
0
class config:
    dataset_name = 'COCO'
    network = 'yolov3'
    pretrained = False
    num_classes = 80
    input_image_size = 416

    model = yolov3.__dict__[network](**{
        'pretrained':
        pretrained,
        'anchor_sizes': [[10, 13], [16, 30], [33, 23], [30, 61], [62, 45],
                         [59, 119], [116, 90], [156, 198], [373, 326]],
        'strides': [8, 16, 32],
        'num_classes':
        num_classes,
    })

    decoder = Yolov4Decoder()

    val_dataset = CocoDetection(COCO2017_path,
                                set_name='val2017',
                                transform=transforms.Compose([
                                    Normalize(),
                                    YoloStyleResize(
                                        resize=input_image_size,
                                        multi_scale=False,
                                        multi_scale_range=[0.8, 1.0]),
                                ]))

    seed = 0
    batch_size = 64
    num_workers = 16
    trained_model_path = ''
示例#5
0
class config:
    dataset_name = 'COCO'
    network = 'resnet50_fcos'
    pretrained = False
    num_classes = 80
    input_image_size = 400

    model = fcos.__dict__[network](**{
        'pretrained': pretrained,
        'num_classes': num_classes,
    })

    criterion = FCOSLoss(box_loss_iou_type='CIoU', box_loss_weight=1.)
    decoder = FCOSDecoder()

    train_dataset = CocoDetection(COCO2017_path,
                                  set_name='train2017',
                                  transform=transforms.Compose([
                                      RandomHorizontalFlip(flip_prob=0.5),
                                      Normalize(),
                                      RetinaStyleResize(
                                          resize=input_image_size,
                                          multi_scale=True,
                                          multi_scale_range=[0.8, 1.0]),
                                  ]))

    val_dataset = CocoDetection(COCO2017_path,
                                set_name='val2017',
                                transform=transforms.Compose([
                                    Normalize(),
                                    RetinaStyleResize(
                                        resize=input_image_size,
                                        multi_scale=False,
                                        multi_scale_range=[0.8, 1.0]),
                                ]))

    seed = 0
    # batch_size is total size in DataParallel mode
    # batch_size is per gpu node size in DistributedDataParallel mode
    batch_size = 16
    num_workers = 16

    # choose 'SGD' or 'AdamW'
    optimizer = 'AdamW'
    # 'AdamW' doesn't need gamma and momentum variable
    gamma = 0.1
    momentum = 0.9
    # choose 'MultiStepLR' or 'CosineLR'
    # milestones only use in 'MultiStepLR'
    scheduler = 'MultiStepLR'
    lr = 1e-4
    weight_decay = 1e-3
    milestones = [8, 11]
    warm_up_epochs = 0

    epochs = 12
    eval_epoch = [1, 3, 5, 8, 11, 12]
    print_interval = 100

    # only in DistributedDataParallel mode can use sync_bn
    distributed = True
    sync_bn = False
    apex = True
示例#6
0
class config:
    dataset_name = 'COCO'
    network = 'resnet18_centernet'
    pretrained = False
    num_classes = 80
    input_image_size = 512

    model = centernet.__dict__[network](**{
        'pretrained': pretrained,
        'num_classes': num_classes,
    })

    criterion = CenterNetLoss()
    decoder = CenterNetDecoder()

    train_dataset = CocoDetection(COCO2017_path,
                                  set_name='train2017',
                                  transform=transforms.Compose([
                                      RandomHorizontalFlip(flip_prob=0.5),
                                      Normalize(),
                                      YoloStyleResize(
                                          resize=input_image_size,
                                          multi_scale=True,
                                          multi_scale_range=[0.6, 1.4]),
                                  ]))

    val_dataset = CocoDetection(COCO2017_path,
                                set_name='val2017',
                                transform=transforms.Compose([
                                    Normalize(),
                                    YoloStyleResize(
                                        resize=input_image_size,
                                        multi_scale=False,
                                        multi_scale_range=[0.6, 1.4]),
                                ]))

    seed = 0
    # batch_size is total size in DataParallel mode
    # batch_size is per gpu node size in DistributedDataParallel mode
    batch_size = 64
    num_workers = 16

    # choose 'SGD' or 'AdamW'
    optimizer = 'AdamW'
    # 'AdamW' doesn't need gamma and momentum variable
    gamma = 0.1
    momentum = 0.9
    # choose 'MultiStepLR' or 'CosineLR'
    # milestones only use in 'MultiStepLR'
    scheduler = 'MultiStepLR'
    lr = 1e-4
    weight_decay = 1e-3
    milestones = [90, 120]
    warm_up_epochs = 0

    epochs = 140
    eval_epoch = [i * 5 for i in range(epochs // 5)]
    print_interval = 100

    # only in DistributedDataParallel mode can use sync_bn
    distributed = True
    sync_bn = False
    apex = True
class config:
    dataset_name = 'COCO'
    network = 'yolov4'
    pretrained = False
    num_classes = 80
    input_image_size = 416

    model = yolov4.__dict__[network](**{
        'pretrained':
        pretrained,
        'anchor_sizes': [[10, 13], [16, 30], [33, 23], [30, 61], [62, 45],
                         [59, 119], [116, 90], [156, 198], [373, 326]],
        'strides': [8, 16, 32],
        'num_classes':
        num_classes,
    })

    criterion = Yolov4Loss(
        anchor_sizes=[[10, 13], [16, 30], [33, 23], [30, 61], [62, 45],
                      [59, 119], [116, 90], [156, 198], [373, 326]],
        strides=[8, 16, 32],
    )
    decoder = Yolov4Decoder()

    train_dataset = CocoDetection(COCO2017_path,
                                  set_name='train2017',
                                  transform=transforms.Compose([
                                      RandomHorizontalFlip(flip_prob=0.5),
                                      Normalize(),
                                      YoloStyleResize(
                                          resize=input_image_size,
                                          multi_scale=True,
                                          multi_scale_range=[0.8, 1.0]),
                                  ]))

    val_dataset = CocoDetection(COCO2017_path,
                                set_name='val2017',
                                transform=transforms.Compose([
                                    Normalize(),
                                    YoloStyleResize(
                                        resize=input_image_size,
                                        multi_scale=False,
                                        multi_scale_range=[0.8, 1.0]),
                                ]))

    seed = 0
    # batch_size is total size in DataParallel mode
    # batch_size is per gpu node size in DistributedDataParallel mode
    batch_size = 32
    num_workers = 16

    # choose 'SGD' or 'AdamW'
    optimizer = 'AdamW'
    # 'AdamW' doesn't need gamma and momentum variable
    gamma = 0.1
    momentum = 0.9
    # choose 'MultiStepLR' or 'CosineLR'
    # milestones only use in 'MultiStepLR'
    scheduler = 'MultiStepLR'
    lr = 1e-4
    weight_decay = 1e-3
    milestones = [60, 90]
    warm_up_epochs = 0

    epochs = 100
    eval_epoch = [1, 2, 3, 4, 5]
    print_interval = 10

    # only in DistributedDataParallel mode can use sync_bn
    distributed = True
    sync_bn = False
    apex = True
    BASE_DIR = os.path.dirname(
        os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
    sys.path.append(BASE_DIR)

    from tools.path import COCO2017_path, VOCdataset_path

    from tqdm import tqdm
    import torchvision.transforms as transforms
    from simpleAICV.datasets.cocodataset import CocoDetection
    from simpleAICV.datasets.vocdataset import VocDetection
    from simpleAICV.detection.common import RandomHorizontalFlip, RandomCrop, RandomTranslate, Normalize, YoloStyleResize, RetinaStyleResize, Collater

    coco = CocoDetection(
        COCO2017_path,
        set_name='train2017',
        transform=transforms.Compose([
            YoloStyleResize(resize=640),
            #RetinaStyleResize(resize=416),
        ]))

    voc = VocDetection(
        root_dir=VOCdataset_path,
        image_sets=[('2007', 'trainval'), ('2012', 'trainval')],
        transform=transforms.Compose([
            YoloStyleResize(resize=640),
            #RetinaStyleResize(resize=416),
        ]),
        keep_difficult=False)

    boxes_wh = []
    # for index in tqdm(range(len(voc))):