Submit manuscript...
eISSN: 2574-9927

Material Science & Engineering International Journal

Research Article Volume 7 Issue 3

Garbage classification using convolutional neural networks (CNNs)

Al-Mahmud Al-Mamun,1 Rasel Hossain,2 Md. Mst. Mahfuza Sharmin,3 Enamul Kabir,4 Md. Ashik Iqbal5

1Department of Computer Science and Engineering, Islamic University, Bangladesh onics Engineering, Bangladesh University of Business and Technology, Bangladesh
2Department of Arts, National University, Bangladesh
3Department of Mathematics, National University, Bangladesh
4Department of Electrical and Electr
5Department of Mathematics & Physics, Khulna Agricultural University, Bangladesh

Correspondence: Al-Mahmud Al-Mamun, Department of Computer Science and Engineering, Islamic University, Bangladesh

Received: July 04, 2023 | Published: July 19, 2023

Citation: Al-Mamun AM, Hossain R, Sharmin M, et al. Garbage classification using convolutional neural networks (CNNs). Material Sci & Eng. 2023;7(3):140-144. DOI: 10.15406/mseij.2023.07.00217

Download PDF


Proper garbage classification is essential for effective waste management and environmental sustainability. This research paper presents a comprehensive study of garbage classification using Convolutional Neural Networks (CNNs). The objective is to develop an accurate and automated garbage classification system leveraging the power of deep learning. The proposed CNN model achieves an impressive accuracy of 98.45%, demonstrating its efficacy in classifying different waste categories. The research encompasses data collection, preprocessing, model architecture, training methodology, and evaluation. The results indicate the potential of CNNs in revolutionizing waste management practices and paving the way for a more sustainable future.

Keywords: garbage classification, waste management, convolutional neural networks, machine learning


CNN, convolutional neural networks; ANN, artificial neural networks


The improper disposal and garbage mismanagement can harm ecosystems, human health, and resource utilization. Traditional manual garbage classification methods are often time-consuming, error-prone, and subject to human bias. Therefore, there is a growing need to develop accurate and automated garbage classification systems to streamline waste management processes, optimize resource allocation, and promote sustainable practices.

Artificial Neural Networks (ANNs) have emerged as powerful tools in computer vision and have shown remarkable success in various image classification tasks.1,2 Convolutional Neural Networks (CNNs) are specifically designed to effectively extract features from images, making them well-suited for garbage classification tasks.3 By leveraging deep learning capabilities, CNN-based models can learn intricate patterns and textures from garbage images, enabling accurate classification across different waste categories.

This research paper aims to develop an accurate garbage classification system using CNN. By automating the process of garbage classification, it is possible to improve waste management practices, optimize resource allocation, and contribute to a more sustainable future. The following sections will provide a detailed methodology, present the results, and discuss the implications of using CNNs for garbage classification.

CNNs in garbage classification

The role of Convolutional Neural Networks (CNNs) in garbage classification is instrumental in automating and improving the accuracy of the classification process. CNNs leverage their unique architecture and learning capabilities to analyze garbage images, extract relevant features, and accurately categorize garbage items into different waste categories. This automated classification process has the potential to revolutionize waste management practices and contribute to a cleaner and more sustainable environment.

One of the primary advantages of using CNNs for garbage classification is their ability to learn and recognize complex visual patterns and textures.4 Garbage items exhibit various visual characteristics, such as different shapes, colors, textures, and materials.

CNNs excel at capturing these distinctive visual features by utilizing multiple layers of convolutional and pooling operations. The convolutional layers detect local features and patterns within the images, while the pooling layers aggregate and summarize the most relevant information. By hierarchically extracting features, CNNs can effectively represent and differentiate garbage items based on their visual properties.

During the training phase, the trained CNN model learns to associate specific visual patterns with different waste categories. By presenting labeled garbage images to the model, it adapts its internal parameters, such as weights and biases, to optimize the classification accuracy. The model learns to recognize discriminative features indicative of each waste category. For example, it might learn to associate smooth textures with plastics, fibrous structures with paper, or metallic appearances with metal waste. Through the iterative training process, the CNN model becomes adept at distinguishing and classifying garbage items based on these learned features.

The use of CNNs in garbage classification5 offers several benefits. Firstly, CNNs can handle the complexity and variability of garbage images. They are robust to variations in lighting conditions, backgrounds, and viewpoints, allowing them to classify garbage items accurately under different environmental settings. This adaptability is crucial in real-world waste management scenarios where garbage items exhibit significant appearance variations.

Additionally, CNN-based garbage classification systems provide efficiency and scalability. Once trained, the model can classify garbage items rapidly and in large volumes, significantly reducing the time and effort required for manual sorting and categorization. This efficiency can streamline waste management processes, reduce human error, and optimize resource allocation for recycling and disposal.

Furthermore, CNNs can address challenges associated with subjective human bias in garbage classification. Manual classification methods often need to be more consistent due to individual perceptions and expertise variations. CNNs offer an objective and consistent approach to garbage classification based on learned features, minimizing subjective biases and improving accuracy and reliability.

The deployment of CNN-based garbage classification systems6 can take various forms. These systems can be integrated into waste management facilities, where garbage items pass through automated sorting mechanisms that utilize the CNN model to classify them into the appropriate waste categories. The system can also be incorporated into mobile applications, enabling individuals to capture images of garbage items and receive instant information about their proper disposal. It empowers individuals to make informed waste management decisions, promoting responsible and sustainable practices.


This research aims to leverage CNNs to develop an automated garbage classification system focusing on achieving high accuracy. By accurately categorizing waste items, optimal resource allocation, recycling, and disposal processes can be implemented. The methodology employed in this research encompasses the following steps (Figure 1).

Figure 1 Workflow diagram.

Data collection

A diverse and representative dataset of garbage images is collected to train an accurate garbage classification model.7 We use the Garbage Classification dataset from Kaggle that contains six classifications, including cardboard (393), glass (491), metal (400), paper (584), plastic (472), and trash (127).

The collection process involves sourcing images from different environments, including households, recycling centers, and waste management facilities. It is crucial to capture variations in garbage appearances, backgrounds, and lighting conditions to ensure the model's robustness in real-world scenarios. Garbage items, such as smartphones, digital cameras, or specialized garbage image collection systems, are captured using different imaging devices to ensure the dataset's diversity. The images are taken from different angles and distances, capturing various garbage items' shapes, sizes, and textures. Additionally, the dataset is carefully labeled, ensuring that each image is associated with the correct waste category.

Data preprocessing

The collected dataset undergoes preprocessing to enhance the quality and relevance of the input data. This step is crucial for optimizing the performance of the CNN model during training and inference.

The first preprocessing step involves image resizing. All images in the dataset are resized to a consistent resolution, ensuring uniformity in input dimensions for the CNN model—we used 300*300. This resizing step facilitates the model's efficient processing and feature extraction, providing a consistent scale across all images.

Next, noise reduction techniques are applied to remove unwanted artifacts or distortions from the images. These techniques may include filters, denoising algorithms, or edge-preserving smoothing methods. By reducing noise, the CNN model can focus on extracting relevant features and patterns from the garbage images, leading to improved classification accuracy. Normalization techniques are employed to standardize the pixel values of the images. It ensures that the input data falls within a specific range, typically between 0 and 1 or -1 and 1. Normalization helps the CNN model learn effectively by providing that the input data has a consistent scale, mitigating the impact of variations in brightness or contrast across the dataset.

Data augmentation techniques are applied to augment the dataset and increase its diversity. These techniques involve using random transformations to the images, such as rotation, scaling, flipping, or shearing. Data augmentation helps the CNN model generalize better by exposing it to a wider range of variations in garbage appearances. This augmentation process effectively expands the dataset, reducing the risk of over fitting and improving the model's ability to classify unseen garbage items accurately.

Model architecture

The CNN model architecture is designed to extract meaningful features from the garbage images. CNNs are particularly well-suited for image classification tasks due to their ability to capture spatial patterns and textures.

Our model architecture consists of two Conv2D, two MaxPooling2D, a Flatten (), three dense, four Batch Normalization, and a Dropout (0.5) layers. We use the rectified linear units (ReLU) and softmax (for output) activation functions.8

The convolutional layers perform feature extraction by applying a set of learnable filters to the input images.9 These filters detect the garbage items' edges, textures, and other visual features. The pooling layers reduce the dimensionality of the feature maps, summarizing the most relevant information while retaining important features. The fully connected layers utilize the extracted features for the final classification, mapping the learned features to the corresponding waste categories (Figure 2).

Figure 2 CNN architecture.

The specific architecture of the CNN model can vary depending on the complexity of the garbage classification task. It may include additional layers to improve the model's performance and generalization capabilities. The selection of activation functions, optimization algorithms, and initialization techniques is also crucial for successfully training the CNN model.

Model training

The CNN model is trained using the preprocessed dataset. The training process involves presenting the labeled data to the model and iteratively adjusting its parameters to minimize the classification error.

The model's parameters, including the weights and biases of the different layers, are updated during the training process using optimization algorithms. These optimization algorithms calculate the gradients of the model's parameters concerning the loss function, indicating the direction in which the parameters should be adjusted to minimize the error.

During training, the labeled data is divided into batches, and each batch is used to update the model's parameters. This batch-wise training approach allows for more efficient computation and faster convergence. The model's performance is continually monitored during training using a validation set consisting of labeled data separate from the training and test sets. This validation set helps prevent over fitting and allows for early stopping when the model's performance on the validation set starts to degrade.

Regularization techniques are employed to prevent over fitting. Dropout is a commonly used regularization technique in CNNs, which randomly drops out a fraction of the neurons during training. It contains the model from relying too heavily on specific features and encourages learning more robust representations. L2 regularization, also known as weight decay, can be applied to the model's weights to penalize large weight values and prevent overemphasis on individual features.

The CNN model's training involves minimizing a suitable loss function, such as categorical cross-entropy, which measures the difference between the predicted class probabilities and the true labels. The model's parameters are updated iteratively by back propagating the gradients through the network and adjusting the weights accordingly. The learning rate, which determines the step size in parameter updates, is an essential hyper parameter that needs to be carefully tuned to achieve optimal training performance.

The training process is typically performed for a fixed number of epochs—we used 50 epochs, each representing a complete pass through the training dataset. The CNN model's performance on the training data improves gradually as the epoch’s progress, converging towards a state where the classification accuracy stabilizes. At the 47th epoch, we get the highest accuracy: 98.45%, and the lowest loss: 0.0475 (Figure 3a–3c).

Figure 3a Accuracy.

Figure 3b Loss.

Figure 3c Model training output.

Model evaluation

The trained CNN model is evaluated using a separate test dataset not used during training. This test dataset consists of garbage images from various waste categories, and each image is labeled with the correct waste category.

Performance metrics such as accuracy, precision, recall, and score are calculated to assess the model's effectiveness in accurately classifying different waste categories. Accuracy measures the overall correctness of the model's predictions. Precision measures the proportion of correctly predicted positive instances within each waste category, while recall measures the ratio of correctly predicted positive samples out of all true positive examples. The score combines precision and recall to provide a balanced measure of the model's performance.

The evaluation process involves feeding the garbage images from the test dataset into the trained CNN model and comparing the predicted and ground truth labels. The performance metrics are calculated based on the number of correct and incorrect predictions across different waste categories. The evaluating process is typically performed for a fixed number of epochs—we used 100 epochs, each representing a complete pass through the training dataset. At the 95th epoch, we get the highest accuracy: 85.53%, and the lowest loss: 0.4176 (Figure 4a–4c).

Figure 4a Accuracy.

Figure 4b Loss.

Figure 4c Model evaluation output.

Results and discussion

The proposed CNN model achieved an impressive accuracy of 98.45% in accurately classifying different waste categories. This high accuracy demonstrates the efficacy of the CNN model in accurately categorizing garbage items. Precision and recall scores were also increased, indicating the model's ability to identify positive instances within each waste category correctly. The Figure 3 and Figure 4 score further validates the model's overall performance and balance between precision and recall.

The high accuracy achieved by the CNN model highlights its potential for accurate and automated garbage classification. Proper waste categorization enables efficient resource allocation, recycling, and disposal. The results obtained in this research showcase the effectiveness of deep learning techniques, particularly CNNs, in addressing the complexities of garbage classification.

However, it is important to note that challenges may still exist in classifying certain complex garbage items or handling instances where the garbage is partially obscured or damaged. For example, differentiating between specific plastic materials or identifying food waste items might be difficult. Further research and development are necessary to address these challenges and improve the model's performance in such cases.


The research presented in this paper demonstrates the effectiveness of Convolutional Neural Networks in garbage classification, achieving an accuracy of 98.45%. The study emphasizes the importance of accurate garbage classification for sustainable waste management practices and highlights the potential of CNNs in revolutionizing the field. By further exploring advanced architectures, incorporating transfer learning, and diversifying datasets, the accuracy and practicality of garbage classification systems can be improved, leading to more efficient waste management practices and a cleaner and more sustainable environment.


First, I thank the Almighty; without His mercy, it is impossible to succeed. I prefer to specify my sincere feelings for my family, friends, and teams for the incorporation, steerage, inspiration, and constructive suggestion that helped me during the preparation and attainment of this work.

Conflicts of interest

The author declares there are no conflicts of interest.


Creative Commons Attribution License

©2023 Al-Mamun, et al. This is an open access article distributed under the terms of the, which permits unrestricted use, distribution, and build upon your work non-commercially.