diff --git a/Butterfly Image Classification/Models/butterfly-classification-cnn.ipynb b/Butterfly Image Classification/Models/butterfly-classification-cnn.ipynb new file mode 100644 index 000000000..7213f4639 --- /dev/null +++ b/Butterfly Image Classification/Models/butterfly-classification-cnn.ipynb @@ -0,0 +1,1253 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "22b85536", + "metadata": { + "_cell_guid": "b1076dfc-b9ad-4769-8c92-a6c4dae69d19", + "_uuid": "8f2839f25d086af736a60e9eeb907d3b93b6e0e5", + "execution": { + "iopub.execute_input": "2024-05-07T13:22:13.340009Z", + "iopub.status.busy": "2024-05-07T13:22:13.339735Z", + "iopub.status.idle": "2024-05-07T13:22:26.631704Z", + "shell.execute_reply": "2024-05-07T13:22:26.630611Z" + }, + "papermill": { + "duration": 13.303115, + "end_time": "2024-05-07T13:22:26.634091", + "exception": false, + "start_time": "2024-05-07T13:22:13.330976", + "status": "completed" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-05-07 13:22:16.401649: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered\n", + "2024-05-07 13:22:16.401763: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered\n", + "2024-05-07 13:22:16.563012: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered\n" + ] + }, + { + "data": { + "text/plain": [ + "\"\\nfor dirname, _, filenames in os.walk('/kaggle/input'):\\n for filename in filenames:\\n print(os.path.join(dirname, filename))\\n\"" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import numpy as np\n", + "import pandas as pd \n", + "import cv2\n", + "import matplotlib.pyplot as plt\n", + "import tensorflow as tf\n", + "import os" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "eefcba16", + "metadata": { + "execution": { + "iopub.execute_input": "2024-05-07T13:22:26.653874Z", + "iopub.status.busy": "2024-05-07T13:22:26.653275Z", + "iopub.status.idle": "2024-05-07T13:22:26.922440Z", + "shell.execute_reply": "2024-05-07T13:22:26.921575Z" + }, + "papermill": { + "duration": 0.281228, + "end_time": "2024-05-07T13:22:26.924678", + "exception": false, + "start_time": "2024-05-07T13:22:26.643450", + "status": "completed" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "gpus = tf.config.experimental.list_physical_devices('GPU')\n", + "for gpu in gpus:\n", + " tf.config.experimental.set_memory_growth(gpu, True)" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "0b03a8d4", + "metadata": { + "execution": { + "iopub.execute_input": "2024-05-07T13:22:26.943904Z", + "iopub.status.busy": "2024-05-07T13:22:26.943086Z", + "iopub.status.idle": "2024-05-07T13:22:26.988549Z", + "shell.execute_reply": "2024-05-07T13:22:26.987404Z" + }, + "papermill": { + "duration": 0.057171, + "end_time": "2024-05-07T13:22:26.990742", + "exception": false, + "start_time": "2024-05-07T13:22:26.933571", + "status": "completed" + }, + "tags": [] + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Model: \"sequential\"\n", + "
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓\n", + "┃ Layer (type) ┃ Output Shape ┃ Param # ┃\n", + "┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩\n", + "│ rescaling (Rescaling) │ (None, 224, 224, 3) │ 0 │\n", + "├─────────────────────────────────┼────────────────────────┼───────────────┤\n", + "│ random_flip (RandomFlip) │ (None, 224, 224, 3) │ 0 │\n", + "├─────────────────────────────────┼────────────────────────┼───────────────┤\n", + "│ random_rotation │ (None, 224, 224, 3) │ 0 │\n", + "│ (RandomRotation) │ │ │\n", + "├─────────────────────────────────┼────────────────────────┼───────────────┤\n", + "│ random_zoom (RandomZoom) │ (None, 224, 224, 3) │ 0 │\n", + "├─────────────────────────────────┼────────────────────────┼───────────────┤\n", + "│ random_contrast │ (None, 224, 224, 3) │ 0 │\n", + "│ (RandomContrast) │ │ │\n", + "├─────────────────────────────────┼────────────────────────┼───────────────┤\n", + "│ conv2d (Conv2D) │ (None, 220, 220, 16) │ 1,216 │\n", + "├─────────────────────────────────┼────────────────────────┼───────────────┤\n", + "│ max_pooling2d (MaxPooling2D) │ (None, 110, 110, 16) │ 0 │\n", + "├─────────────────────────────────┼────────────────────────┼───────────────┤\n", + "│ conv2d_1 (Conv2D) │ (None, 106, 106, 32) │ 12,832 │\n", + "├─────────────────────────────────┼────────────────────────┼───────────────┤\n", + "│ max_pooling2d_1 (MaxPooling2D) │ (None, 53, 53, 32) │ 0 │\n", + "├─────────────────────────────────┼────────────────────────┼───────────────┤\n", + "│ conv2d_2 (Conv2D) │ (None, 51, 51, 64) │ 18,496 │\n", + "├─────────────────────────────────┼────────────────────────┼───────────────┤\n", + "│ max_pooling2d_2 (MaxPooling2D) │ (None, 25, 25, 64) │ 0 │\n", + "├─────────────────────────────────┼────────────────────────┼───────────────┤\n", + "│ conv2d_3 (Conv2D) │ (None, 23, 23, 128) │ 73,856 │\n", + "├─────────────────────────────────┼────────────────────────┼───────────────┤\n", + "│ dropout (Dropout) │ (None, 23, 23, 128) │ 0 │\n", + "├─────────────────────────────────┼────────────────────────┼───────────────┤\n", + "│ flatten (Flatten) │ (None, 67712) │ 0 │\n", + "├─────────────────────────────────┼────────────────────────┼───────────────┤\n", + "│ dense (Dense) │ (None, 128) │ 8,667,264 │\n", + "├─────────────────────────────────┼────────────────────────┼───────────────┤\n", + "│ dense_1 (Dense) │ (None, 128) │ 16,512 │\n", + "├─────────────────────────────────┼────────────────────────┼───────────────┤\n", + "│ dense_2 (Dense) │ (None, 128) │ 16,512 │\n", + "├─────────────────────────────────┼────────────────────────┼───────────────┤\n", + "│ dropout_1 (Dropout) │ (None, 128) │ 0 │\n", + "├─────────────────────────────────┼────────────────────────┼───────────────┤\n", + "│ dense_3 (Dense) │ (None, 75) │ 9,675 │\n", + "└─────────────────────────────────┴────────────────────────┴───────────────┘\n", + "
Total params: 8,816,363 (33.63 MB)\n", + "
Trainable params: 8,816,363 (33.63 MB)\n", + "
Non-trainable params: 0 (0.00 B)\n", + "