noshot 12.0.0__py3-none-any.whl → 13.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. noshot/data/DLE FSD BDA/DLE/DLE 2 (tim stan s)/1.1 DNN (Pytorch).ipynb +164 -0
  2. noshot/data/DLE FSD BDA/DLE/DLE 2 (tim stan s)/1.2 DNN (Tensorflow).ipynb +94 -0
  3. noshot/data/DLE FSD BDA/DLE/DLE 2 (tim stan s)/1.3 DNN (Image Classification).ipynb +134 -0
  4. noshot/data/DLE FSD BDA/DLE/DLE 2 (tim stan s)/2.1 DNN vs CNN.ipynb +127 -0
  5. noshot/data/DLE FSD BDA/DLE/DLE 2 (tim stan s)/2.2 DNN vs CNN.ipynb +123 -0
  6. noshot/data/DLE FSD BDA/DLE/DLE 2 (tim stan s)/4. FCNN (Image Segmentation).ipynb +108 -0
  7. noshot/data/DLE FSD BDA/DLE/DLE 2 (tim stan s)/Lab Excercise (Training DNN).ipynb +646 -0
  8. noshot/data/DLE FSD BDA/DLE/DLE 2 (tim stan s)/Load-Images.ipynb +553 -0
  9. noshot/data/DLE FSD BDA/DLE/DLE 3 (sonic boy)/Ex1.ipynb +216 -0
  10. noshot/data/DLE FSD BDA/DLE/DLE 3 (sonic boy)/Ex2.ipynb +195 -0
  11. noshot/data/DLE FSD BDA/DLE/DLE 3 (sonic boy)/Ex3.ipynb +427 -0
  12. noshot/data/DLE FSD BDA/DLE/DLE 3 (sonic boy)/Ex4.ipynb +186 -0
  13. noshot/data/DLE FSD BDA/DLE/DLE 4 (senior)/Exp01/DNN Ex No 1.ipynb +398 -0
  14. noshot/data/DLE FSD BDA/DLE/DLE 4 (senior)/Exp01/Ex No 1 Build in dataset.ipynb +171 -0
  15. noshot/data/DLE FSD BDA/DLE/DLE 4 (senior)/Exp01/Exp1-Short-DL_ANN_ImageClassification.ipynb +401 -0
  16. noshot/data/DLE FSD BDA/DLE/DLE 4 (senior)/Exp01/OR GATE .ipynb +8511 -0
  17. noshot/data/DLE FSD BDA/DLE/DLE 4 (senior)/Exp02/Exp2-Short-DL_CNN_ImageClassification.ipynb +737 -0
  18. noshot/data/DLE FSD BDA/DLE/DLE 4 (senior)/Exp03/DL-Ex3-RNN.ipynb +591 -0
  19. noshot/data/DLE FSD BDA/DLE/DLE 4 (senior)/Exp04/Ex no 4.ipynb +551 -0
  20. {noshot-12.0.0.dist-info → noshot-13.0.0.dist-info}/METADATA +1 -1
  21. noshot-13.0.0.dist-info/RECORD +32 -0
  22. noshot-12.0.0.dist-info/RECORD +0 -13
  23. /noshot/data/DLE FSD BDA/DLE/{1. DNN (Image Classification).ipynb → DLE 1 (Json)/1. DNN (Image Classification).ipynb} +0 -0
  24. /noshot/data/DLE FSD BDA/DLE/{2. DNN vs CNN.ipynb → DLE 1 (Json)/2. DNN vs CNN.ipynb} +0 -0
  25. /noshot/data/DLE FSD BDA/DLE/{3. CNN (Object Detecrion).ipynb → DLE 1 (Json)/3. CNN (Object Detecrion).ipynb} +0 -0
  26. /noshot/data/DLE FSD BDA/DLE/{4. FCN (Image Segmentaion).ipynb → DLE 1 (Json)/4. FCN (Image Segmentaion).ipynb} +0 -0
  27. {noshot-12.0.0.dist-info → noshot-13.0.0.dist-info}/WHEEL +0 -0
  28. {noshot-12.0.0.dist-info → noshot-13.0.0.dist-info}/licenses/LICENSE.txt +0 -0
  29. {noshot-12.0.0.dist-info → noshot-13.0.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,186 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "id": "6a60369e-1161-4281-b04d-f0168bf5ef7f",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "import tensorflow as tf\n",
11
+ "from tensorflow.keras.preprocessing.image import ImageDataGenerator\n",
12
+ "from tensorflow.keras.layers import Conv2D, MaxPooling2D, Conv2DTranspose, Input\n",
13
+ "from tensorflow.keras.models import Model\n",
14
+ "import matplotlib.pyplot as plt\n",
15
+ "import numpy as np"
16
+ ]
17
+ },
18
+ {
19
+ "cell_type": "code",
20
+ "execution_count": null,
21
+ "id": "b1c3acba-dff0-4bbb-9b35-16f18d36f84f",
22
+ "metadata": {},
23
+ "outputs": [],
24
+ "source": [
25
+ "# Paths to images and masks directories\n",
26
+ "image_dir = r\"D:\\Neeraj\\SEM 7\\DLE LAB\\Banana FCN\\Banana FCN\\Images\"\n",
27
+ "mask_dir = r\"D:\\Neeraj\\SEM 7\\DLE LAB\\Banana FCN\\Banana FCN\\Mask\"\n",
28
+ "\n",
29
+ "# Image and mask data generators\n",
30
+ "image_datagen = ImageDataGenerator(rescale=1./255)\n",
31
+ "mask_datagen = ImageDataGenerator(rescale=1./255)"
32
+ ]
33
+ },
34
+ {
35
+ "cell_type": "code",
36
+ "execution_count": null,
37
+ "id": "a25255b3-ad4f-4037-8ca7-e66572ac6352",
38
+ "metadata": {},
39
+ "outputs": [],
40
+ "source": [
41
+ "image_generator = image_datagen.flow_from_directory(\n",
42
+ " image_dir,\n",
43
+ " class_mode=None,\n",
44
+ " color_mode='rgb',\n",
45
+ " target_size=(128, 128),\n",
46
+ " batch_size=8,\n",
47
+ " seed=42\n",
48
+ ")"
49
+ ]
50
+ },
51
+ {
52
+ "cell_type": "code",
53
+ "execution_count": null,
54
+ "id": "f06864c7-8962-44f8-a51f-89e29335eab8",
55
+ "metadata": {},
56
+ "outputs": [],
57
+ "source": [
58
+ "mask_generator = mask_datagen.flow_from_directory(\n",
59
+ " mask_dir,\n",
60
+ " class_mode=None,\n",
61
+ " color_mode='grayscale',\n",
62
+ " target_size=(128, 128),\n",
63
+ " batch_size=8,\n",
64
+ " seed=42\n",
65
+ ")"
66
+ ]
67
+ },
68
+ {
69
+ "cell_type": "code",
70
+ "execution_count": null,
71
+ "id": "2ab0717a-efb1-4178-b1a3-da50bff63147",
72
+ "metadata": {},
73
+ "outputs": [],
74
+ "source": [
75
+ "# Combine generators into one which yields image and mask\n",
76
+ "train_generator = zip(image_generator, mask_generator)"
77
+ ]
78
+ },
79
+ {
80
+ "cell_type": "code",
81
+ "execution_count": null,
82
+ "id": "c07463ee-7151-49b9-b62f-b7cd750fbae9",
83
+ "metadata": {},
84
+ "outputs": [],
85
+ "source": [
86
+ "def build_fcnn():\n",
87
+ " inputs = Input((128, 128, 3))\n",
88
+ "\n",
89
+ " # Encoder\n",
90
+ " conv1 = Conv2D(128, (3, 3), activation='relu', padding='same')(inputs)\n",
91
+ " pool1 = MaxPooling2D((2, 2))(conv1)\n",
92
+ "\n",
93
+ " conv2 = Conv2D(256, (3, 3), activation='relu', padding='same')(pool1)\n",
94
+ " pool2 = MaxPooling2D((2, 2))(conv2)\n",
95
+ "\n",
96
+ " # Decoder\n",
97
+ " conv3 = Conv2D(256, (3, 3), activation='relu', padding='same')(pool2)\n",
98
+ " up1 = Conv2DTranspose(128, (2, 2), strides=(2, 2), padding='same')(conv3)\n",
99
+ "\n",
100
+ " conv4 = Conv2D(128, (3, 3), activation='relu', padding='same')(up1)\n",
101
+ " up2 = Conv2DTranspose(64, (2, 2), strides=(2, 2), padding='same')(conv4)\n",
102
+ "\n",
103
+ " outputs = Conv2D(1, (1, 1), activation='sigmoid', padding='same')(up2)\n",
104
+ "\n",
105
+ " model = Model(inputs, outputs)\n",
106
+ " return model\n",
107
+ "\n",
108
+ "model = build_fcnn()\n",
109
+ "model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])\n",
110
+ "model.summary()"
111
+ ]
112
+ },
113
+ {
114
+ "cell_type": "code",
115
+ "execution_count": null,
116
+ "id": "6fd59bd5-ef68-4245-8f38-6d07f0d1168e",
117
+ "metadata": {},
118
+ "outputs": [],
119
+ "source": [
120
+ "# Train the FCNN model\n",
121
+ "def combined_generator(image_gen, mask_gen):\n",
122
+ " while True: # Keep yielding data indefinitely\n",
123
+ " img_batch = next(image_gen)\n",
124
+ " mask_batch = next(mask_gen)\n",
125
+ " yield img_batch, mask_batch # Keras expects (input, target)\n",
126
+ "# Fit the model with the custom generator\n",
127
+ "train_generator = combined_generator(image_generator, mask_generator)\n",
128
+ "model.fit(train_generator, steps_per_epoch=len(image_generator), epochs=5)"
129
+ ]
130
+ },
131
+ {
132
+ "cell_type": "code",
133
+ "execution_count": null,
134
+ "id": "77a2606d-0d22-4c8c-95cf-df9c4ddec7ae",
135
+ "metadata": {},
136
+ "outputs": [],
137
+ "source": [
138
+ "# Sample image for prediction\n",
139
+ "sample_image = image_generator[0][0]\n",
140
+ "predicted_mask = model.predict(np.expand_dims(sample_image, axis=0))[0]\n",
141
+ "\n",
142
+ "# Display the original image and predicted mask\n",
143
+ "plt.figure(figsize=(10, 5))\n",
144
+ "\n",
145
+ "plt.subplot(1, 2, 1)\n",
146
+ "plt.title(\"Original Image\")\n",
147
+ "plt.imshow(sample_image)\n",
148
+ "\n",
149
+ "plt.subplot(1, 2, 2)\n",
150
+ "plt.title(\"Predicted Mask\")\n",
151
+ "plt.imshow(predicted_mask.squeeze(), cmap='gray')\n",
152
+ "\n",
153
+ "plt.show()"
154
+ ]
155
+ },
156
+ {
157
+ "cell_type": "code",
158
+ "execution_count": null,
159
+ "id": "87630680-a078-42f4-92bd-cce91efe2d0f",
160
+ "metadata": {},
161
+ "outputs": [],
162
+ "source": []
163
+ }
164
+ ],
165
+ "metadata": {
166
+ "kernelspec": {
167
+ "display_name": "Python 3 (ipykernel)",
168
+ "language": "python",
169
+ "name": "python3"
170
+ },
171
+ "language_info": {
172
+ "codemirror_mode": {
173
+ "name": "ipython",
174
+ "version": 3
175
+ },
176
+ "file_extension": ".py",
177
+ "mimetype": "text/x-python",
178
+ "name": "python",
179
+ "nbconvert_exporter": "python",
180
+ "pygments_lexer": "ipython3",
181
+ "version": "3.12.4"
182
+ }
183
+ },
184
+ "nbformat": 4,
185
+ "nbformat_minor": 5
186
+ }
@@ -0,0 +1,398 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "# Train a deep neural network for an Image classification task using Bean leaf dataset\n",
8
+ "\n",
9
+ "**Dataset**: <https://www.kaggle.com/datasets/prakharrastogi534/bean-leaf-dataset>"
10
+ ]
11
+ },
12
+ {
13
+ "cell_type": "code",
14
+ "execution_count": null,
15
+ "metadata": {},
16
+ "outputs": [],
17
+ "source": [
18
+ "# Import necessary packages\n",
19
+ "import pandas as pd\n",
20
+ "import numpy as np\n",
21
+ "import matplotlib.pyplot as plt\n",
22
+ "import seaborn as sns\n",
23
+ "import tensorflow as tf\n",
24
+ "\n",
25
+ "from tensorflow import keras\n",
26
+ "from sklearn.metrics import confusion_matrix\n",
27
+ "\n",
28
+ "import warnings\n",
29
+ "warnings.filterwarnings('ignore')\n",
30
+ "%matplotlib inline"
31
+ ]
32
+ },
33
+ {
34
+ "cell_type": "code",
35
+ "execution_count": null,
36
+ "metadata": {},
37
+ "outputs": [],
38
+ "source": [
39
+ "import cv2\n",
40
+ "import random as rn\n",
41
+ "from os import listdir\n",
42
+ "from sklearn.preprocessing import LabelBinarizer\n",
43
+ "from keras.models import Sequential\n",
44
+ "from keras.layers import Activation, Flatten, Dropout, Dense\n",
45
+ "from keras import backend as K\n",
46
+ "from keras.preprocessing.image import ImageDataGenerator\n",
47
+ "from keras.preprocessing import image\n",
48
+ "from tensorflow.keras.preprocessing.image import img_to_array\n",
49
+ "from sklearn.preprocessing import MultiLabelBinarizer\n",
50
+ "from sklearn.model_selection import train_test_split\n",
51
+ "import matplotlib.pyplot as plt\n",
52
+ "from numpy.random import seed"
53
+ ]
54
+ },
55
+ {
56
+ "cell_type": "code",
57
+ "execution_count": null,
58
+ "metadata": {},
59
+ "outputs": [],
60
+ "source": [
61
+ "import math\n",
62
+ "import skimage.io\n",
63
+ "import skimage.transform\n",
64
+ "import skimage.filters\n",
65
+ "import keras\n",
66
+ "from skimage import data, exposure, img_as_float"
67
+ ]
68
+ },
69
+ {
70
+ "cell_type": "code",
71
+ "execution_count": null,
72
+ "metadata": {},
73
+ "outputs": [],
74
+ "source": [
75
+ "EPOCHS = 25\n",
76
+ "INIT_LR = 1e-3\n",
77
+ "BS = 32\n",
78
+ "default_image_size = tuple((128, 128))\n",
79
+ "image_size = 0\n",
80
+ "directory_root = r\"C://Users/admin/Downloads/Bean//train\" # Change this to your directory"
81
+ ]
82
+ },
83
+ {
84
+ "cell_type": "code",
85
+ "execution_count": null,
86
+ "metadata": {},
87
+ "outputs": [],
88
+ "source": [
89
+ "def convert_image_to_array(image_dir):\n",
90
+ " try:\n",
91
+ " image = cv2.imread(image_dir)\n",
92
+ " if image is not None :\n",
93
+ " image = cv2.resize(image, default_image_size)\n",
94
+ " return img_to_array(image)\n",
95
+ " else :\n",
96
+ " return np.array([])\n",
97
+ " except Exception as e:\n",
98
+ " print(f\"Error : {e}\")\n",
99
+ " return None"
100
+ ]
101
+ },
102
+ {
103
+ "cell_type": "code",
104
+ "execution_count": null,
105
+ "metadata": {},
106
+ "outputs": [],
107
+ "source": [
108
+ "image_list, label_list = [], []\n",
109
+ "try:\n",
110
+ " print(\"[INFO] Loading images ...\")\n",
111
+ " root_dir = listdir(directory_root)\n",
112
+ " for directory in root_dir :\n",
113
+ " # remove .DS_Store from list\n",
114
+ " if directory == \".DS_Store\" :\n",
115
+ " root_dir.remove(directory)\n",
116
+ "\n",
117
+ " for plant_folder in root_dir :\n",
118
+ " plant_disease_folder_list = listdir(f\"{directory_root}/{plant_folder}\")\n",
119
+ "\n",
120
+ "\n",
121
+ " for plant_disease_folder in plant_disease_folder_list:\n",
122
+ " print(f\"[INFO] Processing {plant_disease_folder} ...\")\n",
123
+ "\n",
124
+ " plant_disease_image_list = listdir(f\"{directory_root}/{plant_folder}/{plant_disease_folder}/\")\n",
125
+ " print(plant_disease_folder)\n",
126
+ " i=len(plant_disease_image_list)\n",
127
+ " print (i)\n",
128
+ " for image in plant_disease_image_list[:10000]:\n",
129
+ " image_directory = f\"{directory_root}/{plant_folder}/{plant_disease_folder}/{image}\"\n",
130
+ " if image_directory.endswith(\".jpg\") == True or image_directory.endswith(\".JPG\") == True:\n",
131
+ " image_list.append(convert_image_to_array(image_directory))\n",
132
+ " label_list.append(plant_disease_folder)\n",
133
+ " elif image_directory.endswith(\".png\") == True or image_directory.endswith(\".PNG\") == True:\n",
134
+ " image_list.append(convert_image_to_array(image_directory))\n",
135
+ " label_list.append(plant_disease_folder)\n",
136
+ " \n",
137
+ " print(\"[INFO] Image loading completed\")\n",
138
+ "except Exception as e:\n",
139
+ " print(f\"Error : {e}\")"
140
+ ]
141
+ },
142
+ {
143
+ "cell_type": "code",
144
+ "execution_count": null,
145
+ "metadata": {},
146
+ "outputs": [],
147
+ "source": [
148
+ "image_size = len(image_list)\n",
149
+ "print(image_size)\n",
150
+ "label_binarizer = LabelBinarizer()\n",
151
+ "image_labels = label_binarizer.fit_transform(label_list)\n",
152
+ "print(image_labels)\n",
153
+ "n_classes = len(label_binarizer.classes_)\n",
154
+ "np_image_list = np.array(image_list, dtype=np.float32) / 225.0\n",
155
+ "print(\"[INFO] Spliting data to train, test\")\n",
156
+ "X_train, X_test, y_train, y_test = train_test_split(np_image_list, image_labels,\n",
157
+ " test_size=0.2, random_state = 42,shuffle=True)\n",
158
+ "\n",
159
+ "print(image_labels)"
160
+ ]
161
+ },
162
+ {
163
+ "cell_type": "code",
164
+ "execution_count": null,
165
+ "metadata": {},
166
+ "outputs": [],
167
+ "source": [
168
+ "plt.imshow(X_train[1])"
169
+ ]
170
+ },
171
+ {
172
+ "cell_type": "code",
173
+ "execution_count": null,
174
+ "metadata": {},
175
+ "outputs": [],
176
+ "source": [
177
+ "# Check the shape of the data\n",
178
+ "X_train.shape, X_test.shape, y_train.shape, y_test.shape"
179
+ ]
180
+ },
181
+ {
182
+ "cell_type": "code",
183
+ "execution_count": null,
184
+ "metadata": {},
185
+ "outputs": [],
186
+ "source": [
187
+ "# Check the data type of the dataset\n",
188
+ "X_train.dtype, X_test.dtype, y_train.dtype, y_test.dtype"
189
+ ]
190
+ },
191
+ {
192
+ "cell_type": "code",
193
+ "execution_count": null,
194
+ "metadata": {},
195
+ "outputs": [],
196
+ "source": [
197
+ "type(y_test)"
198
+ ]
199
+ },
200
+ {
201
+ "cell_type": "code",
202
+ "execution_count": null,
203
+ "metadata": {},
204
+ "outputs": [],
205
+ "source": [
206
+ "# Build the sequential model\n",
207
+ "\n",
208
+ "model=tf.keras.Sequential([\n",
209
+ " tf.keras.layers.Flatten(input_shape=(128,128,3)),\n",
210
+ " tf.keras.layers.Dense(128,activation='relu'),\n",
211
+ " tf.keras.layers.Dense(128,activation='relu'),\n",
212
+ " tf.keras.layers.Dense(128,activation='relu'),\n",
213
+ " tf.keras.layers.Dense(256,activation='relu'),\n",
214
+ " tf.keras.layers.Dense(3,activation='softmax')\n",
215
+ "])"
216
+ ]
217
+ },
218
+ {
219
+ "cell_type": "code",
220
+ "execution_count": null,
221
+ "metadata": {},
222
+ "outputs": [],
223
+ "source": [
224
+ "# Check model summary\n",
225
+ "model.summary()"
226
+ ]
227
+ },
228
+ {
229
+ "cell_type": "code",
230
+ "execution_count": null,
231
+ "metadata": {},
232
+ "outputs": [],
233
+ "source": [
234
+ "# Compile the model\n",
235
+ "\n",
236
+ "model.compile(loss = tf.keras.losses.CategoricalCrossentropy(),\n",
237
+ " optimizer = tf.keras.optimizers.Adam(), metrics = ['accuracy'])"
238
+ ]
239
+ },
240
+ {
241
+ "cell_type": "code",
242
+ "execution_count": null,
243
+ "metadata": {},
244
+ "outputs": [],
245
+ "source": [
246
+ "# Fit the model\n",
247
+ "\n",
248
+ "model_history = model.fit(X_train, y_train, validation_data = (X_test, y_test), epochs = 50)"
249
+ ]
250
+ },
251
+ {
252
+ "cell_type": "code",
253
+ "execution_count": null,
254
+ "metadata": {},
255
+ "outputs": [],
256
+ "source": [
257
+ "# Evaluate the model\n",
258
+ "\n",
259
+ "model.evaluate(X_test, y_test)"
260
+ ]
261
+ },
262
+ {
263
+ "cell_type": "code",
264
+ "execution_count": null,
265
+ "metadata": {},
266
+ "outputs": [],
267
+ "source": [
268
+ "from tensorflow.keras.utils import plot_model\n",
269
+ "\n",
270
+ "plot_model(model, show_shapes = True)"
271
+ ]
272
+ },
273
+ {
274
+ "cell_type": "code",
275
+ "execution_count": null,
276
+ "metadata": {},
277
+ "outputs": [],
278
+ "source": [
279
+ "plt.figure(figsize = (12, 6))\n",
280
+ "plt.style.use('fivethirtyeight')\n",
281
+ "train_loss = model_history.history['loss']\n",
282
+ "val_loss = model_history.history['val_loss'] \n",
283
+ "epoch = range(1, 51)\n",
284
+ "sns.lineplot(epoch, train_loss, label = 'Training Loss')\n",
285
+ "sns.lineplot(epoch, val_loss, label = 'Validation Loss')\n",
286
+ "plt.title('Training and Validation Loss\\n')\n",
287
+ "plt.xlabel('Epochs')\n",
288
+ "plt.ylabel('Loss')\n",
289
+ "plt.legend(loc = 'best')\n",
290
+ "plt.show()"
291
+ ]
292
+ },
293
+ {
294
+ "cell_type": "code",
295
+ "execution_count": null,
296
+ "metadata": {},
297
+ "outputs": [],
298
+ "source": [
299
+ "plt.figure(figsize = (12, 6))\n",
300
+ "\n",
301
+ "train_loss = model_history.history['accuracy']\n",
302
+ "val_loss = model_history.history['val_accuracy'] \n",
303
+ "epoch = range(1, 51)\n",
304
+ "sns.lineplot(epoch, train_loss, label = 'Training accuracy')\n",
305
+ "sns.lineplot(epoch, val_loss, label = 'Validation accuracy')\n",
306
+ "plt.title('Training and Validation Accuracy\\n')\n",
307
+ "plt.xlabel('Epochs')\n",
308
+ "plt.ylabel('Accuracy')\n",
309
+ "plt.legend(loc = 'best')\n",
310
+ "plt.show()"
311
+ ]
312
+ },
313
+ {
314
+ "cell_type": "code",
315
+ "execution_count": null,
316
+ "metadata": {},
317
+ "outputs": [],
318
+ "source": [
319
+ "# Making predictions\n",
320
+ "\n",
321
+ "y_probs = model.predict(X_test)\n",
322
+ "y_preds = y_probs.argmax(axis = 1)\n",
323
+ "\n",
324
+ "y_preds[:100]"
325
+ ]
326
+ },
327
+ {
328
+ "cell_type": "code",
329
+ "execution_count": null,
330
+ "metadata": {},
331
+ "outputs": [],
332
+ "source": [
333
+ "label = ['angular_leaf_spot', \n",
334
+ "'bean_rust' , \n",
335
+ "'healthy' , \n",
336
+ " ]\n",
337
+ "Ypred = model.predict(X_test)\n",
338
+ "\n",
339
+ "Ypred = np.argmax(Ypred, axis=1)\n",
340
+ "Ytrue = np.argmax(y_test, axis=1)\n",
341
+ "\n",
342
+ "cm = confusion_matrix(Ytrue, Ypred)\n",
343
+ "plt.figure(figsize=(12, 12))\n",
344
+ "ax = sns.heatmap(cm, cmap=\"rocket_r\", fmt=\".01f\",annot_kws={'size':24}, annot=True, square=True, xticklabels=label, yticklabels=label)\n",
345
+ "ax.set_ylabel('Actual', fontsize=20)\n",
346
+ "ax.set_xlabel('Predicted', fontsize=20)"
347
+ ]
348
+ },
349
+ {
350
+ "cell_type": "code",
351
+ "execution_count": null,
352
+ "metadata": {},
353
+ "outputs": [],
354
+ "source": [
355
+ "from sklearn.metrics import confusion_matrix, classification_report\n",
356
+ "\n",
357
+ "print('Classification Report:')\n",
358
+ "print(classification_report(Ytrue, Ypred))"
359
+ ]
360
+ }
361
+ ],
362
+ "metadata": {
363
+ "kaggle": {
364
+ "accelerator": "gpu",
365
+ "dataSources": [
366
+ {
367
+ "datasetId": 2243,
368
+ "sourceId": 9243,
369
+ "sourceType": "datasetVersion"
370
+ }
371
+ ],
372
+ "dockerImageVersionId": 30097,
373
+ "isGpuEnabled": true,
374
+ "isInternetEnabled": true,
375
+ "language": "python",
376
+ "sourceType": "notebook"
377
+ },
378
+ "kernelspec": {
379
+ "display_name": "Python 3 (ipykernel)",
380
+ "language": "python",
381
+ "name": "python3"
382
+ },
383
+ "language_info": {
384
+ "codemirror_mode": {
385
+ "name": "ipython",
386
+ "version": 3
387
+ },
388
+ "file_extension": ".py",
389
+ "mimetype": "text/x-python",
390
+ "name": "python",
391
+ "nbconvert_exporter": "python",
392
+ "pygments_lexer": "ipython3",
393
+ "version": "3.12.4"
394
+ }
395
+ },
396
+ "nbformat": 4,
397
+ "nbformat_minor": 4
398
+ }