Пример #1
0
def get_transform_fun(resized=False):
    if resized == True:
        transform_function = et.ExtCompose([
            et.ExtRandomCrop(size=2048),
            et.ExtRandomCrop(scale=0.7, size=None),
            et.ExtEnhanceContrast(),
            et.ExtRandomCrop(size=2048, pad_if_needed=True),
            et.ExtResize(scale=0.5),
            et.ExtRandomHorizontalFlip(p=0.5),
            et.ExtRandomCrop(size=512),
            et.ExtRandomVerticalFlip(p=0.5),
            et.ExtToTensor()
        ])
    else:
        transform_function = et.ExtCompose([
            et.ExtRandomCrop(size=256),
            et.ExtRandomHorizontalFlip(p=0.5),
            et.ExtRandomVerticalFlip(p=0.5),
            et.ExtEnhanceContrast(),
            et.ExtToTensor()
        ])
    return transform_function
Пример #2
0
    file_names_train = file_names_train[file_names_train != ".DS_S"]

    file_names_val = np.array([
        image_name[:-4] for image_name in os.listdir(path_val)
        if image_name[-5] != "k"
    ])
    N_files = len(file_names_val)
    shuffled_index = np.random.permutation(len(file_names_val))
    file_names_val = file_names_val[shuffled_index]
    file_names_val = file_names_val[file_names_val != ".DS_S"]

    # #FOR EXTENDED DATASET EXPERIMENT
    transform_function = et.ExtCompose([
        et.ExtRandomHorizontalFlip(p=0.5),
        et.ExtRandomCrop(size=SIZE),
        et.ExtEnhanceContrast(),
        et.ExtRandomVerticalFlip(p=0.5),
        et.ExtToTensor(),
        et.ExtNormalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
    ])

    if binary:
        color_dict = data_loader.color_dict_binary
        target_dict = data_loader.get_target_dict()
        annotations_dict = data_loader.annotations_dict

    train_dst = LeatherData(path_mask=path_train,
                            path_img=path_train,
                            list_of_filenames=file_names_train,
                            transform=transform_function,
                            color_dict=color_dict,
Пример #3
0
        device = torch.device('cpu')
        cpu_device = torch.device('cpu')

        model_name = 'resnet50'
        path_original_data = r'C:\Users\johan\OneDrive\Skrivebord\leather_patches'
        path_meta_data = r'samples/model_comparison.csv'
        optim = "SGD"
        tif_path = r'C:\Users\johan\iCloudDrive\DTU\KID\BA\HPC\TIF\good_area1.png'
        save_path = r'C:\Users\johan\iCloudDrive\DTU\KID\BA\HPC\last_round\predictions\vda4'
        resize = False
        if resize:
            patch_size = 512
        else:
            path_size = 256

    transform_function = et.ExtCompose([et.ExtEnhanceContrast(),
                                        et.ExtToTensor()])

    print("Device: %s" % device)
    print("Exp: ", exp)
    if brevetti:
        print("REDHALF")
    else:
        print("WALKNAPPA")
    data_loader = DataLoader(data_path=path_original_data,
                             metadata_path=path_meta_data)

    array = load_tif_as_numpy_array(tif_path)
    print("Shape array: ", np.shape(array))

    if resize == True:
Пример #4
0
        cpu_device = torch.device('cpu')

        model_name = 'resnet50'
        path_original_data = r'C:\Users\johan\OneDrive\Skrivebord\leather_patches'
        path_meta_data = r'samples/model_comparison.csv'
        optim = "SGD"
        tif_path = r'C:\Users\johan\iCloudDrive\DTU\KID\BA\HPC\TIF\good_area1.png'
        save_path = r'C:\Users\johan\iCloudDrive\DTU\KID\BA\HPC\last_round\predictions\vda4'
        resize = False
        if resize:
            patch_size = 512
        else:
            path_size = 256

    transform_function = et.ExtCompose(
        [et.ExtEnhanceContrast(), et.ExtToTensor()])

    print("Device: %s" % device)
    print("Exp: ", exp)
    if brevetti:
        print("REDHALF")
    else:
        print("WALKNAPPA")
    data_loader = DataLoader(data_path=path_original_data,
                             metadata_path=path_meta_data)

    array = load_tif_as_numpy_array(tif_path)
    print("Shape array: ", np.shape(array))

    if resize == True:
        resize_function = et.ExtCompose([et.ExtResize(scale=0.5)])