# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# + _uuid="8f2839f25d086af736a60e9eeb907d3b93b6e0e5" _cell_guid="b1076dfc-b9ad-4769-8c92-a6c4dae69d19"
# This Python 3 environment comes with many helpful analytics libraries installed
# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python
# For example, here's several helpful packages to load

# import numpy as np # linear algebra
# import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

# # Input data files are available in the read-only "../input/" directory
# # For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory

# import os
# for dirname, _, filenames in os.walk('/kaggle/input'):
#     for filename in filenames:
#         print(os.path.join(dirname, filename))

# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using "Save & Run All" 
# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session
# -

# !pip install sewar

# +
## Load all the necessary packages

# %matplotlib inline

import matplotlib.pyplot as plt
import skimage.transform
from skimage import data, io, filters
import numpy as np
from numpy import array
from skimage.transform import rescale, resize
from skimage.transform import resize
import os
import PIL
import pandas as pd
import imageio
import sewar


from matplotlib.pyplot import imread
import cv2


# +
## Load Directory Paths

def load_path(path):
    directories = []
    if os.path.isdir(path):
        print('directory path: ', path)
        directories.append(path)
    for elem in os.listdir(path): #check for nested dir within parent dir
        if os.path.isdir(os.path.join(path,elem)):
            print('inside nested dir')
            directories = directories + load_path(os.path.join(path,elem))
            directories.append(os.path.join(path,elem))
    print('directories: ', directories)
    return directories


# +
## Load Images from directory

def load_data_from_dirs(dirs, ext):
    files = []
    file_names = []
    count = 0
    res = {}
    
    for d in dirs:
        for f in os.listdir(d):
            if f.endswith(ext):
                image = cv2.imread(os.path.join(d,f))
                files.append(image)
                file_names.append(os.path.join(d,f))
                count = count + 1
                res[int(os.path.join(d,f)[40:-4])] = image
    
    print('list of files: ',len(files))
    print('list of files path: ', len(file_names), 'file path: ', file_names[0])
    print('Files Read: ',count)
    
    return res   


# +
## Load Images

def load_data(directory, ext):
    files = load_data_from_dirs(load_path(directory), ext)
    return files


# -

## Load HR Images from the directory
print(len('../input/tumorsrcnn/hr_tumor_imgs/'))
hr_tumor_files = load_data("../input/tumorsrcnn/hr_tumor_imgs/", ".png")

from collections import OrderedDict
# sorted(test_list, key = int)
srt_hr_tumor_files = OrderedDict(sorted(hr_tumor_files.items()))

# +
## Convert each jpeg image to UMat format to apply polygon curve approximation in opencv2

hr_tumors = []
for i in range(1, len(srt_hr_tumor_files)):
    hr_tumors.append(cv2.cvtColor(cv2.UMat(srt_hr_tumor_files[i]), cv2.COLOR_RGB2GRAY))


# +
## Function to display UMat images

def displayImages(img_arr):    
    width=8
    height=8
    rows = 3
    cols = 4
    axes=[]

    fig=plt.figure(figsize=(10,10))

    for i in range(rows * cols):
        axes.append( fig.add_subplot(rows, cols, i+1) )
        subplot_title=("Image: "+str(i+1))
        axes[-1].set_title(subplot_title)  
        plt.imshow(img_arr[i].get().astype('f'), cmap='gray')
        plt.axis('off')
    fig.tight_layout()    
    plt.show()


# +
## Function to display numpy images of Tumor

def displayTumors(img_arr):    
    width=8
    height=8
    rows = 3
    cols = 4
    axes=[]

    fig=plt.figure(figsize=(10,10))

    for i in range(rows * cols):
        axes.append( fig.add_subplot(rows, cols, i+1) )
        subplot_title=("Image: "+str(i+1))
        axes[-1].set_title(subplot_title)  
        plt.imshow(img_arr[i].astype('float32').squeeze(), cmap='gray')
        plt.axis('off')
    fig.tight_layout()    
    plt.show()


# +
## Visualize few tumor images extracted using binary mask

displayImages(hr_tumors)

# +
## Extract Tumor regions with the help of contours

hr_tumor_regions = []
hr_contours_regions = []
for img in hr_tumors:
    
    ret, thresh = cv2.threshold(img,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
    contours, hierarchy = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
    
    ## get the biggest contour
    
    biggest_cntr = max(contours, key = cv2.contourArea)
    img_cpy = img.get().copy()
    
    ## Apply Polygon Curve approximation to extract out the tumor
    
    eps = 0.01 * cv2.arcLength(biggest_cntr, True)
    approx = cv2.approxPolyDP(biggest_cntr, eps, True)
    hr_contours_regions.append(cv2.drawContours(img_cpy, [approx],0,(255,0,0), 3))
    
    ## Bounding Rectangle
    (x,y,w,h) = cv2.boundingRect(biggest_cntr)

    ## Crop the tumor region
    
    hr_tumor_regions.append(img.get()[y:y+h, x:x+w])

# +
## Visualize tumor images with contour drawn on them

displayImages(hr_contours_regions)

# +
## Visualize extratced tumor regions

displayTumors(hr_tumor_regions)

# +
## Load SR Images from the directory

sr_tumor_files = load_data("../input/tumorsrcnn/sr_tumor_imgs/", ".png")
# -

from collections import OrderedDict
# sorted(test_list, key = int)
srt_sr_tumor_files = OrderedDict(sorted(hr_tumor_files.items()))

# +
## Convert each image to UMat in order to apply 

sr_tumors = []
for i in range(1, len(srt_sr_tumor_files)):
    sr_tumors.append(cv2.cvtColor(cv2.UMat(srt_sr_tumor_files[i]), cv2.COLOR_RGB2GRAY))
# -

# ### Display SR Tumor Images

# +
## Display SR Tumors

displayImages(sr_tumors)


# -

def img_normal(img1, img2):
    hr_img = img1.astype(np.uint16)
    sr_img = img2.astype(np.uint16)
    hr_img = 0.2*hr_img/255.
    sr_img = 0.1*sr_img/255.
    return hr_img, sr_img


# +
## Extract Tumor regions with the help of contours

sr_tumor_regions = []
sr_contours_regions = []
for img in sr_tumors:
    
    ret, thresh = cv2.threshold(img,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
    contours, hierarchy = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
    
    ## get the biggest contour
    
    biggest_cntr = max(contours, key = cv2.contourArea)
    img_cpy = img.get().copy()
    
    ## Apply Polygon Curve approximation to extract out the tumor
    
    eps = 0.01 * cv2.arcLength(biggest_cntr, True)
    approx = cv2.approxPolyDP(biggest_cntr, eps, True)
    sr_contours_regions.append(cv2.drawContours(img_cpy, [approx],0,(255,0,0), 3))
    
    ## Bounding Rectangle
    (x,y,w,h) = cv2.boundingRect(biggest_cntr)

    ## Crop the tumor region
    
    sr_tumor_regions.append(img.get()[y:y+h, x:x+w])
# -

# ### Display Contours on Tumor

displayImages(sr_contours_regions)

# ### Display Extracted Tumor Regions

displayTumors(sr_tumor_regions)

srcnn_tumor_metric = {}
srcnn_tumor_metric["tumor"] = {}
srcnn_tumor_metric["mannwhitneyu"] = {}

# ### Compute SSIM parameters individually and see the output



# ## Defining Constants C1 and C2 and C3
#
# ### C1 = (K1,L)
# ### C2 = (K2,L)
# ### C3 = C2/2
#
# ## L is the dynamic range for pixel values [How to decide Value of L?](https://scikit-image.org/docs/dev/user_guide/data_types.html)
#
# **Here K1 and K2 are constant values very very close to 0** 

C1 = (0.01 * 65535) ** 2 
C2 = (0.03 * 65535) ** 2
C3 = C2/2


def luminance(img1, img2):
    mu1 = img1.mean()
    mu2 = img2.mean()
    mu1_sqr = mu1 ** 2
    mu2_sqr = mu2 ** 2
    L = (2*mu1*mu2 + C1) / (2*(mu1_sqr + mu2_sqr) + C1)
    return L


def contrast(img1, img2):
    sigma1 = img1.std()
    sigma2 = img2.std()
    sigma1_sqr = sigma1 ** 2
    sigma2_sqr = sigma2 ** 2
    C = (2*sigma1*sigma2 + C2) / (2*(sigma1_sqr + sigma2_sqr) + C2)
    return C


def structure(img1, img2):
    C3 = C2/2
    sigma1 = img1.std()
    sigma2 = img2.std()
    sigma12 = np.cov(img1, img2)[0,1]
    S = (sigma12 + C3) / (2*sigma1*sigma2 + C3) 
    return S


def compute_ssim(sr_img, hr_img):
    
    sr_img = sr_img.astype(np.uint16)
    hr_img = hr_img.astype(np.uint16)
    
    img1 = np.array(list(filter(lambda pixel : pixel !=0, sr_img.flatten())))
    img2 = np.array(list(filter(lambda pixel : pixel !=0, hr_img.flatten())))
    
    ## Computing Luminance Comparison Function
    
    L = luminance(img1, img2)
    
    ## Computing Contrast Comparison Function
    
    C = contrast(img1, img2)
    
    ## Computing Structure Comparison Function
    
    S = structure(img1, img2)
    
    ## defining alpha, beta, gamma
    
    alpha, beta, gamma = 1, 1, 1

    ssim = (L ** alpha) * (C ** beta) ** (S ** gamma)
    
    return ssim


from skimage.metrics import structural_similarity as ssim

## Compute SSIM for single image
compute_ssim(sr_tumor_regions[22],hr_tumor_regions[22])

# +
ssim_arr = []
for sr_img, hr_img in zip(sr_tumor_regions,hr_tumor_regions):
    ssim_arr.append(compute_ssim(sr_img, hr_img))
    
## Display Results for starting 10 images

print(ssim_arr[:10])
# -

ssim_mean, ssim_std = np.mean(ssim_arr), np.std(ssim_arr)
srcnn_tumor_metric["tumor"]["ssim"] = ssim_arr
print("mean: ", ssim_mean, " std: ", ssim_std)


# ## Universal Quality Index (UQI)
#
# ### It is special case of SSIM when C1=0 and C2=0
#
# **NOTE: It produces unstable results when either (mu1_srq + mu2_srq) or (sigma1_sqr + sigma2_sqr) is close to 0**

# +
# def displayResults(img_arr1, img_arr2,ssim_arr, metric, dim=(1, 3), figsize=(15, 5)):    
#     width=8
#     height=8
#     rows = 5
#     cols = 5
#     axes=[]

#     fig=plt.figure(figsize=(10,10))

#     for i in range(rows * cols):
#         plt.figure(figsize=figsize)

#         plt.subplot(dim[0], dim[1], 1)
#         plt.imshow(img_arr1[i].squeeze(), interpolation='nearest', cmap='gray')
#         plt.title(f"Super Resolution Image Tumor {i+1}")
#         plt.axis('off')

#         plt.subplot(dim[0], dim[1], 2)
#         plt.imshow(img_arr2[i].squeeze(), interpolation='nearest', cmap='gray')
#         plt.title(f"Origial Image Tumor {i+1}")
#         plt.axis('off')
        
#         plt.subplot(dim[0], dim[1], 3)
#         plt.text(0.5, 0.5,f"{metric} {ssim_arr[i]}")
#         plt.axis('off')
        
#     fig.tight_layout()    
#     plt.show()
# -

# ## Display SSIM Results for starting 10 Images

# +
# displayResults(sr_tumor_regions, hr_tumor_regions, ssim_arr, "SSIM")
# -

# ## Mean Absolute Error

def MAE(true_img, pred_img):
    
    hr_img, sr_img = img_normal(true_img, pred_img)
    
    img1 = np.array(list(filter(lambda pixel : pixel !=0., sr_img.flatten())))
    img2 = np.array(list(filter(lambda pixel : pixel !=0., hr_img.flatten())))
    metric = (np.sum(np.absolute(np.subtract(img1, img2)))) / len(img1)
    return metric


MAE(hr_tumor_regions[0], sr_tumor_regions[0])

mae_arr=[]
for img1, img2 in zip(hr_tumor_regions, sr_tumor_regions):
    mae_arr.append(MAE(img1, img2))
print(mae_arr[:10])

mae_mean, mae_std = np.mean(mae_arr), np.std(mae_arr)
srcnn_tumor_metric["tumor"]["mae"] = mae_arr
print("mean: ", mae_mean, " std: ", mae_std)


# ## Mean Percentage Error

def MPE(true_img, pred_img):
    
    hr_img, sr_img = img_normal(true_img, pred_img)
    
    img1 = np.array(list(filter(lambda pixel : pixel !=0, hr_img.flatten())))
    img2 = np.array(list(filter(lambda pixel : pixel !=0., sr_img.flatten())))
    metric = np.sum((img1 - img2)) / len(img1)
    return metric * 100


MPE(hr_tumor_regions[0], sr_tumor_regions[0])

mpe_arr=[]
for img1, img2 in zip(hr_tumor_regions, sr_tumor_regions):
    mpe_arr.append(MPE(img1, img2))
print(mpe_arr[:10])

mpe_mean, mpe_std = np.mean(mpe_arr), np.std(mpe_arr)
srcnn_tumor_metric["tumor"]["mpe"] = mpe_arr
print("mean: ", mpe_mean, " std: ", mpe_std)


def hr_normal(img):
    hr_img = img.astype(np.uint16)
    hr_img = 0.2*hr_img/255.
    return hr_img


def sr_normal(img):
    sr_img = img.astype(np.uint16)
    sr_img = 0.1*sr_img/255.
    return sr_img


# +
n_hr_tumor_regions = []
for img in hr_tumor_regions:
    n_hr_tumor_regions.append(hr_normal(img))
    
n_sr_tumor_regions = []
for img in sr_tumor_regions:
    n_sr_tumor_regions.append(sr_normal(img))
# -

# ### Mean Square Error (MSE)

ans = sewar.full_ref.mse(n_hr_tumor_regions[9], n_sr_tumor_regions[9])
print(ans, type(ans))

# +
mse_arr = []
for img1, img2 in zip(n_hr_tumor_regions, n_sr_tumor_regions):
    mse_arr.append(sewar.full_ref.mse(img1, img2))
    
## Display Results for starting 10 images

print(mse_arr[:10])
# -

mse_mean, mse_std = np.mean(mse_arr), np.std(mse_arr)
srcnn_tumor_metric["tumor"]["mse"] = mse_arr
print("mean: ", mse_mean, " std: ", mse_std)

# ### Root Mean Square Error (RMSE)

ans = sewar.full_ref.rmse(n_hr_tumor_regions[9], n_sr_tumor_regions[9])
print(ans, type(ans))

# +
rmse_arr = []
for img1, img2 in zip(n_hr_tumor_regions, n_sr_tumor_regions):
    rmse_arr.append(sewar.full_ref.rmse(img1, img2))
    
## Display Results for starting 10 images

print(rmse_arr[:10])
# -

rmse_mean, rmse_std = np.mean(rmse_arr), np.std(rmse_arr)
srcnn_tumor_metric["tumor"]["rmse"] = rmse_arr
print("mean: ", rmse_mean, " std: ", rmse_std)

# ## PSNR

from skimage.metrics import peak_signal_noise_ratio as psnr

ans = psnr(n_hr_tumor_regions[4], n_sr_tumor_regions[4])
print(ans, type(ans))

# +
psnr_arr = []
for img1, img2 in zip(n_hr_tumor_regions, n_sr_tumor_regions):
    psnr_arr.append(psnr(img1, img2))
    
## Display Results for starting 10 images
print(psnr_arr[:10])
# -

psnr_mean, psnr_std = np.mean(psnr_arr), np.std(psnr_arr)
srcnn_tumor_metric["tumor"]["psnr"] = psnr_arr
print("mean: ", psnr_mean, " std: ", psnr_std)

# ## Multi-Scale Structural Similarity Index (MS-SSIM)

ans = sewar.full_ref.msssim(hr_tumor_regions[2].astype(np.uint16), sr_tumor_regions[2].astype(np.uint16)).real
print(ans, type(ans))

msssim_arr = []
for img1, img2 in zip(hr_tumor_regions, sr_tumor_regions):
#     msssim_arr.append(sewar.full_ref.scc(img1, img2))
    try:
        msssim_arr.append(sewar.full_ref.msssim(img1.astype(np.uint16), img2.astype(np.uint16)).real)
    except:
        continue
## Display Results for starting 10 images
print(msssim_arr[:10])

msssim_mean, msssim_std = np.mean(msssim_arr), np.std(msssim_arr)
srcnn_tumor_metric["tumor"]["msssim"] = msssim_arr
print("mean: ", msssim_mean,  " std: ", msssim_std)

# ### Spatial Corelation Coefficient (SCC)

ans = sewar.full_ref.scc(n_hr_tumor_regions[3], n_sr_tumor_regions[3])
print(ans, type(ans))

# +
scc_arr = []
for img1, img2 in zip(n_hr_tumor_regions, n_sr_tumor_regions):
    scc_arr.append(sewar.full_ref.scc(img1, img2))
    
## Display Results for starting 10 images

print(scc_arr[:10])
# -

scc_mean, scc_std = np.mean(scc_arr), np.std(scc_arr)
srcnn_tumor_metric["tumor"]["scc"] = scc_arr
print("mean: ", scc_mean,  " std: ", scc_std)

# ### Pixel Based Visual Information Fidelity (vif-p)

ans = sewar.full_ref.vifp(n_hr_tumor_regions[5], n_sr_tumor_regions[5])
print(ans, type(ans))

# +
vifp_arr = []
for img1, img2 in zip(n_hr_tumor_regions, n_sr_tumor_regions):
#     vifp_arr.append(sewar.full_ref.scc(img1, img2))
    try:
        vifp_arr.append(sewar.full_ref.vifp(img1, img2))
    except:
        continue
    
## Display Results for starting 10 images

print(vifp_arr[:10])
# -

vifp_mean, vifp_std = np.mean(vifp_arr), np.std(vifp_arr)
srcnn_tumor_metric["tumor"]["vifp"] = vifp_arr
print("mean: ", vifp_mean,  " std: ", vifp_std)

# +
# os.mkdir('./tumor')

# +
# os.mkdir('./tumor/error_barplot')
# os.mkdir('./tumor/scatter')
# os.mkdir('./tumor/regression')

# +
# ## Define error bar plot function

# def error_barplot(error_arr,title='', file_name=''):
    
#     # Calculate the average
#     error_mean = np.mean(error_arr)
    
#     # Calculate the standard deviation
#     error_std = np.std(error_arr)

#     # Define labels, positions, bar heights and error bar heights
#     labels = ['For 200 Images']
#     x_pos = np.arange(len(labels))
#     CTEs = [error_mean]
#     error = [error_std]
    
#     # Build the plot
#     fig, ax = plt.subplots(figsize=(5,5))
#     ax.bar(x_pos, CTEs,yerr=error,align='center',alpha=0.5,ecolor='black',capsize=10)
# #     ax.set_ylabel('Mean Percentage Error')
#     ax.set_xticks(x_pos)
#     ax.set_xticklabels(labels)
#     ax.set_title(title)
#     ax.yaxis.grid(True)
    
#     plt.savefig(f"./tumor/error_barplot/{file_name}.png")

#     # Save the figure and show
#     plt.tight_layout()
#     # plt.savefig('bar_plot_with_error_bars.png')
#     plt.show()

# +
# error_barplot(mae_arr,title='Mean Absolute Error (MAE)', file_name='mae_barplot')

# +
# error_barplot(mpe_arr,title='Mean Percentage Error (MPE)', file_name='mpe_barplot')

# +
# error_barplot(mse_arr,title='Mean Square Error (MSE)', file_name='mse_barplot')

# +
# error_barplot(rmse_arr,title='Root Mean Square Error (RMSE)', file_name='rmse_barplot')

# +
# error_barplot(psnr_arr,title='Peak Signal to Noise Ratio (PSNR)', file_name='psnr_barplot')

# +
# error_barplot(ssim_arr,title='Structural Similarity Index (SSIM)', file_name='ssim_barplot')

# +
# error_barplot(scc_arr,title='Spatial Corelation Coefficient (SCC)', file_name='scc_barplot')

# +
# error_barplot(vifp_arr,title='Pixel Based Visual Information Fidelity (vif-p)', file_name='vifp_barplot')
# -

# ## Scatter Plot for MAE, MPE, MSE, RMSE, PSNR, SSIM, MS-SSIM, SCC and VIF-P

# +
# import seaborn as sns
# sns.set_theme(style="whitegrid")
# sns.set(rc={'figure.figsize':(8,8)})

# +
# metric_dict = {'Images': [i for i in range(1,199)],
#             'MAE' : mae_arr,
#             'MPE' : mpe_arr,
#             'MSE' : mse_arr,
#             'RMSE' : rmse_arr,
#             'PSNR' : psnr_arr,
#             'SSIM' : ssim_arr,
#             'SCC' : scc_arr,
#             'VIFP' : vifp_arr
#          }
# metric_df = pd.DataFrame(metric_dict)

# +
# def getScatterPlot(y_val,df,title='', file_name=''):
    
#     sns_plt = sns.scatterplot(x=metric_df.Images, y=y_val, data=df, linewidth=2.5).set_title(title)
#     sns_fig = sns_plt.get_figure()
#     sns_fig.savefig(f"./tumor/scatter/{file_name}.png")

# +
# def RegPlot(y_val,df,title='', file_name=''):
    
#     sns_plt = sns.regplot(x=metric_df.Images, y=y_val, data=df).set_title(title)
#     sns_fig = sns_plt.get_figure()
#     sns_fig.savefig(f"./tumor/regression/{file_name}.png")

# +
# getScatterPlot(metric_df.MAE, metric_df, 'Mean Absolute Error', 'mae_scatter')

# +
# getScatterPlot(metric_df.MPE, metric_df, title='Mean Percentage Error', file_name='mpe_scatter')

# +
# getScatterPlot(metric_df.MSE, metric_df, title='Mean Square Error', file_name='mse_scatter')

# +
# getScatterPlot(metric_df.RMSE, metric_df, title='Root Mean Square Error', file_name='rmse_scatter')

# +
# getScatterPlot(metric_df.PSNR, metric_df, title='Peak Signal to Noise Ratio', file_name='psnr_scatter')

# +
# getScatterPlot(metric_df.SSIM, metric_df, title='Structure Similarity Index', file_name='ssim_scatter')

# +
# getScatterPlot(metric_df.SCC, metric_df, title='Spatial Corelation Coefficient', file_name='scc_scatter')

# +
# getScatterPlot(metric_df.VIFP, metric_df, title='Pixel Based Visual Information Fidelity', file_name='vifp_scatter')
# -

# ## Regression Plot for MAE, MPE, MSE, RMSE, PSNR, SSIM, MS-SSIM, SCC and VIF-P

# +
# RegPlot(metric_df.MAE, metric_df, 'Mean Absolute Error', 'mae_scatter')

# +
# RegPlot(metric_df.MPE, metric_df, title='Mean Percentage Error', file_name='mpe_scatter')

# +
# RegPlot(metric_df.MSE, metric_df, title='Mean Square Error', file_name='mse_scatter')

# +
# RegPlot(metric_df.RMSE, metric_df, title='Root Mean Square Error', file_name='rmse_scatter')

# +
# RegPlot(metric_df.PSNR, metric_df, title='Peak Signal to Noise Ratio', file_name='psnr_scatter')

# +
# RegPlot(metric_df.SSIM, metric_df, title='Structure Similarity Index', file_name='ssim_scatter')

# +
# RegPlot(metric_df.SCC, metric_df, title='Spatial Corelation Coefficient', file_name='scc_scatter')

# +
# RegPlot(metric_df.VIFP, metric_df, title='Pixel Based Visual Information Fidelity', file_name='vifp_scatter')

# +
import pickle

with open('./srcnn_tumor_pickle.pkl', 'wb') as f:
    pickle.dump(srcnn_tumor_metric, f)

# +
%%!

zip srcnn_tumor_metric.zip ./srcnn_tumor_pickle.pkl
# -





StarcoderdataJupyterScriptsDedupFiltered