Пример #1
0
def run_test_origin_images():
    result = []
    result_top5 = []
    model = "checkerboard"
    acc, acc_top5 = test_original_images(model)
    result.append(acc)
    result_top5.append(acc_top5)
    pickle_data(result, f"test_masked_images_result_{model}")
    pickle_data(result_top5, f"test_masked_images_result_top5_{model}")
    print(result)
    print(result_top5)
Пример #2
0
def run_test_masked_images():
    result = []
    result_top5 = []
    model = "vgg16"
    patch_sizes = [20, 30, 40, 50, 60, 70]
    for patch_size in patch_sizes:
        acc, acc_top5 = test_masked_images(patch_size, model)
        result.append(acc)
        result_top5.append(acc_top5)
    pickle_data(result, f"test_masked_images_result_{model}")
    pickle_data(result_top5, f"test_masked_images_result_top5_{model}")
    print(result)
    print(result_top5)
Пример #3
0
def get_corrcoef(patch_size: int, model: Any, model_name: str, generate_dataset: bool = False, generate_org: bool = False):
    """
    :param patch_size: size of the occlusion patch
    :param generate_dataset: set True if need to genereate the manipulated dataset (both combination and isolation)
    :param generate_org: set True to generate the pearson correlation for original images (without manipulation)
    :return: None
    """
    generator = MaskImageGenerator(DATASET, DESTINATION, model)
    if generate_dataset:
        generator.make_dataset(patch_size, combination=False, isolation=False, original=False)
    lhs = generator.calculate_lhs(patch_size)
    pickle_data(lhs, f'lhs_{model_name}_{patch_size}_new.pkl')
    rhs = generator.calculate_rhs(patch_size)
    pickle_data(rhs, f'rhs_{model_name}_{patch_size}_new.pkl')
    if generate_org:
        org = generator.calculate_org_logit()
        pickle_data(org, f'org_{model_name}_new.pkl')
Пример #4
0
def get_corrcoef_per_category_intact(model: Any, model_name: str):
    generator = ScrambleImageGenerator(DATASET_ORIGINAL, model)
    scramble = generator.calculate_intact_per_category()
    pickle_data(scramble, f"intact_per_category_{model_name}_new.pkl")
Пример #5
0
def get_corrcoef_per_category_scramble(block_size: int, model: Any,
                                       model_name: str):
    generator = ScrambleImageGenerator(DATASET_ORIGINAL, model)
    scramble = generator.calculate_scramble_per_category(block_size)
    pickle_data(scramble,
                f"scramble_per_category_{model_name}_{block_size}_new.pkl")
Пример #6
0
def get_corrcoef(block_size: int, model: Any, model_name: str):
    generator = ScrambleImageGenerator(DATASET_SIZE224, model)
    scramble = generator.calculate_scramble(block_size)
    pickle_data(scramble, f"scramble_{model_name}_{block_size}_new.pkl")