File size: 6,024 Bytes
1bf8e35 f688cae 68bd7a1 f688cae ab4ee71 f688cae ab4ee71 f688cae 2aa36ca f688cae 2aa36ca f688cae 1bf8e35 |
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 |
---
library_name: keras
tags:
- image-classification
- spam-detectio
metrics:
- accuracy
base_model:
- keras-io/VGG19
---
# Image Spam Detection with VGG19
This is a model for detecting spam in images using transfer learning, with a VGG19 base model fine-tuned on the [Image Spam Hunter Dataset](https://example-dataset-link.com).
---
## Model Description
This model is built for binary classification, detecting whether an image is spam or not. The VGG19 architecture was used as the base model for transfer learning, leveraging pre-trained weights from ImageNet. The final layers were customised to include a GlobalAveragePooling layer, followed by fully connected layers, and a softmax activation for classification.
- **Base Model**: VGG19
- **Task**: Binary classification (Spam / Not Spam)
- **Framework**: Keras (TensorFlow backend)
---
## Training and Evaluation Data
### Dataset
The model was trained and evaluated on the **Image Spam Hunter Dataset**, a publicly available dataset that contains spam and non-spam images:
- **Training set**: 1731 images
- **Validation set**: 1385 images
You can find more about the dataset [here](https://users.cs.northwestern.edu/~yga751/ML/).
---
## Training Procedure
### Preprocessing
- Images were resized to 256x256.
- Normalisation was applied to scale pixel values between 0 and 1.
### Optimizer
- **Optimizer**: Adam
- **Learning Rate**: 0.001
### Training Parameters
- **Batch Size**: 128
- **Epochs**: 26 (early stopping)
### Loss Function
- Binary Cross-Entropy Loss
### Augmentations
- Random augmentation using Keras CV RandAugment layer.
---
## Training Metrics
Below is a summary of the model's performance over the training process:
| | FN | FP | TN | TP | accuracy | loss | val_FN | val_FP | val_TN | val_TP | val_accuracy | val_loss |
|---:|-----:|-----:|-----:|-----:|-----------:|----------:|---------:|---------:|---------:|---------:|---------------:|-----------:|
| 0 | 187 | 140 | 499 | 559 | 0.763899 | 1.93435 | 19 | 2 | 169 | 156 | 0.939306 | 0.378412 |
| 1 | 16 | 35 | 604 | 730 | 0.963177 | 0.242954 | 6 | 3 | 168 | 169 | 0.973988 | 0.186523 |
| 2 | 29 | 19 | 620 | 717 | 0.965343 | 0.174301 | 3 | 12 | 159 | 172 | 0.956647 | 0.149353 |
| 3 | 17 | 26 | 613 | 729 | 0.968953 | 0.116907 | 3 | 7 | 164 | 172 | 0.971098 | 0.0973678 |
| 4 | 14 | 17 | 622 | 732 | 0.977617 | 0.0807728 | 2 | 12 | 159 | 173 | 0.959538 | 0.0991694 |
| 5 | 13 | 18 | 621 | 733 | 0.977617 | 0.0713564 | 3 | 6 | 165 | 172 | 0.973988 | 0.0604228 |
| 6 | 10 | 17 | 622 | 736 | 0.980505 | 0.0604733 | 3 | 5 | 166 | 172 | 0.976879 | 0.0584633 |
| 7 | 9 | 13 | 626 | 737 | 0.984116 | 0.0478682 | 4 | 4 | 167 | 171 | 0.976879 | 0.0745383 |
| 8 | 5 | 13 | 626 | 741 | 0.987004 | 0.0376507 | 3 | 7 | 164 | 172 | 0.971098 | 0.0773135 |
| 9 | 7 | 6 | 633 | 739 | 0.990614 | 0.0248621 | 3 | 2 | 169 | 172 | 0.985549 | 0.0628484 |
| 10 | 7 | 10 | 629 | 739 | 0.987726 | 0.0298408 | 2 | 2 | 169 | 173 | 0.988439 | 0.0531744 |
| 11 | 4 | 10 | 629 | 742 | 0.989892 | 0.0242986 | 3 | 2 | 169 | 172 | 0.985549 | 0.0675473 |
| 12 | 6 | 7 | 632 | 740 | 0.990614 | 0.0326418 | 2 | 3 | 168 | 173 | 0.985549 | 0.0671533 |
| 13 | 6 | 9 | 630 | 740 | 0.98917 | 0.0279278 | 2 | 5 | 166 | 173 | 0.979769 | 0.06897 |
| 14 | 7 | 7 | 632 | 739 | 0.989892 | 0.0244297 | 2 | 3 | 168 | 173 | 0.985549 | 0.0550619 |
| 15 | 5 | 4 | 635 | 741 | 0.993502 | 0.0228877 | 3 | 2 | 169 | 172 | 0.985549 | 0.0558347 |
| 16 | 4 | 10 | 629 | 742 | 0.989892 | 0.0277857 | 4 | 0 | 171 | 171 | 0.988439 | 0.0401906 |
| 17 | 2 | 7 | 632 | 744 | 0.993502 | 0.0193213 | 9 | 1 | 170 | 166 | 0.971098 | 0.0959367 |
| 18 | 7 | 3 | 636 | 739 | 0.99278 | 0.0151094 | 4 | 6 | 165 | 171 | 0.971098 | 0.0873069 |
| 19 | 7 | 3 | 636 | 739 | 0.99278 | 0.017344 | 1 | 6 | 165 | 174 | 0.979769 | 0.0964724 |
| 20 | 5 | 4 | 635 | 741 | 0.993502 | 0.024251 | 1 | 4 | 167 | 174 | 0.985549 | 0.0580115 |
| 21 | 3 | 9 | 630 | 743 | 0.991336 | 0.0207464 | 1 | 3 | 168 | 174 | 0.988439 | 0.0510422 |
| 22 | 2 | 6 | 633 | 744 | 0.994224 | 0.0122992 | 1 | 1 | 170 | 174 | 0.99422 | 0.0439666 |
| 23 | 3 | 2 | 637 | 743 | 0.99639 | 0.0105987 | 4 | 2 | 169 | 171 | 0.982659 | 0.0502425 |
| 24 | 3 | 6 | 633 | 743 | 0.993502 | 0.0164827 | 6 | 1 | 170 | 169 | 0.979769 | 0.0865423 |
| 25 | 5 | 7 | 632 | 741 | 0.991336 | 0.0245302 | 6 | 3 | 168 | 169 | 0.973988 | 0.0918282 |
| 26 | 9 | 8 | 631 | 737 | 0.987726 | 0.0296158 | 5 | 1 | 170 | 170 | 0.982659 | 0.0991676 |
---
## Model Plot
The model architecture can be visualised in the image below:

---
## Validation Accuracy
The final validation accuracy achieved by the model was **98%**.
---
## How to Use the Model
### Loading the Model
To load this model in your application, use the following:
```python
from tensorflow.keras.models import load_model
model = load_model("path/to/saved_model") |