# Attention-Based Light Weight Deep Learning Models for Early Potato Disease Detection
## 2 Convolutional Block Attention Module-Based Technique  
The proposed technique, illustrated in Figure 1, is a combination of three components: a pre-trained model, attention blocks, and dense layers. We utilize transfer learning to simplify model complexity and reduce the number of trainable parameters. The pre-trained model is imported without its dense layers and all layers are frozen, making them non-trainable. The output from the pre-trained model is fed into the CBAM module, which then passes the data to trainable dense layers for prediction. All the images were by default in the shape of 256 \(\times\) 256. The resize operation was performed to form a base in the dataset so that if any sample had a different size, it got changed to 256 \(\times\) 256. Every pixel value was standardized in the range 0 to 1. The standardization method was performed using the Image Data Generator method of Keras library in Python 3.10. The purpose of standardization was to give consistent input; it allows the model to generalize faster when input is consistent. The pixel value of all the images was standardized in the range 0 to 1. The dataset was split into a training, testing, and validation set in the ratio of 80%, 10%, and 10%, respectively. The optimizer used is Adam [24] and categorical cross-entropy is the loss function. The metric used to evaluate the model is accuracy score. No data augmentation techniques were applied; all models were trained on original images. All the models were trained for only 10 epochs as the baseline for comparison. The Convolutional Block Attention Module (CBAM) is a specialized attention mechanism used in Convolutional Neural Networks. It is a combination of two sub-modules: the channel attention module (CAM) and spatial attention module (SAM). * Channel attention focuses on highlighting relevant and important features across channels. It processes an image or a feature map, which consists of multiple channels, each representing a different pattern or aspect detected by a filter. The feature map is passed through a global average pooling layer, generating an average value for each channel to capture the general importance of each channel across the feature map. Simultaneously, the feature map is passed through a global max pooling layer to identify the max value in each channel. The purpose of the global max pooling layer is to highlight the most prominent features in each channel. The outputs from the global average and global max layers are then fed into dense layers, with the final dense layers containing a number of neurons equal to the number of channels in the feature map. These dense layers assign weights to each channel based on importance, which helps in generating the final attention map. After processing through the dense layers, the outputs are combined using element-wise addition to produce a single feature map with multiple channels, each channel containing a single number representing its importance. The feature map is then passed through a sigmoid activation function to normalize its values. Finally, the normalized feature map is combined with the original feature map through element-wise multiplication, resulting in a feature map  
Figure 1: Flowchart of proposed model. that retains the original feature map with prominent channels having highlighted features. Figure 2 shows the flow of the channel attention mechanism. * Spatial attention focuses on finding the most dominant regions in an image by identifying the most significant group of pixels. It processes an image or a feature map composed of multiple channels, each channel representing a grid. The feature map is passed through two layers: a global average pooling layer and global max pooling layer. Unlike channel attention, where the average value within each channel is obtained, here the average pooling is performed across the channel axis calculating the average value across all channels for each pixel.