{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":10418,"databundleVersionId":862236,"sourceType":"competition"}],"dockerImageVersionId":30732,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nfrom PIL import Image\nfrom collections import Counter\nfrom matplotlib.colors import LinearSegmentedColormap\nimport tensorflow as tf\nimport pathlib as p\n\nimport cv2\nimport os\nprint(os.listdir(\"../input/human-protein-atlas-image-classification\"))","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2024-06-29T10:29:50.886306Z","iopub.execute_input":"2024-06-29T10:29:50.886904Z","iopub.status.idle":"2024-06-29T10:29:50.896124Z","shell.execute_reply.started":"2024-06-29T10:29:50.886867Z","shell.execute_reply":"2024-06-29T10:29:50.894929Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#import training data\ntrain = pd.read_csv(\"../input/human-protein-atlas-image-classification/train.csv\")\nprint(train.head())\n\n#map of targets in a dictionary\nsubcell_locs = {\n0:  \"Nucleoplasm\", \n1:  \"Nuclear membrane\",   \n2:  \"Nucleoli\",   \n3:  \"Nucleoli fibrillar center\" ,  \n4:  \"Nuclear speckles\",\n5:  \"Nuclear bodies\",\n6:  \"Endoplasmic reticulum\",   \n7:  \"Golgi apparatus\",\n8:  \"Peroxisomes\",\n9:  \"Endosomes\",\n10:  \"Lysosomes\",\n11:  \"Intermediate filaments\",   \n12:  \"Actin filaments\",\n13:  \"Focal adhesion sites\",   \n14:  \"Microtubules\",\n15:  \"Microtubule ends\",   \n16:  \"Cytokinetic bridge\",   \n17:  \"Mitotic spindle\",\n18:  \"Microtubule organizing center\",  \n19:  \"Centrosome\",\n20:  \"Lipid droplets\",   \n21:  \"Plasma membrane\",   \n22:  \"Cell junctions\", \n23:  \"Mitochondria\",\n24:  \"Aggresome\",\n25:  \"Cytosol\",\n26:  \"Cytoplasmic bodies\",   \n27:  \"Rods & rings\" \n}","metadata":{"execution":{"iopub.status.busy":"2024-06-29T08:56:03.412404Z","iopub.execute_input":"2024-06-29T08:56:03.412949Z","iopub.status.idle":"2024-06-29T08:56:03.464354Z","shell.execute_reply.started":"2024-06-29T08:56:03.412912Z","shell.execute_reply":"2024-06-29T08:56:03.462944Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"The image with ID == 1 has the following labels:\", train.loc[1, \"Target\"])\nprint(\"These labels correspond to:\")\nfor location in train.loc[1, \"Target\"].split():\n    print(\"-\", subcell_locs[int(location)])\n\n# Reset seaborn style\nsns.reset_orig()\n\n# Get image id\nim_id = train.loc[1, \"Id\"]\n\n# Create custom color maps\ncdict1 = {'red':   ((0.0,  0.0, 0.0),\n                   (1.0,  0.0, 0.0)),\n         'green': ((0.0,  0.0, 0.0),\n                   (0.75, 1.0, 1.0),\n                   (1.0,  1.0, 1.0)),\n         'blue':  ((0.0,  0.0, 0.0),\n                   (1.0,  0.0, 0.0))}\n\ncdict2 = {'red':   ((0.0,  0.0, 0.0),\n                   (0.75, 1.0, 1.0),\n                   (1.0,  1.0, 1.0)),\n         'green': ((0.0,  0.0, 0.0),\n                   (1.0,  0.0, 0.0)),\n         'blue':  ((0.0,  0.0, 0.0),\n                   (1.0,  0.0, 0.0))}\n\ncdict3 = {'red':   ((0.0,  0.0, 0.0),\n                   (1.0,  0.0, 0.0)),\n         'green': ((0.0,  0.0, 0.0),\n                   (1.0,  0.0, 0.0)),\n         'blue':  ((0.0,  0.0, 0.0),\n                   (0.75, 1.0, 1.0),\n                   (1.0,  1.0, 1.0))}\n\ncdict4 = {'red': ((0.0,  0.0, 0.0),\n                   (0.75, 1.0, 1.0),\n                   (1.0,  1.0, 1.0)),\n         'green': ((0.0,  0.0, 0.0),\n                   (0.75, 1.0, 1.0),\n                   (1.0,  1.0, 1.0)),\n         'blue':  ((0.0,  0.0, 0.0),\n                   (1.0,  0.0, 0.0))}\n\n# Create and register colormaps\ncustom_greens = LinearSegmentedColormap('CustomGreens', cdict1)\ncustom_reds = LinearSegmentedColormap('CustomReds', cdict2)\ncustom_blues = LinearSegmentedColormap('CustomBlues', cdict3)\ncustom_yellows = LinearSegmentedColormap('CustomYellows', cdict4)\n\nplt.register_cmap(cmap=custom_greens)\nplt.register_cmap(cmap=custom_reds)\nplt.register_cmap(cmap=custom_blues)\nplt.register_cmap(cmap=custom_yellows)\n\n# Get each image channel as a greyscale image (second argument 0 in imread)\ngreen = cv2.imread(f'../input/human-protein-atlas-image-classification/train/{im_id}_green.png', 0)\nred = cv2.imread(f'../input/human-protein-atlas-image-classification/train/{im_id}_red.png', 0)\nblue = cv2.imread(f'../input/human-protein-atlas-image-classification/train/{im_id}_blue.png', 0)\nyellow = cv2.imread(f'../input/human-protein-atlas-image-classification/train/{im_id}_yellow.png', 0)\n\n# Display each channel separately\nfig, ax = plt.subplots(nrows=2, ncols=2, figsize=(15, 15))\nax[0, 0].imshow(green, cmap=\"CustomGreens\")\nax[0, 0].set_title(\"Protein of interest\", fontsize=18)\nax[0, 1].imshow(red, cmap=\"CustomReds\")\nax[0, 1].set_title(\"Microtubules\", fontsize=18)\nax[1, 0].imshow(blue, cmap=\"CustomBlues\")\nax[1, 0].set_title(\"Nucleus\", fontsize=18)\nax[1, 1].imshow(yellow, cmap=\"CustomYellows\")\nax[1, 1].set_title(\"Endoplasmic reticulum\", fontsize=18)\nfor i in range(2):\n    for j in range(2):\n        ax[i, j].set_xticklabels([])\n        ax[i, j].set_yticklabels([])\n        ax[i, j].tick_params(left=False, bottom=False)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-06-29T09:00:09.488781Z","iopub.execute_input":"2024-06-29T09:00:09.489163Z","iopub.status.idle":"2024-06-29T09:00:11.040324Z","shell.execute_reply.started":"2024-06-29T09:00:09.489122Z","shell.execute_reply":"2024-06-29T09:00:11.038806Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#stack nucleus and microtubules images\n#create blue nucleus and red microtubule images\nnuclei = cv2.merge((np.zeros((512, 512),dtype='uint8'), np.zeros((512, 512),dtype='uint8'), blue))\nmicrotub = cv2.merge((red, np.zeros((512, 512),dtype='uint8'), np.zeros((512, 512),dtype='uint8')))\n\n#create ROI\nrows, cols, _ = nuclei.shape\nroi = microtub[:rows, :cols]\n\n#create a mask of nuclei and invert mask\nnuclei_grey = cv2.cvtColor(nuclei, cv2.COLOR_BGR2GRAY)\nret, mask = cv2.threshold(nuclei_grey, 10, 255, cv2.THRESH_BINARY)\nmask_inv = cv2.bitwise_not(mask)\n\n#make area of nuclei in ROI black\nred_bg = cv2.bitwise_and(roi, roi, mask=mask_inv)\n\n#select only region with nuclei from blue\nblue_fg = cv2.bitwise_and(nuclei, nuclei, mask=mask)\n\n#put nuclei in ROI and modify red\ndst = cv2.add(red_bg, blue_fg)\nmicrotub[:rows, :cols] = dst\n\n#show result image\nfig, ax = plt.subplots(figsize=(8, 8))\nax.imshow(microtub)\nax.set_title(\"Nuclei (blue) + microtubules (red)\", fontsize=15)\nax.set_xticklabels([])\nax.set_yticklabels([])\nax.tick_params(left=False, bottom=False)","metadata":{"execution":{"iopub.status.busy":"2024-06-29T09:01:07.030956Z","iopub.execute_input":"2024-06-29T09:01:07.031463Z","iopub.status.idle":"2024-06-29T09:01:07.61107Z","shell.execute_reply.started":"2024-06-29T09:01:07.031427Z","shell.execute_reply":"2024-06-29T09:01:07.609787Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels_num = [value.split() for value in train['Target']]\nlabels_num_flat = list(map(int, [item for sublist in labels_num for item in sublist]))\nlabels = [\"\" for _ in range(len(labels_num_flat))]\nfor i in range(len(labels_num_flat)):\n    labels[i] = subcell_locs[labels_num_flat[i]]\n\nfig, ax = plt.subplots(figsize=(15, 5))\npd.Series(labels).value_counts().plot(kind='bar', fontsize=14)","metadata":{"execution":{"iopub.status.busy":"2024-06-29T09:02:08.515514Z","iopub.execute_input":"2024-06-29T09:02:08.516442Z","iopub.status.idle":"2024-06-29T09:02:09.311705Z","shell.execute_reply.started":"2024-06-29T09:02:08.516403Z","shell.execute_reply":"2024-06-29T09:02:09.310406Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Đọc dữ liệu","metadata":{}},{"cell_type":"code","source":"dataset_folder = os.path.join(\"../input/human-protein-atlas-image-classification/train\")\ndatasetObject = p.Path(dataset_folder)\ndataset_images = list(datasetObject.glob(\"*.*\"))","metadata":{"execution":{"iopub.status.busy":"2024-06-29T09:27:51.298943Z","iopub.execute_input":"2024-06-29T09:27:51.299404Z","iopub.status.idle":"2024-06-29T09:27:55.362088Z","shell.execute_reply.started":"2024-06-29T09:27:51.299369Z","shell.execute_reply":"2024-06-29T09:27:55.360943Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(dataset_images)","metadata":{"execution":{"iopub.status.busy":"2024-06-29T09:27:58.972667Z","iopub.execute_input":"2024-06-29T09:27:58.97309Z","iopub.status.idle":"2024-06-29T09:27:58.980896Z","shell.execute_reply.started":"2024-06-29T09:27:58.973059Z","shell.execute_reply":"2024-06-29T09:27:58.979619Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"csv_dataset = pd.read_csv(\"../input/human-protein-atlas-image-classification/train.csv\")\ncsv_dataset.head()","metadata":{"execution":{"iopub.status.busy":"2024-06-29T09:28:34.895171Z","iopub.execute_input":"2024-06-29T09:28:34.895589Z","iopub.status.idle":"2024-06-29T09:28:34.94197Z","shell.execute_reply.started":"2024-06-29T09:28:34.895559Z","shell.execute_reply":"2024-06-29T09:28:34.940601Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(csv_dataset)","metadata":{"execution":{"iopub.status.busy":"2024-06-29T09:28:42.010026Z","iopub.execute_input":"2024-06-29T09:28:42.010428Z","iopub.status.idle":"2024-06-29T09:28:42.018569Z","shell.execute_reply.started":"2024-06-29T09:28:42.010398Z","shell.execute_reply":"2024-06-29T09:28:42.017309Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"target = csv_dataset['Target']\ntarget.head()","metadata":{"execution":{"iopub.status.busy":"2024-06-29T09:28:49.825497Z","iopub.execute_input":"2024-06-29T09:28:49.825916Z","iopub.status.idle":"2024-06-29T09:28:49.835952Z","shell.execute_reply.started":"2024-06-29T09:28:49.825887Z","shell.execute_reply":"2024-06-29T09:28:49.834453Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"IDs = csv_dataset['Id']\nplt.figure(figsize = (17, 12))\nfor i in range(20):\n  plt.subplot(4, 5, i + 1)\n  red= cv2.imread(\"../input/human-protein-atlas-image-classification/train/{}_red.png\".format(str(IDs[i])), 0)\n  green = cv2.imread(\"../input/human-protein-atlas-image-classification/train/{}_green.png\".format(str(IDs[i])), 0)\n  blue = cv2.imread(\"../input/human-protein-atlas-image-classification/train/{}_blue.png\".format(str(IDs[i])), 0)\n  image = np.stack((red, green, blue), -1)\n  plt.imshow(image)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-06-29T09:29:58.312513Z","iopub.execute_input":"2024-06-29T09:29:58.313003Z","iopub.status.idle":"2024-06-29T09:30:03.132542Z","shell.execute_reply.started":"2024-06-29T09:29:58.312968Z","shell.execute_reply":"2024-06-29T09:30:03.130816Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Preprocessing","metadata":{}},{"cell_type":"code","source":"def reszie_and_scale_image(img, target_size):\n  img = cv2.resize(img, target_size)\n  img = img/255\n  return img","metadata":{"execution":{"iopub.status.busy":"2024-06-29T09:33:47.724955Z","iopub.execute_input":"2024-06-29T09:33:47.725378Z","iopub.status.idle":"2024-06-29T09:33:47.735066Z","shell.execute_reply.started":"2024-06-29T09:33:47.725339Z","shell.execute_reply":"2024-06-29T09:33:47.73375Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def read_img(paths):\n  red = cv2.imread(paths[0], 0)\n  red = reszie_and_scale_image(red, (90, 90))\n  blue = cv2.imread(paths[1], 0)\n  blue = reszie_and_scale_image(blue, (90, 90))\n  yellow = cv2.imread(paths[2])\n  yellow = reszie_and_scale_image(yellow, (90, 90))\n  green = cv2.imread(paths[3], 0)\n  green = reszie_and_scale_image(green, (90, 90))\n  return np.array([np.stack(\n      (red, green, blue), -1\n  ), yellow])","metadata":{"execution":{"iopub.status.busy":"2024-06-29T09:33:50.019814Z","iopub.execute_input":"2024-06-29T09:33:50.020365Z","iopub.status.idle":"2024-06-29T09:33:50.030359Z","shell.execute_reply.started":"2024-06-29T09:33:50.020327Z","shell.execute_reply":"2024-06-29T09:33:50.028677Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"images = []\nlist_images_csv_dataset = csv_dataset['Id']\nfor img in list_images_csv_dataset:\n  arr = read_img([\n      \"../input/human-protein-atlas-image-classification/train/{}_red.png\".format(str(img)),\n      \"../input/human-protein-atlas-image-classification/train/{}_blue.png\".format(str(img)),\n      \"../input/human-protein-atlas-image-classification/train/{}_yellow.png\".format(str(img)),\n      \"../input/human-protein-atlas-image-classification/train/{}_green.png\".format(str(img))\n  ])\n  images.append(arr)","metadata":{"execution":{"iopub.status.busy":"2024-06-29T09:33:53.989501Z","iopub.execute_input":"2024-06-29T09:33:53.990781Z","iopub.status.idle":"2024-06-29T10:04:57.12363Z","shell.execute_reply.started":"2024-06-29T09:33:53.990739Z","shell.execute_reply":"2024-06-29T10:04:57.119645Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"images = np.asarray(images)","metadata":{"execution":{"iopub.status.busy":"2024-06-29T10:05:10.183346Z","iopub.execute_input":"2024-06-29T10:05:10.184042Z","iopub.status.idle":"2024-06-29T10:05:32.881619Z","shell.execute_reply.started":"2024-06-29T10:05:10.183996Z","shell.execute_reply":"2024-06-29T10:05:32.880119Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Lưu nhiều mảng trong một file .npz\nnp.savez('images.npz', images=images)","metadata":{"execution":{"iopub.status.busy":"2024-06-29T10:59:47.201414Z","iopub.execute_input":"2024-06-29T10:59:47.202072Z","iopub.status.idle":"2024-06-29T11:00:35.337519Z","shell.execute_reply.started":"2024-06-29T10:59:47.202022Z","shell.execute_reply":"2024-06-29T11:00:35.336157Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import shutil\nimport os\n\n# Nén thư mục hoặc file\nshutil.make_archive('/kaggle/working/data_archive', 'zip', '/kaggle/working/')\n\n# Sau đó bạn có thể tải file nén này từ tab \"Data\" hoặc sử dụng các phương pháp tải lên Kaggle UI\n","metadata":{"execution":{"iopub.status.busy":"2024-06-29T11:04:31.842883Z","iopub.execute_input":"2024-06-29T11:04:31.843431Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"images.shape","metadata":{"execution":{"iopub.status.busy":"2024-06-29T10:05:38.8751Z","iopub.execute_input":"2024-06-29T10:05:38.875808Z","iopub.status.idle":"2024-06-29T10:05:38.890371Z","shell.execute_reply.started":"2024-06-29T10:05:38.875754Z","shell.execute_reply":"2024-06-29T10:05:38.888678Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"images[0][0].shape","metadata":{"execution":{"iopub.status.busy":"2024-06-29T10:06:58.868283Z","iopub.execute_input":"2024-06-29T10:06:58.868877Z","iopub.status.idle":"2024-06-29T10:06:58.878431Z","shell.execute_reply.started":"2024-06-29T10:06:58.86884Z","shell.execute_reply":"2024-06-29T10:06:58.877013Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize = (17, 12))\nfor i in range(24):\n  plt.subplot(4, 6, i + 1)\n  plt.imshow(images[i][0])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-06-29T10:12:45.7752Z","iopub.execute_input":"2024-06-29T10:12:45.776351Z","iopub.status.idle":"2024-06-29T10:12:50.821666Z","shell.execute_reply.started":"2024-06-29T10:12:45.776304Z","shell.execute_reply":"2024-06-29T10:12:50.820217Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize = (12, 4))\ncolors = [\"rgb\", \"yellow\"]\nfor i in range(2):\n  plt.subplot(1, 4, i + 1)\n  plt.imshow(images[1][i])\n  plt.title(colors[i])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-06-29T10:12:58.526069Z","iopub.execute_input":"2024-06-29T10:12:58.526583Z","iopub.status.idle":"2024-06-29T10:12:58.990929Z","shell.execute_reply.started":"2024-06-29T10:12:58.526546Z","shell.execute_reply":"2024-06-29T10:12:58.989273Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"target_after = np.zeros((len(csv_dataset), 28), dtype=int)","metadata":{"execution":{"iopub.status.busy":"2024-06-29T10:13:37.735147Z","iopub.execute_input":"2024-06-29T10:13:37.735724Z","iopub.status.idle":"2024-06-29T10:13:37.745614Z","shell.execute_reply.started":"2024-06-29T10:13:37.735659Z","shell.execute_reply":"2024-06-29T10:13:37.743787Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"target_after.shape","metadata":{"execution":{"iopub.status.busy":"2024-06-29T10:13:55.397419Z","iopub.execute_input":"2024-06-29T10:13:55.397897Z","iopub.status.idle":"2024-06-29T10:13:55.406316Z","shell.execute_reply.started":"2024-06-29T10:13:55.397864Z","shell.execute_reply":"2024-06-29T10:13:55.404776Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"target_after[0]","metadata":{"execution":{"iopub.status.busy":"2024-06-29T10:13:59.094629Z","iopub.execute_input":"2024-06-29T10:13:59.095172Z","iopub.status.idle":"2024-06-29T10:13:59.105904Z","shell.execute_reply.started":"2024-06-29T10:13:59.095133Z","shell.execute_reply":"2024-06-29T10:13:59.104379Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"targets = csv_dataset['Target']\nfor index, tar in enumerate(targets):\n  ids = tar.split()\n  for id in ids:\n    target_after[index, int(id)] = 1","metadata":{"execution":{"iopub.status.busy":"2024-06-29T10:14:03.361531Z","iopub.execute_input":"2024-06-29T10:14:03.36208Z","iopub.status.idle":"2024-06-29T10:14:03.429038Z","shell.execute_reply.started":"2024-06-29T10:14:03.362026Z","shell.execute_reply":"2024-06-29T10:14:03.427783Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"target_after[0]","metadata":{"execution":{"iopub.status.busy":"2024-06-29T10:14:05.359684Z","iopub.execute_input":"2024-06-29T10:14:05.360744Z","iopub.status.idle":"2024-06-29T10:14:05.369043Z","shell.execute_reply.started":"2024-06-29T10:14:05.360677Z","shell.execute_reply":"2024-06-29T10:14:05.367587Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install --upgrade tensorflow","metadata":{"execution":{"iopub.status.busy":"2024-06-29T10:49:22.894125Z","iopub.execute_input":"2024-06-29T10:49:22.89467Z","iopub.status.idle":"2024-06-29T10:52:18.532352Z","shell.execute_reply.started":"2024-06-29T10:49:22.894635Z","shell.execute_reply":"2024-06-29T10:52:18.530778Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from tensorflow.keras.applications import DenseNet201\nimport os\nimport urllib.request\n\n# Define URL and local file path\nurl = \"https://storage.googleapis.com/tensorflow/keras-applications/densenet/densenet201_weights_tf_dim_ordering_tf_kernels_notop.h5\"\nlocal_file_path = \"densenet201_weights.h5\"\n\n# Download the file\nurllib.request.urlretrieve(url, local_file_path)\n\n# Load the model with the downloaded weights\nmodel = DenseNet201(include_top=False, weights=None, input_shape=(90, 90, 3))\nmodel.load_weights(local_file_path)\n\n\n# Set all layers to be trainable\nfor layer in DenseNet_model.layers:\n    layer.trainable = True  \n\n# Define the model\nmodel = tf.keras.models.Sequential([\n    # TimeDistributed wrapper for DenseNet201\n    tf.keras.layers.TimeDistributed(DenseNet_model, input_shape=(2, 90, 90, 3)),\n    tf.keras.layers.TimeDistributed(tf.keras.layers.GlobalAveragePooling2D()),\n    tf.keras.layers.BatchNormalization(),\n    tf.keras.layers.Dropout(0.5),\n    tf.keras.layers.Flatten(),  # Flatten before passing to Dense layers\n    tf.keras.layers.Dense(1024, activation='relu'),\n    tf.keras.layers.Dropout(0.5),\n    tf.keras.layers.Dense(28, activation='sigmoid')\n])\n\n# Compile the model\nmodel.compile(optimizer=tf.keras.optimizers.Adam(learning_rate=0.00001),\n              loss='binary_crossentropy',\n              metrics=['binary_accuracy'])\n\n# Display the model summary\nmodel.summary()","metadata":{"execution":{"iopub.status.busy":"2024-06-29T10:53:58.82752Z","iopub.execute_input":"2024-06-29T10:53:58.828127Z","iopub.status.idle":"2024-06-29T10:54:19.166357Z","shell.execute_reply.started":"2024-06-29T10:53:58.828088Z","shell.execute_reply":"2024-06-29T10:54:19.16413Z"},"trusted":true},"execution_count":null,"outputs":[]}]}