File size: 47,807 Bytes
e76e1f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import numpy as np\n",
    "import tensorflow as tf\n",
    "from tensorflow.keras.preprocessing.image import load_img, img_to_array\n",
    "from tensorflow.keras.applications import ResNet152V2, MobileNet\n",
    "from tensorflow.keras.layers import Dense, GlobalAveragePooling2D\n",
    "from tensorflow.keras.models import Model\n",
    "from tensorflow.keras.optimizers import Adam\n",
    "from tensorflow.keras.utils import Sequence\n",
    "from sklearn.utils import shuffle\n",
    "import glob"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Check TensorFlow and GPU setup\n",
    "print(\"TensorFlow version:\", tf.__version__)\n",
    "print(\"GPUs available:\", tf.config.list_physical_devices('GPU'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Dataset Paths\n",
    "CANCER_PATH = '/kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER'\n",
    "NON_CANCER_PATH = '/kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/NON CANCER'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Parameters\n",
    "IMG_SIZE = (224, 224)\n",
    "BATCH_SIZE = 32"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Safe Data Generator\n",
    "class SafeDataGenerator(Sequence):\n",
    "    def __init__(self, file_paths, labels, batch_size, target_size=(224, 224)):\n",
    "        self.file_paths = file_paths\n",
    "        self.labels = labels\n",
    "        self.batch_size = batch_size\n",
    "        self.target_size = target_size\n",
    "\n",
    "    def __len__(self):\n",
    "        return len(self.file_paths) // self.batch_size\n",
    "\n",
    "    def __getitem__(self, idx):\n",
    "        batch_paths = self.file_paths[idx * self.batch_size:(idx + 1) * self.batch_size]\n",
    "        batch_labels = self.labels[idx * self.batch_size:(idx + 1) * self.batch_size]\n",
    "        images, labels = [], []\n",
    "        for path, label in zip(batch_paths, batch_labels):\n",
    "            try:\n",
    "                img = load_img(path, target_size=self.target_size)\n",
    "                img_array = img_to_array(img) / 255.0  # Normalize\n",
    "                images.append(img_array)\n",
    "                labels.append(label)\n",
    "            except Exception as e:\n",
    "                print(f\"Skipping corrupted file: {path}, Error: {e}\")\n",
    "        return np.array(images), np.array(labels)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Collect file paths\n",
    "cancer_files = glob.glob(f\"{CANCER_PATH}/*.jpeg\")\n",
    "non_cancer_files = glob.glob(f\"{NON_CANCER_PATH}/*.jpeg\")\n",
    "\n",
    "file_paths = cancer_files + non_cancer_files\n",
    "labels = [1] * len(cancer_files) + [0] * len(non_cancer_files)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Shuffle dataset\n",
    "file_paths, labels = shuffle(file_paths, labels, random_state=42)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Split into training and validation\n",
    "split_idx = int(len(file_paths) * 0.8)\n",
    "train_paths, val_paths = file_paths[:split_idx], file_paths[split_idx:]\n",
    "train_labels, val_labels = labels[:split_idx], labels[split_idx:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create generators\n",
    "train_generator = SafeDataGenerator(train_paths, train_labels, batch_size=BATCH_SIZE, target_size=IMG_SIZE)\n",
    "val_generator = SafeDataGenerator(val_paths, val_labels, batch_size=BATCH_SIZE, target_size=IMG_SIZE)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Define ResNet152V2 Model\n",
    "def build_resnet152v2(input_shape=(224, 224, 3)):\n",
    "    base_model = ResNet152V2(weights='imagenet', include_top=False, input_shape=input_shape)\n",
    "    x = GlobalAveragePooling2D()(base_model.output)\n",
    "    x = Dense(128, activation='relu')(x)\n",
    "    x = Dense(1, activation='sigmoid')(x)  # Binary classification\n",
    "    model = Model(inputs=base_model.input, outputs=x)\n",
    "\n",
    "    # Freeze base model layers\n",
    "    for layer in base_model.layers:\n",
    "        layer.trainable = False\n",
    "\n",
    "    model.compile(optimizer=Adam(learning_rate=0.001),\n",
    "                  loss='binary_crossentropy',\n",
    "                  metrics=['accuracy'])\n",
    "    return model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Define MobileNet Model\n",
    "def build_mobilenet(input_shape=(224, 224, 3)):\n",
    "    base_model = MobileNet(weights='imagenet', include_top=False, input_shape=input_shape)\n",
    "    x = GlobalAveragePooling2D()(base_model.output)\n",
    "    x = Dense(128, activation='relu')(x)\n",
    "    x = Dense(1, activation='sigmoid')(x)  # Binary classification\n",
    "    model = Model(inputs=base_model.input, outputs=x)\n",
    "\n",
    "    # Freeze base model layers\n",
    "    for layer in base_model.layers:\n",
    "        layer.trainable = False\n",
    "\n",
    "    model.compile(optimizer=Adam(learning_rate=0.001),\n",
    "                  loss='binary_crossentropy',\n",
    "                  metrics=['accuracy'])\n",
    "    return model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Build Models\n",
    "resnet_model = build_resnet152v2()\n",
    "mobilenet_model = build_mobilenet()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Train ResNet152V2\n",
    "history_resnet = resnet_model.fit(\n",
    "    train_generator,\n",
    "    epochs=10,\n",
    "    validation_data=val_generator,\n",
    "    steps_per_epoch=len(train_generator),\n",
    "    validation_steps=len(val_generator)\n",
    ")\n",
    "\n",
    "# Save ResNet152V2 Model\n",
    "resnet_model.save(\"/kaggle/working/resnet152v2_oral_cancer.h5\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Train MobileNet\n",
    "history_mobilenet = mobilenet_model.fit(\n",
    "    train_generator,\n",
    "    epochs=10,\n",
    "    validation_data=val_generator,\n",
    "    steps_per_epoch=len(train_generator),\n",
    "    validation_steps=len(val_generator)\n",
    ")\n",
    "\n",
    "# Save MobileNet Model\n",
    "mobilenet_model.save(\"/kaggle/working/mobilenet_oral_cancer.h5\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-01-28T12:51:18.511395Z",
     "iopub.status.busy": "2025-01-28T12:51:18.511095Z",
     "iopub.status.idle": "2025-01-28T12:55:03.294121Z",
     "shell.execute_reply": "2025-01-28T12:55:03.293343Z",
     "shell.execute_reply.started": "2025-01-28T12:51:18.511372Z"
    },
    "trusted": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "TensorFlow version: 2.17.1\n",
      "GPUs available: [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU'), PhysicalDevice(name='/physical_device:GPU:1', device_type='GPU')]\n",
      "Downloading data from https://storage.googleapis.com/tensorflow/keras-applications/resnet/resnet152v2_weights_tf_dim_ordering_tf_kernels_notop.h5\n",
      "\u001b[1m234545216/234545216\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m1s\u001b[0m 0us/step\n",
      "Downloading data from https://storage.googleapis.com/tensorflow/keras-applications/mobilenet/mobilenet_1_0_224_tf_no_top.h5\n",
      "\u001b[1m17225924/17225924\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 0us/step\n",
      "Epoch 1/10\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/local/lib/python3.10/dist-packages/keras/src/trainers/data_adapters/py_dataset_adapter.py:122: UserWarning: Your `PyDataset` class should call `super().__init__(**kwargs)` in its constructor. `**kwargs` can include `workers`, `use_multiprocessing`, `max_queue_size`. Do not pass these arguments to `fit()`, as they will be ignored.\n",
      "  self._warn_if_super_not_called()\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/273.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892883e2f0>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/101.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892883e570>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/407.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892883e340>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/481.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7889289dfc40>\n",
      "\u001b[1m 1/23\u001b[0m \u001b[37m━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[1m12:28\u001b[0m 34s/step - accuracy: 0.3871 - loss: 0.9560Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/200.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7889289dfc40>\n",
      "\u001b[1m 7/23\u001b[0m \u001b[32m━━━━━━\u001b[0m\u001b[37m━━━━━━━━━━━━━━\u001b[0m \u001b[1m56s\u001b[0m 4s/step - accuracy: 0.6386 - loss: 0.6414 Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/328.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892883ee80>\n",
      "\u001b[1m 9/23\u001b[0m \u001b[32m━━━━━━━\u001b[0m\u001b[37m━━━━━━━━━━━━━\u001b[0m \u001b[1m38s\u001b[0m 3s/step - accuracy: 0.6640 - loss: 0.6185Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/450.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892883ede0>\n",
      "\u001b[1m12/23\u001b[0m \u001b[32m━━━━━━━━━━\u001b[0m\u001b[37m━━━━━━━━━━\u001b[0m \u001b[1m24s\u001b[0m 2s/step - accuracy: 0.6883 - loss: 0.6052Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/317.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892883eed0>\n",
      "\u001b[1m13/23\u001b[0m \u001b[32m━━━━━━━━━━━\u001b[0m\u001b[37m━━━━━━━━━\u001b[0m \u001b[1m20s\u001b[0m 2s/step - accuracy: 0.6947 - loss: 0.6012Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/455.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892883f3d0>\n",
      "\u001b[1m23/23\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 1s/step - accuracy: 0.7369 - loss: 0.5619"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/local/lib/python3.10/dist-packages/PIL/Image.py:1054: UserWarning: Palette images with Transparency expressed in bytes should be converted to RGBA images\n",
      "  warnings.warn(\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/485.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f0777560>\n",
      "\u001b[1m23/23\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m79s\u001b[0m 2s/step - accuracy: 0.7399 - loss: 0.5586 - val_accuracy: 0.8868 - val_loss: 0.2889\n",
      "Epoch 2/10\n",
      "\u001b[1m23/23\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 5ms/step - accuracy: 0.0000e+00 - loss: 0.0000e+00\n",
      "Epoch 3/10\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/lib/python3.10/contextlib.py:153: UserWarning: Your input ran out of data; interrupting training. Make sure that your dataset or generator can generate at least `steps_per_epoch * epochs` batches. You may need to use the `.repeat()` function when building your dataset.\n",
      "  self.gen.throw(typ, value, traceback)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/101.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f0617650>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/328.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f0617830>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/407.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f0617970>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/481.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f0617830>\n",
      "\u001b[1m 2/23\u001b[0m \u001b[32m━\u001b[0m\u001b[37m━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[1m8s\u001b[0m 421ms/step - accuracy: 0.9439 - loss: 0.1772Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/273.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f0617dd0>\n",
      "\u001b[1m10/23\u001b[0m \u001b[32m━━━━━━━━\u001b[0m\u001b[37m━━━━━━━━━━━━\u001b[0m \u001b[1m4s\u001b[0m 327ms/step - accuracy: 0.9419 - loss: 0.1812Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/450.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f062c360>\n",
      "\u001b[1m11/23\u001b[0m \u001b[32m━━━━━━━━━\u001b[0m\u001b[37m━━━━━━━━━━━\u001b[0m \u001b[1m3s\u001b[0m 330ms/step - accuracy: 0.9422 - loss: 0.1801Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/200.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f062c680>\n",
      "\u001b[1m13/23\u001b[0m \u001b[32m━━━━━━━━━━━\u001b[0m\u001b[37m━━━━━━━━━\u001b[0m \u001b[1m3s\u001b[0m 315ms/step - accuracy: 0.9426 - loss: 0.1788Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/317.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f062c590>\n",
      "\u001b[1m14/23\u001b[0m \u001b[32m━━━━━━━━━━━━\u001b[0m\u001b[37m━━━━━━━━\u001b[0m \u001b[1m2s\u001b[0m 307ms/step - accuracy: 0.9428 - loss: 0.1786Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/455.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f062c6d0>\n",
      "\u001b[1m23/23\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 265ms/step - accuracy: 0.9419 - loss: 0.1794Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/485.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f0777600>\n",
      "\u001b[1m23/23\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m11s\u001b[0m 364ms/step - accuracy: 0.9417 - loss: 0.1796 - val_accuracy: 0.9057 - val_loss: 0.2701\n",
      "Epoch 4/10\n",
      "\u001b[1m23/23\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 1ms/step - accuracy: 0.0000e+00 - loss: 0.0000e+00\n",
      "Epoch 5/10\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/328.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f062cc70>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/317.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f062d260>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/455.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f0777600>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/101.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f062d3a0>\n",
      "\u001b[1m 5/23\u001b[0m \u001b[32m━━━━\u001b[0m\u001b[37m━━━━━━━━━━━━━━━━\u001b[0m \u001b[1m5s\u001b[0m 281ms/step - accuracy: 0.9503 - loss: 0.1660Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/273.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f062cf40>\n",
      "\u001b[1m 6/23\u001b[0m \u001b[32m━━━━━\u001b[0m\u001b[37m━━━━━━━━━━━━━━━\u001b[0m \u001b[1m5s\u001b[0m 312ms/step - accuracy: 0.9524 - loss: 0.1633Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/450.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f062d670>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/200.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f062db20>\n",
      "\u001b[1m12/23\u001b[0m \u001b[32m━━━━━━━━━━\u001b[0m\u001b[37m━━━━━━━━━━\u001b[0m \u001b[1m3s\u001b[0m 314ms/step - accuracy: 0.9565 - loss: 0.1535Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/407.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f062de40>\n",
      "\u001b[1m13/23\u001b[0m \u001b[32m━━━━━━━━━━━\u001b[0m\u001b[37m━━━━━━━━━\u001b[0m \u001b[1m3s\u001b[0m 333ms/step - accuracy: 0.9571 - loss: 0.1517Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/481.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f062e020>\n",
      "\u001b[1m23/23\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 279ms/step - accuracy: 0.9616 - loss: 0.1378Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/485.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f062e700>\n",
      "\u001b[1m23/23\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m12s\u001b[0m 377ms/step - accuracy: 0.9617 - loss: 0.1370 - val_accuracy: 0.9057 - val_loss: 0.2537\n",
      "Epoch 6/10\n",
      "\u001b[1m23/23\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 2ms/step - accuracy: 0.0000e+00 - loss: 0.0000e+00\n",
      "Epoch 7/10\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/200.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f062ea20>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/450.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f062eb60>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/101.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f062ec00>\n",
      "\u001b[1m 2/23\u001b[0m \u001b[32m━\u001b[0m\u001b[37m━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[1m5s\u001b[0m 249ms/step - accuracy: 0.9519 - loss: 0.0861Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/273.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f062eed0>\n",
      "\u001b[1m 3/23\u001b[0m \u001b[32m━━\u001b[0m\u001b[37m━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[1m6s\u001b[0m 308ms/step - accuracy: 0.9609 - loss: 0.0776Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/328.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f062f010>\n",
      "\u001b[1m 5/23\u001b[0m \u001b[32m━━━━\u001b[0m\u001b[37m━━━━━━━━━━━━━━━━\u001b[0m \u001b[1m5s\u001b[0m 295ms/step - accuracy: 0.9683 - loss: 0.0721Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/407.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f062f150>\n",
      "\u001b[1m 6/23\u001b[0m \u001b[32m━━━━━\u001b[0m\u001b[37m━━━━━━━━━━━━━━━\u001b[0m \u001b[1m4s\u001b[0m 279ms/step - accuracy: 0.9692 - loss: 0.0733Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/481.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f062c040>\n",
      "\u001b[1m14/23\u001b[0m \u001b[32m━━━━━━━━━━━━\u001b[0m\u001b[37m━━━━━━━━\u001b[0m \u001b[1m3s\u001b[0m 343ms/step - accuracy: 0.9724 - loss: 0.0786Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/317.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f062ecf0>\n",
      "\u001b[1m15/23\u001b[0m \u001b[32m━━━━━━━━━━━━━\u001b[0m\u001b[37m━━━━━━━\u001b[0m \u001b[1m2s\u001b[0m 345ms/step - accuracy: 0.9726 - loss: 0.0789Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/455.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f062f740>\n",
      "\u001b[1m23/23\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 292ms/step - accuracy: 0.9738 - loss: 0.0811Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/485.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f062fd80>\n",
      "\u001b[1m23/23\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m11s\u001b[0m 397ms/step - accuracy: 0.9740 - loss: 0.0811 - val_accuracy: 0.8868 - val_loss: 0.2439\n",
      "Epoch 8/10\n",
      "\u001b[1m23/23\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 2ms/step - accuracy: 0.0000e+00 - loss: 0.0000e+00\n",
      "Epoch 9/10\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/317.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f06441d0>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/455.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f062f6a0>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/200.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f062f6a0>\n",
      "\u001b[1m 1/23\u001b[0m \u001b[37m━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[1m56s\u001b[0m 3s/step - accuracy: 1.0000 - loss: 0.0521Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/407.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f0644540>\n",
      "\u001b[1m 2/23\u001b[0m \u001b[32m━\u001b[0m\u001b[37m━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[1m15s\u001b[0m 733ms/step - accuracy: 1.0000 - loss: 0.0473Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/481.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f0644180>\n",
      "\u001b[1m 3/23\u001b[0m \u001b[32m━━\u001b[0m\u001b[37m━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[1m10s\u001b[0m 532ms/step - accuracy: 1.0000 - loss: 0.0434Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/273.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f0644040>\n",
      "\u001b[1m 4/23\u001b[0m \u001b[32m━━━\u001b[0m\u001b[37m━━━━━━━━━━━━━━━━━\u001b[0m \u001b[1m9s\u001b[0m 483ms/step - accuracy: 0.9960 - loss: 0.0448 Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/101.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f0644040>\n",
      "\u001b[1m 5/23\u001b[0m \u001b[32m━━━━\u001b[0m\u001b[37m━━━━━━━━━━━━━━━━\u001b[0m \u001b[1m9s\u001b[0m 503ms/step - accuracy: 0.9943 - loss: 0.0448Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/328.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f0644360>\n",
      "\u001b[1m10/23\u001b[0m \u001b[32m━━━━━━━━\u001b[0m\u001b[37m━━━━━━━━━━━━\u001b[0m \u001b[1m5s\u001b[0m 390ms/step - accuracy: 0.9896 - loss: 0.0472Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/450.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f0644860>\n",
      "\u001b[1m23/23\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 304ms/step - accuracy: 0.9881 - loss: 0.0508Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/485.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x7888f0645120>\n",
      "\u001b[1m23/23\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m11s\u001b[0m 402ms/step - accuracy: 0.9881 - loss: 0.0509 - val_accuracy: 0.9057 - val_loss: 0.2370\n",
      "Epoch 10/10\n",
      "\u001b[1m23/23\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 1ms/step - accuracy: 0.0000e+00 - loss: 0.0000e+00\n",
      "Epoch 1/10\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/328.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892bb93290>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/101.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892bb93380>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/317.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892bb931f0>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/455.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892bb93240>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/200.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892bb93790>\n",
      "\u001b[1m 1/23\u001b[0m \u001b[37m━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[1m3:36\u001b[0m 10s/step - accuracy: 0.7097 - loss: 0.5852Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/407.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892bb939c0>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/481.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892bb93a60>\n",
      "\u001b[1m 7/23\u001b[0m \u001b[32m━━━━━━\u001b[0m\u001b[37m━━━━━━━━━━━━━━\u001b[0m \u001b[1m25s\u001b[0m 2s/step - accuracy: 0.7169 - loss: 0.5594Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/450.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892bb93dd0>\n",
      "\u001b[1m14/23\u001b[0m \u001b[32m━━━━━━━━━━━━\u001b[0m\u001b[37m━━━━━━━━\u001b[0m \u001b[1m8s\u001b[0m 912ms/step - accuracy: 0.7475 - loss: 0.5249Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/273.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892bbac180>\n",
      "\u001b[1m22/23\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 609ms/step - accuracy: 0.7693 - loss: 0.4918Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/485.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892bb939c0>\n",
      "\u001b[1m23/23\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m28s\u001b[0m 828ms/step - accuracy: 0.7741 - loss: 0.4839 - val_accuracy: 0.8302 - val_loss: 0.3507\n",
      "Epoch 2/10\n",
      "\u001b[1m23/23\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 1ms/step - accuracy: 0.0000e+00 - loss: 0.0000e+00\n",
      "Epoch 3/10\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/273.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a2f8a40>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/200.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892bbaef20>\n",
      "\u001b[1m 3/23\u001b[0m \u001b[32m━━\u001b[0m\u001b[37m━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[1m5s\u001b[0m 270ms/step - accuracy: 0.8403 - loss: 0.2648Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/450.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a2f8ea0>\n",
      "\u001b[1m 5/23\u001b[0m \u001b[32m━━━━\u001b[0m\u001b[37m━━━━━━━━━━━━━━━━\u001b[0m \u001b[1m5s\u001b[0m 287ms/step - accuracy: 0.8598 - loss: 0.2512Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/328.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a2f92b0>\n",
      "\u001b[1m 7/23\u001b[0m \u001b[32m━━━━━━\u001b[0m\u001b[37m━━━━━━━━━━━━━━\u001b[0m \u001b[1m4s\u001b[0m 277ms/step - accuracy: 0.8690 - loss: 0.2440Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/407.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a2f89f0>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/481.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a2f9440>\n",
      "\u001b[1m 9/23\u001b[0m \u001b[32m━━━━━━━\u001b[0m\u001b[37m━━━━━━━━━━━━━\u001b[0m \u001b[1m3s\u001b[0m 263ms/step - accuracy: 0.8738 - loss: 0.2404Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/317.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a2f9120>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/455.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a2f96c0>\n",
      "\u001b[1m13/23\u001b[0m \u001b[32m━━━━━━━━━━━\u001b[0m\u001b[37m━━━━━━━━━\u001b[0m \u001b[1m3s\u001b[0m 315ms/step - accuracy: 0.8806 - loss: 0.2354Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/101.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a2f9800>\n",
      "\u001b[1m22/23\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 232ms/step - accuracy: 0.8880 - loss: 0.2344Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/485.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a2fa250>\n",
      "\u001b[1m23/23\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m10s\u001b[0m 311ms/step - accuracy: 0.8890 - loss: 0.2339 - val_accuracy: 0.8553 - val_loss: 0.3244\n",
      "Epoch 4/10\n",
      "\u001b[1m23/23\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 549us/step - accuracy: 0.0000e+00 - loss: 0.0000e+00\n",
      "Epoch 5/10\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/101.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a2fa660>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/273.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892bb93b00>\n",
      "\u001b[1m 5/23\u001b[0m \u001b[32m━━━━\u001b[0m\u001b[37m━━━━━━━━━━━━━━━━\u001b[0m \u001b[1m4s\u001b[0m 255ms/step - accuracy: 0.9116 - loss: 0.1889Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/450.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a2fb060>\n",
      "\u001b[1m 6/23\u001b[0m \u001b[32m━━━━━\u001b[0m\u001b[37m━━━━━━━━━━━━━━━\u001b[0m \u001b[1m4s\u001b[0m 270ms/step - accuracy: 0.9159 - loss: 0.1820Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/200.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a2fa7f0>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/328.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a2fa980>\n",
      "\u001b[1m 9/23\u001b[0m \u001b[32m━━━━━━━\u001b[0m\u001b[37m━━━━━━━━━━━━━\u001b[0m \u001b[1m4s\u001b[0m 328ms/step - accuracy: 0.9235 - loss: 0.1682Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/317.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a2faf70>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/455.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a2fa0c0>\n",
      "\u001b[1m15/23\u001b[0m \u001b[32m━━━━━━━━━━━━━\u001b[0m\u001b[37m━━━━━━━\u001b[0m \u001b[1m2s\u001b[0m 334ms/step - accuracy: 0.9311 - loss: 0.1527Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/407.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a2fb5b0>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/481.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a2fb650>\n",
      "\u001b[1m22/23\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 248ms/step - accuracy: 0.9352 - loss: 0.1472Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/485.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a2fbc40>\n",
      "\u001b[1m23/23\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m10s\u001b[0m 326ms/step - accuracy: 0.9358 - loss: 0.1469 - val_accuracy: 0.8994 - val_loss: 0.2897\n",
      "Epoch 6/10\n",
      "\u001b[1m23/23\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 583us/step - accuracy: 0.0000e+00 - loss: 0.0000e+00\n",
      "Epoch 7/10\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/273.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a2fa7f0>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/450.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a2fa2f0>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/317.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a2fbd80>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/455.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a2fa7f0>\n",
      "\u001b[1m 8/23\u001b[0m \u001b[32m━━━━━━\u001b[0m\u001b[37m━━━━━━━━━━━━━━\u001b[0m \u001b[1m4s\u001b[0m 298ms/step - accuracy: 0.9654 - loss: 0.0936Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/200.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a2fb600>\n",
      "\u001b[1m10/23\u001b[0m \u001b[32m━━━━━━━━\u001b[0m\u001b[37m━━━━━━━━━━━━\u001b[0m \u001b[1m3s\u001b[0m 285ms/step - accuracy: 0.9663 - loss: 0.0933Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/101.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a11c6d0>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/328.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a11ca40>\n",
      "\u001b[1m13/23\u001b[0m \u001b[32m━━━━━━━━━━━\u001b[0m\u001b[37m━━━━━━━━━\u001b[0m \u001b[1m2s\u001b[0m 279ms/step - accuracy: 0.9670 - loss: 0.0934Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/407.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a2fb600>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/481.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a11c6d0>\n",
      "\u001b[1m22/23\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 233ms/step - accuracy: 0.9681 - loss: 0.0954Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/485.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a11cc70>\n",
      "\u001b[1m23/23\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m9s\u001b[0m 309ms/step - accuracy: 0.9681 - loss: 0.0957 - val_accuracy: 0.8994 - val_loss: 0.2943\n",
      "Epoch 8/10\n",
      "\u001b[1m23/23\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 566us/step - accuracy: 0.0000e+00 - loss: 0.0000e+00\n",
      "Epoch 9/10\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/450.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a11d3a0>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/328.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a11d5d0>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/200.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a2f9670>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/273.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a11cd60>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/101.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a11cd60>\n",
      "\u001b[1m 1/23\u001b[0m \u001b[37m━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[1m1:00\u001b[0m 3s/step - accuracy: 1.0000 - loss: 0.0286Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/407.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a11cc70>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/481.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a11cc70>\n",
      "\u001b[1m 5/23\u001b[0m \u001b[32m━━━━\u001b[0m\u001b[37m━━━━━━━━━━━━━━━━\u001b[0m \u001b[1m5s\u001b[0m 320ms/step - accuracy: 0.9840 - loss: 0.0508Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/317.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a11dc60>\n",
      "Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/455.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a11dd00>\n",
      "\u001b[1m22/23\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 231ms/step - accuracy: 0.9814 - loss: 0.0634Skipping corrupted file: /kaggle/input/oral-cancer-dataset/Oral cancer Dataset 2.0/OC Dataset kaggle new/CANCER/485.jpeg, Error: cannot identify image file <_io.BytesIO object at 0x78892a11e480>\n",
      "\u001b[1m23/23\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m10s\u001b[0m 310ms/step - accuracy: 0.9812 - loss: 0.0640 - val_accuracy: 0.8805 - val_loss: 0.3013\n",
      "Epoch 10/10\n",
      "\u001b[1m23/23\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 800us/step - accuracy: 0.0000e+00 - loss: 0.0000e+00\n"
     ]
    }
   ],
   "source": [
    "# Results"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Custom Prediction Function\n",
    "def predict_custom_image(model_path, image_path):\n",
    "    model = tf.keras.models.load_model(model_path)\n",
    "    image = load_img(image_path, target_size=IMG_SIZE)\n",
    "    image_array = img_to_array(image) / 255.0\n",
    "    image_array = np.expand_dims(image_array, axis=0)  # Add batch dimension\n",
    "\n",
    "    prediction = model.predict(image_array)\n",
    "    class_name = 'Cancer' if prediction[0][0] > 0.5 else 'Non-Cancer'\n",
    "    print(f\"Prediction: {class_name}, Confidence: {prediction[0][0]:.2f}\")\n",
    "\n",
    "# Example Usage \n",
    "predict_custom_image(\"/kaggle/working/resnet152v2_oral_cancer.h5\", \"/path/to/custom/image.jpg\")\n",
    "predict_custom_image(\"/kaggle/working/mobilenet_oral_cancer.h5\", \"/path/to/custom/image.jpg\")"
   ]
  }
 ],
 "metadata": {
  "kaggle": {
   "accelerator": "nvidiaTeslaT4",
   "dataSources": [
    {
     "datasetId": 4426002,
     "sourceId": 7716037,
     "sourceType": "datasetVersion"
    }
   ],
   "dockerImageVersionId": 30840,
   "isGpuEnabled": true,
   "isInternetEnabled": true,
   "language": "python",
   "sourceType": "notebook"
  },
  "kernelspec": {
   "display_name": "100p",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.20"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}