<jupyter_start><jupyter_text>Minimal model<jupyter_code>root_model_path = Path("/data/students_home/fmameli/repos/Artifact_Removal_GAN/models/")
exported_model_minimal  =Path("/data/students_home/fmameli/repos/Artifact_Removal_GAN/models/minimal.pkl")
testFrameList = ImageImageList.from_folder(path/'DIV2K_train_LR_512_QF20', presort=True)
learn_min = load_learner(path=root_model_path, file=exported_model_minimal, test=testFrameList[:24], tfm_y=False)
learn_min.data.batch_size = 2
i = 803
id_img = str(i).zfill(4)

img_low = open_image("dataset/DIV2K_train_LR_512_QF20/" + id_img + ".jpg")
%%timeit -n 1 -r 100
p,img_hr,b = learn_min.predict(img_low)
%%timeit -n 1 -r 4
p = learn_min.get_preds(ds_type=DatasetType.Test)<jupyter_output><empty_output><jupyter_text>Standard GAN model<jupyter_code>root_model_path = Path("/data/students_home/fmameli/repos/Artifact_Removal_GAN/models/")
exported_model_standard =Path("/data/students_home/fmameli/repos/Artifact_Removal_GAN/models/standard.pkl")
testFrameList = ImageImageList.from_folder(path/'DIV2K_train_LR_512_QF20', presort=True)
learn_std = load_learner(path=root_model_path, file=exported_model_standard, test=testFrameList[:24], tfm_y=False)
learn_std.data.batch_size = 2
%%timeit -n 1 -r 100
p,img_hr,b = learn_std.predict(img_low)
%%timeit -n 1 -r 4
p = learn_std.get_preds(ds_type=DatasetType.Test)<jupyter_output><empty_output><jupyter_text>Image processing<jupyter_code>def toEven(sz):
    tempSz = [sz[0], sz[1]]
    if sz[0]%2 != 0:
        tempSz[0] += 1
    if sz[1]%2 != 0:
        tempSz[1] += 1
    return tempSz
weights = "/data/students_home/fmameli/repos/SuperRes/models/unet_wideNf2_superRes_mobilenetV3_GAN_best"
learn_gen.load(weights, with_opt=False)

for i in range(1, 901):
    id_img = str(i).zfill(4)

    img_low = open_image("dataset/DIV2K_train_LR_1024_QF20/" + id_img + ".jpg")
    size=toEven(img_low.size)
    data_gen = get_DIV2k_data_QF(path_lowRes_Full, path_fullRes, bs=bs, sz=size)

    learn_gen.data = data_gen
    
    p,img_hr,b = learn_gen.predict(img_low)
    p.save("output_imgs/" + id_img + "_GAN.png")
    print("dataset/DIV2K_train_LR_1024_QF20/" + id_img + ".jpg")
weights = "/data/students_home/fmameli/repos/SuperRes/models/unet_superRes_mobilenetV3_MSE_gen_512px_2"
learn_gen.load(weights, with_opt=False)

for i in range(1, 901):
    id_img = str(i).zfill(4)

    img_low = open_image("dataset/DIV2K_train_LR_1024_QF20/" + id_img + ".jpg")
    size=toEven(img_low.size)
    data_gen = get_DIV2k_data_QF(path_lowRes_Full, path_fullRes, bs=bs, sz=size)

    learn_gen.data = data_gen
    
    p,img_hr,b = learn_gen.predict(img_low)
    p.save("output_imgs/" + id_img + "_MSE.png")
    print("dataset/DIV2K_train_LR_1024_QF20/" + id_img + ".jpg")
weights = "/data/students_home/fmameli/repos/SuperRes/models/unet_superRes_mobilenetV3_SSIM_gen_512px_0"
learn_gen.load(weights, with_opt=False)

for i in range(1, 901):
    id_img = str(i).zfill(4)

    img_low = open_image("dataset/DIV2K_train_LR_1024_QF20/" + id_img + ".jpg")
    size=toEven(img_low.size)
    data_gen = get_DIV2k_data_QF(path_lowRes_Full, path_fullRes, bs=bs, sz=size)

    learn_gen.data = data_gen
    
    p,img_hr,b = learn_gen.predict(img_low)
    p.save("output_imgs/" + id_img + "_SSIM.png")
    print("dataset/DIV2K_train_LR_1024_QF20/" + id_img + ".jpg")
weights = "/data/students_home/fmameli/repos/SuperRes/models/unet_wideNf2_superRes_mobilenetV3_GAN_best"
learn_gen.load(weights, with_opt=False)

p_gan,img_hr,b = learn_gen.predict(img_low)
p_gan
weights = "/data/students_home/fmameli/repos/SuperRes/models/unet_superRes_mobilenetV3_MSE_gen_512px_2"
learn_gen.load(weights, with_opt=False)

p_mse,img_hr,b = learn_gen.predict(img_low)
p_mse
weights = "/data/students_home/fmameli/repos/SuperRes/models/unet_superRes_mobilenetV3_SSIM_gen_512px_0"
learn_gen.load(weights, with_opt=False)

p_ssim,img_hr,b = learn_gen.predict(img_low)
p_ssim<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13043478260869565, 'fraction_numerical': 0.034378159757330634, 'mean_word_length': 6.01595744680851, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '248872', 'license': 'MIT', 'n_tokens_mistral': 1800, 'n_tokens_neox': 1670, 'n_words': 197, 'path': 'Inference_unet_generated_imgs.ipynb', 'repo_name': 'goldenbili/ARTIFACT_TEST', 'size': '3956'}