예제 #1
0
    model = model_.ResNet_pca(nclasses=args.n_classes)
elif args.model == 'lcnn_9':
    model = model_.lcnn_9layers(nclasses=args.n_classes)
elif args.model == 'lcnn_29':
    model = model_.lcnn_29layers_v2(nclasses=args.n_classes)
elif args.model == 'lcnn_9_pca':
    model = model_.lcnn_9layers_pca(nclasses=args.n_classes)
elif args.model == 'lcnn_29_pca':
    model = model_.lcnn_29layers_v2_pca(nclasses=args.n_classes)
elif args.model == 'lcnn_9_icqspec':
    model = model_.lcnn_9layers_icqspec(nclasses=args.n_classes)
elif args.model == 'lcnn_9_prodspec':
    model = model_.lcnn_9layers_prodspec(nclasses=args.n_classes)
elif args.model == 'lcnn_9_CC':
    model = model_.lcnn_9layers_CC(nclasses=args.n_classes,
                                   ncoef=args.ncoef,
                                   init_coef=args.init_coef)
elif args.model == 'lcnn_29_CC':
    model = model_.lcnn_29layers_CC(nclasses=args.n_classes,
                                    ncoef=args.ncoef,
                                    init_coef=args.init_coef)
elif args.model == 'resnet_CC':
    model = model_.ResNet_CC(nclasses=args.n_classes,
                             ncoef=args.ncoef,
                             init_coef=args.init_coef)

if args.pretrained_path is not None:
    ckpt = torch.load(args.pretrained_path,
                      map_location=lambda storage, loc: storage)

    try:
예제 #2
0
    elif args.model == 'resnet_pca':
        model = model_.ResNet_pca()
    elif args.model == 'lcnn_9':
        model = model_.lcnn_9layers()
    elif args.model == 'lcnn_29':
        model = model_.lcnn_29layers_v2()
    elif args.model == 'lcnn_9_pca':
        model = model_.lcnn_9layers_pca()
    elif args.model == 'lcnn_29_pca':
        model = model_.lcnn_29layers_v2_pca()
    elif args.model == 'lcnn_9_icqspec':
        model = model_.lcnn_9layers_icqspec()
    elif args.model == 'lcnn_9_prodspec':
        model = model_.lcnn_9layers_prodspec()
    elif args.model == 'lcnn_9_CC':
        model = model_.lcnn_9layers_CC(ncoef=args.ncoef,
                                       init_coef=args.init_coef)
    elif args.model == 'lcnn_29_CC':
        model = model_.lcnn_29layers_CC(ncoef=args.ncoef,
                                        init_coef=args.init_coef)
    elif args.model == 'resnet_34_CC':
        model = model_.ResNet_34_CC(ncoef=args.ncoef, init_coef=args.init_coef)

    print('Loading model')

    ckpt = torch.load(args.cp_path, map_location=lambda storage, loc: storage)
    model.load_state_dict(ckpt['model_state'], strict=True)
    model.eval()

    print('Model loaded')

    print('Loading data')
예제 #3
0
    elif args.model_la == 'resnet_pca':
        model_la = model_.ResNet_pca()
    elif args.model_la == 'lcnn_9':
        model_la = model_.lcnn_9layers()
    elif args.model_la == 'lcnn_29':
        model_la = model_.lcnn_29layers_v2()
    elif args.model_la == 'lcnn_9_pca':
        model_la = model_.lcnn_9layers_pca()
    elif args.model_la == 'lcnn_29_pca':
        model_la = model_.lcnn_29layers_v2_pca()
    elif args.model_la == 'lcnn_9_icqspec':
        model_la = model_.lcnn_9layers_icqspec()
    elif args.model_la == 'lcnn_9_prodspec':
        model_la = model_.lcnn_9layers_prodspec()
    elif args.model_la == 'lcnn_9_CC':
        model_la = model_.lcnn_9layers_CC(ncoef=args.ncoef_la)
    elif args.model_la == 'lcnn_29_CC':
        model_la = model_.lcnn_29layers_CC(ncoef=args.ncoef_la)
    elif args.model_la == 'resnet_CC':
        model_la = model_.ResNet_CC(ncoef=args.ncoef_la)

    if args.model_pa == 'lstm':
        model_pa = model_.cnn_lstm()
    elif args.model_pa == 'resnet':
        model_pa = model_.ResNet()
    elif args.model_pa == 'resnet_pca':
        model_pa = model_.ResNet_pca()
    elif args.model_pa == 'lcnn_9':
        model_pa = model_.lcnn_9layers()
    elif args.model_pa == 'lcnn_29':
        model_pa = model_.lcnn_29layers_v2()
예제 #4
0
if args.model == 'lcnn_29_pca' or args.model == 'all':
    batch = torch.rand(3, 1, 120, 300)
    model = model_.lcnn_29layers_v2_pca()
    mu = model.forward(batch)
    print('lcnn_29_pca', mu.size())
if args.model == 'lcnn_9_icqspec' or args.model == 'all':
    batch = torch.rand(3, 1, 256, 300)
    model = model_.lcnn_9layers_icqspec()
    mu = model.forward(batch)
    print('lcnn_9_icqspec', mu.size())
if args.model == 'lcnn_9_prodspec' or args.model == 'all':
    batch = torch.rand(3, 1, 257, 300)
    model = model_.lcnn_9layers_prodspec()
    mu = model.forward(batch)
    print('lcnn_9_prodspec', mu.size())
if args.model == 'lcnn_9_CC' or args.model == 'all':
    batch = torch.rand(3, 1, 90, 300)
    model = model_.lcnn_9layers_CC()
    mu = model.forward(batch)
    print('lcnn_9_CC', mu.size())
if args.model == 'lcnn_29_CC' or args.model == 'all':
    batch = torch.rand(3, 1, 90, 300)
    model = model_.lcnn_29layers_CC()
    mu = model.forward(batch)
    print('lcnn_29_CC', mu.size())
if args.model == 'resnet_34_CC' or args.model == 'all':
    batch = torch.rand(3, 1, 90, 300)
    model = model_.ResNet_34_CC()
    mu = model.forward(batch)
    print('resnet_34_CC', mu.size())