{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport tensorflow as tf\nfrom tensorflow import keras\nfrom tensorflow.keras import layers\nimport tensorflow_addons as tfa\nfrom tensorflow.keras.preprocessing.image import load_img\nfrom tensorflow.keras.preprocessing.image import img_to_array\nfrom random import random\nfrom random import sample\n\n\n\nfrom kaggle_datasets import KaggleDatasets\nimport matplotlib.pyplot as plt\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\n\n# 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\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-05-22T06:23:14.878857Z","iopub.execute_input":"2023-05-22T06:23:14.879183Z","iopub.status.idle":"2023-05-22T06:23:23.701003Z","shell.execute_reply.started":"2023-05-22T06:23:14.879152Z","shell.execute_reply":"2023-05-22T06:23:23.699891Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\nfor dirname, _, monet_filenames in os.walk('/kaggle/input/gan-getting-started/monet_jpg'):\n    print('Number of Monet Files:', len(monet_filenames))\nfor dirname, _, photo_filenames in os.walk('/kaggle/input/gan-getting-started/photo_jpg'):\n    print('Number of Photo Files:', len(photo_filenames))\n","metadata":{"execution":{"iopub.status.busy":"2023-05-22T06:23:23.703370Z","iopub.execute_input":"2023-05-22T06:23:23.704280Z","iopub.status.idle":"2023-05-22T06:23:29.570824Z","shell.execute_reply.started":"2023-05-22T06:23:23.704221Z","shell.execute_reply":"2023-05-22T06:23:29.569643Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# load all images in a directory into memory\nsample_num = 200\ndef load_sample_images(path, filenames, size=(256,256)):\n    data_list = list()\n    # get a sample of files\n    samples = sample(filenames, sample_num)\n    for filename in samples:\n        # load and resize the image\n        pixels = load_img(path + filename, target_size=size)\n        # convert to numpy array\n        pixels = img_to_array(pixels)\n        # store\n        data_list.append(pixels)\n\n    return np.asarray(data_list)","metadata":{"execution":{"iopub.status.busy":"2023-05-22T06:23:29.573364Z","iopub.execute_input":"2023-05-22T06:23:29.574058Z","iopub.status.idle":"2023-05-22T06:23:29.581837Z","shell.execute_reply.started":"2023-05-22T06:23:29.574015Z","shell.execute_reply":"2023-05-22T06:23:29.580646Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def load_images(path, filenames, size=(256,256)):\n    data_list = list()\n    for filename in filenames:\n        # load and resize the image\n        pixels = load_img(path + filename, target_size=size)\n        # convert to numpy array\n        pixels = img_to_array(pixels)\n        # store\n        data_list.append(pixels)\n\n    return np.asarray(data_list)","metadata":{"execution":{"iopub.status.busy":"2023-05-22T06:23:29.586280Z","iopub.execute_input":"2023-05-22T06:23:29.587043Z","iopub.status.idle":"2023-05-22T06:23:29.594759Z","shell.execute_reply.started":"2023-05-22T06:23:29.587013Z","shell.execute_reply":"2023-05-22T06:23:29.593533Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"path = '/kaggle/input/gan-getting-started/monet_jpg/'\ndata_monet = load_sample_images(path, monet_filenames)\nprint('Loaded data_monet: ', data_monet.shape)\npath = '/kaggle/input/gan-getting-started/photo_jpg/'\ndata_photo = load_sample_images(path, photo_filenames)\nprint('Loaded data_photo: ', data_photo.shape)\n\n","metadata":{"execution":{"iopub.status.busy":"2023-05-22T06:23:29.597178Z","iopub.execute_input":"2023-05-22T06:23:29.598070Z","iopub.status.idle":"2023-05-22T06:23:32.842843Z","shell.execute_reply.started":"2023-05-22T06:23:29.598031Z","shell.execute_reply":"2023-05-22T06:23:32.841809Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# plot monet images\nn_samples = 3\nfor i in range(n_samples):\n    plt.subplot(2, n_samples, 1 + i)\n    plt.axis('off')\n    plt.imshow(data_monet[i].astype('uint8'))\n# plot photo image\nfor i in range(n_samples):\n    plt.subplot(2, n_samples, 1 + n_samples + i)\n    plt.axis('off')\n    plt.imshow(data_photo[i].astype('uint8'))\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-05-22T06:23:32.847376Z","iopub.execute_input":"2023-05-22T06:23:32.849789Z","iopub.status.idle":"2023-05-22T06:23:33.292161Z","shell.execute_reply.started":"2023-05-22T06:23:32.849748Z","shell.execute_reply":"2023-05-22T06:23:33.291194Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#scale from [0,255] to [-1,1]\ndata_monet = (data_monet - 127.5) / 127.5\ndata_photo = (data_photo - 127.5) / 127.5","metadata":{"execution":{"iopub.status.busy":"2023-05-22T06:23:33.293341Z","iopub.execute_input":"2023-05-22T06:23:33.293686Z","iopub.status.idle":"2023-05-22T06:23:33.424997Z","shell.execute_reply.started":"2023-05-22T06:23:33.293652Z","shell.execute_reply":"2023-05-22T06:23:33.423926Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\n# define the discriminator model\ndef define_discriminator(image_shape):\n     # weight initialization\n    init = keras.initializers.RandomNormal(stddev = 0.02)\n    # source image input\n    in_image = keras.Input(shape = image_shape)\n    # C64\n    d = layers.Conv2D(64, (4,4), strides=(2,2), padding='same', kernel_initializer=init)(in_image)\n    d = layers.LeakyReLU(alpha=0.2)(d)\n    # C128\n    d = layers.Conv2D(128, (4,4), strides=(2,2), padding='same', kernel_initializer=init)(d)\n    d = tfa.layers.InstanceNormalization(axis=-1)(d)\n    d = layers.LeakyReLU(alpha=0.2)(d)\n    # C256\n    d = layers.Conv2D(256, (4,4), strides=(2,2), padding='same', kernel_initializer=init)(d)\n    d = tfa.layers.InstanceNormalization(axis=-1)(d)\n    d = layers.LeakyReLU(alpha=0.2)(d)\n    # C512\n    d = layers.Conv2D(512, (4,4), strides=(2,2), padding='same', kernel_initializer=init)(d)\n    d = tfa.layers.InstanceNormalization(axis=-1)(d)\n    d = layers.LeakyReLU(alpha=0.2)(d)\n    # second last output layer\n    d = layers.Conv2D(512, (4,4), padding='same', kernel_initializer=init)(d)\n    d = tfa.layers.InstanceNormalization(axis=-1)(d)\n    d = layers.LeakyReLU(alpha=0.2)(d)\n    # patch output\n    patch_out = layers.Conv2D(1, (4,4), padding='same', kernel_initializer=init)(d)\n    # define model\n    model = keras.Model(in_image, patch_out)\n    # compile model\n    model.compile(loss='mse', optimizer=keras.optimizers.Adam(lr=0.0002, beta_1=0.5), loss_weights=[0.5])\n    return model","metadata":{"execution":{"iopub.status.busy":"2023-05-22T06:23:33.426553Z","iopub.execute_input":"2023-05-22T06:23:33.427046Z","iopub.status.idle":"2023-05-22T06:23:33.621479Z","shell.execute_reply.started":"2023-05-22T06:23:33.426996Z","shell.execute_reply":"2023-05-22T06:23:33.619987Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# generator a resnet block\ndef resnet_block(n_filters, input_layer):\n    # weight initialization\n    init = keras.initializers.RandomNormal(stddev=0.02)\n    # first layer convolutional layer\n    g = layers.Conv2D(n_filters, (3,3), padding='same', kernel_initializer=init)(input_layer)\n    g = tfa.layers.InstanceNormalization(axis=-1)(g)\n    g = layers.Activation('relu')(g)\n    # second convolutional layer\n    g = layers.Conv2D(n_filters, (3,3), padding='same', kernel_initializer=init)(g)\n    g = tfa.layers.InstanceNormalization(axis=-1)(g)\n    # concatenate merge channel-wise with input layer\n    g = layers.Concatenate()([g, input_layer])\n    return g","metadata":{"execution":{"iopub.status.busy":"2023-05-22T06:23:33.624794Z","iopub.execute_input":"2023-05-22T06:23:33.625590Z","iopub.status.idle":"2023-05-22T06:23:33.636004Z","shell.execute_reply.started":"2023-05-22T06:23:33.625546Z","shell.execute_reply":"2023-05-22T06:23:33.634917Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def define_generator(image_shape, n_resnet=9):\n    # weight initialization\n    init = keras.initializers.RandomNormal(stddev=0.02)\n    # image input\n    in_image = keras.Input(shape=image_shape)\n    # c7s1-64\n    g = layers.Conv2D(64, (7,7), padding='same', kernel_initializer=init)(in_image)\n    g = tfa.layers.InstanceNormalization(axis=-1)(g)\n    g = layers.Activation('relu')(g)\n    # d128\n    g = layers.Conv2D(128, (3,3), strides=(2,2), padding='same', kernel_initializer=init)(g)\n    g = tfa.layers.InstanceNormalization(axis=-1)(g)\n    g = layers.Activation('relu')(g)\n    # d256\n    g = layers.Conv2D(256, (3,3), strides=(2,2), padding='same', kernel_initializer=init)(g)\n    g = tfa.layers.InstanceNormalization(axis=-1)(g)\n    g = layers.Activation('relu')(g)\n    # R256\n    for _ in range(n_resnet):\n        g = resnet_block(256, g)\n        # u128\n    g = layers.Conv2DTranspose(128, (3,3), strides=(2,2), padding='same', kernel_initializer=init)(g)\n    g = tfa.layers.InstanceNormalization(axis=-1)(g)\n    g = layers.Activation('relu')(g)\n    # u64\n    g = layers.Conv2DTranspose(64, (3,3), strides=(2,2), padding='same', kernel_initializer=init)(g)\n    g = tfa.layers.InstanceNormalization(axis=-1)(g)\n    g = layers.Activation('relu')(g)\n    # c7s1-3\n    g = layers.Conv2D(3, (7,7), padding='same', kernel_initializer=init)(g)\n    g = tfa.layers.InstanceNormalization(axis=-1)(g)\n    out_image = layers.Activation('tanh')(g)\n    # define model\n    model = keras.Model(in_image, out_image)\n    return model\n","metadata":{"execution":{"iopub.status.busy":"2023-05-22T06:23:33.641353Z","iopub.execute_input":"2023-05-22T06:23:33.641660Z","iopub.status.idle":"2023-05-22T06:23:33.658768Z","shell.execute_reply.started":"2023-05-22T06:23:33.641631Z","shell.execute_reply":"2023-05-22T06:23:33.657719Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# define a composite model for updating generators by adversarial and cycle loss\ndef define_composite_model(g_model_1, d_model, g_model_2, image_shape):\n    # ensure the model we're updating is trainable\n    g_model_1.trainable = True\n    # mark discriminator as not trainable\n    d_model.trainable = False\n    # mark other generator model as not trainable\n    g_model_2.trainable = False\n    # discriminator element\n    input_gen = keras.Input(shape=image_shape)\n    gen1_out = g_model_1(input_gen)\n    output_d = d_model(gen1_out)\n    # identity element\n    input_id = keras.Input(shape=image_shape)\n    output_id = g_model_1(input_id)\n    # forward cycle\n    output_f = g_model_2(gen1_out)\n    # backward cycle\n    gen2_out = g_model_2(input_id)\n    output_b = g_model_1(gen2_out)\n    # define model graph\n    model = keras.Model([input_gen, input_id], [output_d, output_id, output_f, output_b])\n    # define optimization algorithm configuration\n    opt = keras.optimizers.Adam(lr=0.0002, beta_1=0.5)\n    # compile model with weighting of least squares loss and L1 loss\n    model.compile(loss=['mse', 'mae', 'mae', 'mae'], loss_weights=[1, 5, 10, 10], optimizer=opt)\n    return model","metadata":{"execution":{"iopub.status.busy":"2023-05-22T06:23:33.662607Z","iopub.execute_input":"2023-05-22T06:23:33.662885Z","iopub.status.idle":"2023-05-22T06:23:33.673139Z","shell.execute_reply.started":"2023-05-22T06:23:33.662858Z","shell.execute_reply":"2023-05-22T06:23:33.672076Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# select a batch of random samples, returns images and target\ndef generate_real_samples(dataset, n_samples, patch_shape):\n    # choose random instances\n    ix = np.random.randint(0, dataset.shape[0], n_samples)\n    # retrieve selected images\n    X = dataset[ix]\n    # generate 'real' class labels (1)\n    y = np.ones((n_samples, patch_shape, patch_shape, 1))\n    return X, y","metadata":{"execution":{"iopub.status.busy":"2023-05-22T06:23:33.674738Z","iopub.execute_input":"2023-05-22T06:23:33.675207Z","iopub.status.idle":"2023-05-22T06:23:33.686291Z","shell.execute_reply.started":"2023-05-22T06:23:33.675169Z","shell.execute_reply":"2023-05-22T06:23:33.685275Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# generate a batch of images, returns images and targets\ndef generate_fake_samples(g_model, dataset, patch_shape):\n    # generate fake instance\n    X = g_model.predict(dataset)\n    # create 'fake' class labels (0)\n    y = np.zeros((len(X), patch_shape, patch_shape, 1))\n    return X, y","metadata":{"execution":{"iopub.status.busy":"2023-05-22T06:23:33.689962Z","iopub.execute_input":"2023-05-22T06:23:33.690443Z","iopub.status.idle":"2023-05-22T06:23:33.696397Z","shell.execute_reply.started":"2023-05-22T06:23:33.690414Z","shell.execute_reply":"2023-05-22T06:23:33.695246Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# save the generator models to file\ndef save_models(step, g_model_PtoS, g_model_StoP):\n    # save the first generator model\n    filename1 = 'g_model_PtoS_%06d.h5' % (step+1)\n    g_model_PtoS.save(filename1)\n    # save the second generator model\n    filename2 = 'g_model_StoP_%06d.h5' % (step+1)\n    g_model_StoP.save(filename2)\n    print('>Saved: %s and %s' % (filename1, filename2))","metadata":{"execution":{"iopub.status.busy":"2023-05-22T06:23:33.698194Z","iopub.execute_input":"2023-05-22T06:23:33.698967Z","iopub.status.idle":"2023-05-22T06:23:33.706705Z","shell.execute_reply.started":"2023-05-22T06:23:33.698889Z","shell.execute_reply":"2023-05-22T06:23:33.705648Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# generate samples and save as a plot and save the model\ndef summarize_performance(step, g_model, trainX, name, n_samples=5):\n    # select a sample of input images\n    X_in, _ = generate_real_samples(trainX, n_samples, 0)\n    # generate translated images\n    X_out, _ = generate_fake_samples(g_model, X_in, 0)\n    # scale all pixels from [-1,1] to [0,1]\n    X_in = (X_in + 1) / 2.0\n    X_out = (X_out + 1) / 2.0\n    # plot real images\n    for i in range(n_samples):\n        plt.subplot(2, n_samples, 1 + i)\n        plt.axis('off')\n        plt.imshow(X_in[i])\n    # plot translated image\n    for i in range(n_samples):\n        plt.subplot(2, n_samples, 1 + n_samples + i)\n        plt.axis('off')\n        plt.imshow(X_out[i])\n    # save plot to file\n    filename1 = '%s_generated_plot_%06d.png' % (name, (step+1))\n    plt.savefig(filename1)\n    plt.close()","metadata":{"execution":{"iopub.status.busy":"2023-05-22T06:23:33.709245Z","iopub.execute_input":"2023-05-22T06:23:33.709964Z","iopub.status.idle":"2023-05-22T06:23:33.721248Z","shell.execute_reply.started":"2023-05-22T06:23:33.709923Z","shell.execute_reply":"2023-05-22T06:23:33.720261Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# update image pool for fake images\ndef update_image_pool(pool, images, max_size=50):\n    selected = list()\n    for image in images:\n        if len(pool) < max_size:\n            # stock the pool\n            pool.append(image)\n            selected.append(image)\n        elif random() < 0.5:\n            # use image, but don't add it to the pool\n            selected.append(image)\n        else:\n            # replace an existing image and use replaced image\n            ix = np.random.randint(0, len(pool))\n            selected.append(pool[ix])\n            pool[ix] = image\n    return np.asarray(selected)","metadata":{"execution":{"iopub.status.busy":"2023-05-22T06:23:33.723359Z","iopub.execute_input":"2023-05-22T06:23:33.724141Z","iopub.status.idle":"2023-05-22T06:23:33.732449Z","shell.execute_reply.started":"2023-05-22T06:23:33.724101Z","shell.execute_reply":"2023-05-22T06:23:33.731464Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# train cyclegan models\ndef train(d_model_A, d_model_B, g_model_AtoB, g_model_BtoA, c_model_AtoB, c_model_BtoA, trainA, trainB):\n    # define properties of the training run\n    n_epochs, n_batch, = 50, 1\n    # determine the output square shape of the discriminator\n    n_patch = d_model_A.output_shape[1]\n    # unpack dataset\n    #trainA, trainB = dataset\n    # prepare image pool for fakes\n    poolA, poolB = list(), list()\n    # calculate the number of batches per training epoch\n    bat_per_epo = int(len(trainA) / n_batch)\n    # calculate the number of training iterations\n    n_steps = bat_per_epo * n_epochs\n    # manually enumerate epochs\n    for i in range(n_steps):\n        # select a batch of real samples\n        X_realA, y_realA = generate_real_samples(trainA, n_batch, n_patch)\n        X_realB, y_realB = generate_real_samples(trainB, n_batch, n_patch)\n        # generate a batch of fake samples\n        X_fakeA, y_fakeA = generate_fake_samples(g_model_BtoA, X_realB, n_patch)\n        X_fakeB, y_fakeB = generate_fake_samples(g_model_AtoB, X_realA, n_patch)\n        # update fakes from pool\n        X_fakeA = update_image_pool(poolA, X_fakeA)\n        X_fakeB = update_image_pool(poolB, X_fakeB)\n        # update generator B->A via adversarial and cycle loss\n        g_loss2, _, _, _, _  = c_model_BtoA.train_on_batch([X_realB, X_realA], [y_realA, X_realA, X_realB, X_realA])\n        # update discriminator for A -> [real/fake]\n        dA_loss1 = d_model_A.train_on_batch(X_realA, y_realA)\n        dA_loss2 = d_model_A.train_on_batch(X_fakeA, y_fakeA)\n        # update generator A->B via adversarial and cycle loss\n        g_loss1, _, _, _, _ = c_model_AtoB.train_on_batch([X_realA, X_realB], [y_realB, X_realB, X_realA, X_realB])\n        # update discriminator for B -> [real/fake]\n        dB_loss1 = d_model_B.train_on_batch(X_realB, y_realB)\n        dB_loss2 = d_model_B.train_on_batch(X_fakeB, y_fakeB)\n        # summarize performance\n        print('>%d, dA[%.3f,%.3f] dB[%.3f,%.3f] g[%.3f,%.3f]' % (i+1, dA_loss1,dA_loss2, dB_loss1,dB_loss2, g_loss1,g_loss2))\n        # evaluate the model performance every so often\n        #if (i+1) % (bat_per_epo * 1) == 0:\n            # plot A->B translation\n            #summarize_performance(i, g_model_AtoB, trainA, 'AtoB')\n            # plot B->A translation\n            #summarize_performance(i, g_model_BtoA, trainB, 'BtoA')\n        #if (i+1) % (bat_per_epo * 5) == 0:\n            # save the models\n            #save_models(i, g_model_AtoB, g_model_BtoA)\n","metadata":{"execution":{"iopub.status.busy":"2023-05-22T06:23:33.734244Z","iopub.execute_input":"2023-05-22T06:23:33.734666Z","iopub.status.idle":"2023-05-22T06:23:33.749476Z","shell.execute_reply.started":"2023-05-22T06:23:33.734588Z","shell.execute_reply":"2023-05-22T06:23:33.748338Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# load image data\nprint('Shapes of data:', data_monet.shape, data_photo.shape)\n# define input shape based on the loaded dataset\nimage_shape = data_monet.shape[1:]\n# generator: A -> B\ng_model_AtoB = define_generator(image_shape)\n# generator: B -> A\ng_model_BtoA = define_generator(image_shape)\n# discriminator: A -> [real/fake]\nd_model_A = define_discriminator(image_shape)\n# discriminator: B -> [real/fake]\nd_model_B = define_discriminator(image_shape)\n# composite: A -> B -> [real/fake, A]\nc_model_AtoB = define_composite_model(g_model_AtoB, d_model_B, g_model_BtoA, image_shape)\n# composite: B -> A -> [real/fake, B]\nc_model_BtoA = define_composite_model(g_model_BtoA, d_model_A, g_model_AtoB, image_shape)\n# train models\ntrain(d_model_A, d_model_B, g_model_AtoB, g_model_BtoA, c_model_AtoB, c_model_BtoA, data_photo,data_monet)","metadata":{"execution":{"iopub.status.busy":"2023-05-22T06:23:33.751355Z","iopub.execute_input":"2023-05-22T06:23:33.751669Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import PIL\n! mkdir ../images","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#save predictions\ni = 1\nfor filename in photo_filenames:\n    filename_list = [filename]\n    img = load_images(path, filename_list)\n    #print(img.shape)\n    img = (img - 127.5) / 127.5\n    #print(img.shape)\n    prediction = g_model_AtoB.predict(img, verbose = 0)[0]\n    #print(prediction.shape)\n    prediction = (prediction * 127.5 + 127.5).astype(np.uint8)\n    #print(prediction.shape)\n    im = PIL.Image.fromarray(prediction)\n    im.save(\"../images/\" + str(i) + \".jpg\")\n    i += 1\n    #if i % 1000 == 0:\n        #print(i)\n#plt.imshow(prediction.astype('uint8'))","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#show the images\nimg = load_images(path, filename_list)\nimg = img[0]\nplt.subplot(1, 2, 1 )\nplt.axis('off')\nplt.imshow(img.astype('uint8'))\nplt.subplot(1, 2, 2)\nplt.axis('off')\nplt.imshow(prediction.astype('uint8'))\nplt.show()","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import shutil\nshutil.make_archive(\"/kaggle/working/images\", 'zip', \"/kaggle/images\")","metadata":{"trusted":true},"execution_count":null,"outputs":[]}]}