예제 #1
0
    ####################################################################################################################
    # build results for od-centered with OD model
    print('* Instantiating model {}, pretrained={}'.format(
        model_name, pretrained))
    model, mean, std = get_arch(model_name,
                                pretrained=pretrained,
                                n_classes=n_classes)

    model, stats = load_model(model, load_path_od, device='cpu')
    model = model.to(device)
    print("Total params: {0:,}".format(
        sum(p.numel() for p in model.parameters() if p.requires_grad)))
    print('* Creating Dataloaders, batch size = {:d}'.format(bs))
    test_loader = get_test_loader(csv_path_test=csv_test_od,
                                  batch_size=bs,
                                  mean=mean,
                                  std=std)

    if tta:
        probs_od, preds_od, labels = test_cls_tta_dihedral(model,
                                                           test_loader,
                                                           n=3)
    else:
        probs_od, preds_od, labels = test_cls(model, test_loader)
    df_od = pd.DataFrame(zip(list(test_loader.dataset.im_list), preds_od),
                         columns=['image_id', 'preds'])
    ####################################################################################################################
    # build results for macula-centered with MAC model
    print('* Instantiating model {}, pretrained={}'.format(
        model_name, pretrained))
    model, mean, std = get_arch(model_name,
예제 #2
0
    # build results for MT model
    n_classes = 18
    print('* Instantiating MT model {}, pretrained={}'.format(
        model_name_MT, pretrained))
    model, mean, std = get_arch(model_name_MT,
                                pretrained=pretrained,
                                n_classes=n_classes)

    model, stats = load_model(model, load_path_MT, device='cpu')
    model = model.to(device)
    print("Total params: {0:,}".format(
        sum(p.numel() for p in model.parameters() if p.requires_grad)))
    print('* Creating Dataloaders, batch size = {:d}'.format(bs))
    test_loader = get_test_loader(csv_path_test=csv_test_q_MT,
                                  batch_size=bs,
                                  mean=mean,
                                  std=std,
                                  qualities=True)

    probs_tta_q, preds_tta_q, probs_tta_a, preds_tta_a, probs_tta_c, preds_tta_c, probs_tta_f, preds_tta_f \
        = test_cls_tta_dihedral_MT(model, test_loader, n=3)

    ####################################################################################################################
    # build results for QUALITY model
    n_classes = 2
    print('* Instantiating QUALITY model {}, pretrained={}'.format(
        model_name_quality, pretrained))
    model, mean, std = get_arch(model_name_quality,
                                pretrained=pretrained,
                                n_classes=n_classes)