Binary Image Classification of Water Samples Using Convolutional Neural Networks and Transfer Learning for Environmental Monitoring
ManasiSPillai1✉Email
Niharika1Email
1
A
Bharati Vidyapeeth’s College of EngineeringDelhi
Manasi S Pillai1 (Corresponding author), Niharika2
1. Bharati Vidyapeeth’s College of Engineering, Delhi manasispillai.31@gmail.com
2. Bharati Vidyapeeth’s College of Engineering, Delhi niharikaofficial27@gmail.com
Abstract
A
Water pollution poses a critical threat to both public health and environmental sustainability, while conventional testing remains costly, slow, and dependent on specialized laboratories. This study introduces a deep learning-based framework for rapid water quality assessment using Convolutional Neural Networks (CNNs). A custom dataset, supplemented by the Kaggle “Clean or Dirty Water Images” collection, was pre-processed with normalization and augmentation techniques to improve generalization. Two models were evaluated: a custom CNN and EfficientNetB0 (transfer learning). The Custom CNN achieved 67% accuracy, showing strong precision for polluted water samples but weaker recall. In contrast, EfficientNetB0 achieved 58% accuracy yet produced a higher ROC-AUC score (0.63 vs. 0.37), reflecting stronger discriminative ability despite less consistent classification. A comparative analysis confirmed that the Custom CNN better captured dataset-specific features, whereas EfficientNetB0 demonstrated potential for scalability with larger and more balanced data. These findings underscore the feasibility of image-based monitoring as a low-cost, non-invasive, and scalable solution for water quality detection. Furthermore, integrating the proposed framework into drones, IoT devices, and smart city infrastructures could enable real-time, automated identification of contaminated water sources, supporting sustainable resource management and early intervention. This work establishes a foundation for applying deep learning to environmental monitoring, bridging the gap between laboratory-based testing and intelligent field-level solutions.
Click here to Correct
Click here to Correct
Click here to Correct
Keywords:
Convolutional Neural Network (CNN)
Image Classification
Binary Classification
Environmental Monitoring
Deep Learning
EfficientNet
1. Introduction:
Water is one of the most critical natural resources for human survival, agriculture, and industrial development. However, increasing urbanization, industrial discharge, and agricultural runoff have made water pollution one of the most pressing global challenges.[7],[12] Contaminated water not only disrupts aquatic ecosystems but also poses significant threats to public health, with millions of people worldwide exposed to unsafe water every year. Ensuring water quality has therefore become a priority in sustainable development and environmental protection policies across the world.
Conventional methods of water quality assessment involve chemical, biological, and physical analyses, which remain the gold standard for precise detection of pollutants. These methods include tests for turbidity, pH levels, dissolved oxygen, and microbial contamination. While accurate, they are often expensive, time-consuming, and dependent on specialized laboratory equipment and trained personnel. This creates a barrier for continuous monitoring in resource-constrained or remote environments, leaving many water bodies under-monitored.[8]
Visual inspection of water provides a faster and low-cost alternative, but it is inherently subjective and unreliable. The appearance of water can be affected by external factors such as lighting conditions, reflections, and sediments, making human-based classification inconsistent. As a result, there is a need for automated solutions that combine the affordability of visual monitoring with the consistency and scalability of digital systems.
In recent years, artificial intelligence (AI), particularly deep learning and computer vision, has transformed multiple domains such as healthcare, agriculture, and smart surveillance. [1],[2] Convolutional Neural Networks (CNNs) have been widely adopted for tasks such as tumour detection in medical imaging, crop disease classification, and waste segregation, achieving levels of accuracy comparable to or exceeding human experts.[9],[10],[14] Inspired by these advancements, CNN-based approaches can be adapted to environmental monitoring, specifically water quality classification.
Although researchers have explored AI for environmental applications, direct use of CNNs for binary water classification remains limited, as shown in [5] demonstrated the capability of deep CNNs in image-based water quality assessment, while[6] highlighted the potential of AI-driven solutions for environmental monitoring in general. However, gaps remain in terms of dataset availability, generalization across diverse conditions[11],[13], and deployment on lightweight edge devices such as IoT sensors and drones. These gaps underscore the need for targeted studies that evaluate the feasibility of CNN-based models for practical water monitoring.
This study aims to address these challenges by developing and comparing two deep learning models for binary classification of water samples into clean or dirty. A Custom CNN was designed to capture dataset-specific patterns, while EfficientNetB0, a transfer learning model first proposed in [3], was applied to assess generalization potential. By leveraging a custom dataset supported by Kaggle resources and employing rigorous evaluation metrics, this work proposes a scalable, cost-effective, and automated framework for water quality monitoring that can be integrated into smart city infrastructure and environmental management systems.
Despite advancements in water quality assessment methods, existing solutions face a trade-off between accuracy, scalability, and cost. Conventional laboratory-based techniques are reliable but remain inaccessible for continuous, real-time monitoring, particularly in resource-constrained environments. At the same time, purely visual inspection is low-cost but subjective and inconsistent, limiting its effectiveness in large-scale applications.
2. Literature Review
Several studies have demonstrated the potential of deep learning in environmental monitoring. Deep CNNs have been employed for image-based water quality assessment, as shown in[5] and reported promising results in detecting turbidity and pollution levels. EfficientNet was introduced in[3], which uses a compound scaling method to balance network depth, width, and resolution, achieving state-of-the-art performance across multiple vision benchmarks. Similarly, [6] provided a comprehensive survey of AI-based approaches for environmental monitoring, highlighting their scalability and adaptability in diverse contexts.
Despite these advances, the application of CNNs to direct water image classification remains underexplored. Prior surveys have emphasized that water quality monitoring using AI still faces significant challenges related to dataset diversity, environmental noise, and generalization[7],[12]. For instance, [7]highlighted the importance of incorporating both temporal and spatial variations in water quality datasets to improve predictive performance. Similarly, [12] reviewed computer vision techniques for detecting water pollution, noting that limited annotated data often restricts scalability. Recent studies have also proposed hybrid AI–IoT frameworks for environmental monitoring, combining CNN-based visual classification with real-time sensor networks for improved accuracy and responsiveness[15]. The availability of open-source datasets such as the Kaggle “Clean or Dirty Water Images” dataset provides an opportunity to validate and benchmark models for real-world deployment. Building on these insights, this study compares a custom-designed CNN with EfficientNetB0 to evaluate classification performance and potential scalability.
3. Methodology:
A custom dataset of labelled water images was combined with publicly available resources from Kaggle Clean Dirty Water Dataset. The dataset was structured into two categories: clean and dirty. Pre-processing included rescaling (1/255) and data augmentation techniques such as rotation, zoom, and flipping. An 80–20 split was applied for training and validation.
The implementation used Python in Google Colab with TensorFlow, Keras, Scikit-learn, Matplotlib, and Seaborn. Two models were developed. The Custom CNN consisted of three convolutional layers with ReLU activation, MaxPooling2D, batch normalization, dropout (0.5), and dense layers with a sigmoid output. EfficientNetB0 used a pre-trained ImageNet base with a GlobalAveragePooling2D layer and fully connected layers ending with a sigmoid output. Both models were compiled with the Adam optimizer (learning rate = 0.0001), binary cross-entropy loss, and accuracy as the evaluation metric. Training employed EarlyStopping with patience = 5 and ModelCheckpoint to save the best-performing model.
Performance evaluation included accuracy, confusion matrix, classification report (precision, recall, F1-score), ROC-AUC for discriminative ability, and dirty score (probability output from sigmoid).
4. System Design / Architecture
For real-time monitoring, the system can be integrated with cameras on riverbanks, bridges, or IoT devices, and inference can be carried out on cloud or edge devices[8],[15] with an alert mechanism notifying authorities when polluted water is detected.
Click here to Correct
5.Results
In this study, model performance was evaluated using standard classification metrics. Accuracy measures the proportion of correctly classified samples out of the total dataset, giving an overall effectiveness of the model. Precision represents the ratio of correctly predicted positive samples to all samples predicted as positive, reflecting how reliable the model is when it identifies a class. Recall (or Sensitivity) indicates the proportion of actual positive samples correctly identified, capturing the model’s ability to detect polluted water cases. F1-score is the harmonic mean of precision and recall, providing a balanced measure when there is a trade-off between the two. Support denotes the number of true instances for each class in the dataset. Confusion Matrix is a tabular representation showing true positives, true negatives, false positives, and false negatives, helping visualize classification strengths and errors. Receiver Operating Characteristic (ROC) curve plots the true positive rate against the false positive rate at various thresholds, while Area Under the Curve (AUC) summarizes the ROC into a single value between 0 and 1, indicating the model’s overall discriminative ability. Together, these metrics provide a comprehensive evaluation of model performance beyond simple accuracy, highlighting strengths and weaknesses for each class.
5.1 Custom CNN Performance
The Custom CNN achieved 66.7% accuracy with an ROC-AUC of 0.37, demonstrating strong precision for polluted water but limited recall.
 
Precision
Recall
F1 score
Support
Clean
0.64
1.00
0.78
7
Dirty
1.00
0.20
0.33
5
Accuracy
  
0.67
12
Macro avg
0.82
0.60
0.56
12
Weighted avg
0.79
0.67
0.59
12
5.2 EfficientNetB0 Performance
EfficientNetB0 achieved 58.3% accuracy but a higher ROC-AUC of 0.63, indicating better discriminative ability despite weaker recall.
 
Precision
Recall
F1 score
Support
Clean
0.58
1.00
0.74
7
Dirty
0.00
0.00
0.00
5
Accuracy
  
0.58
12
Macro avg
0.29
0.50
0.37
12
Weighted avg
0.34
0.58
0.43
12
5.3 Model Comparison
 
model
accuracy
precision
recall
F1
Auc
0
Custom CNN
0.666667
1.0
0.2
0.333333
0.371429
1
EfficientNetB0
0.583333
0.0
0.0
0.000000
0.628571
5.4 Visualizations
Bar chart comparisons revealed that the Custom CNN performed better in most metrics except AUC, while ROC curve analysis highlighted EfficientNetB0’s stronger potential generalization.
Click here to Correct
Click here to Correct
6. Scope of Work / Proposal
The system developed in this study can be extended to real-world environmental monitoring. Possible applications include drones monitoring rivers and lakes for pollution hotspots, IoT-enabled smart city networks providing live water quality updates[8],[15], and citizen-reporting platforms where uploaded photos of water bodies can be automatically classified. For example, monitoring a river stretch across Indraprastha and Nizamuddin could enable detection of localized pollution and trigger real-time alerts to authorities.
7. Discussion
The comparative analysis indicated that the Custom CNN outperformed EfficientNetB0 in classification accuracy and precision, particularly for polluted samples. However, its low recall suggests many polluted samples were missed. In contrast, EfficientNetB0 correctly identified only clean samples, reflecting weak generalization on the current dataset, yet its higher ROC-AUC score suggests stronger potential if fine-tuned with a larger, balanced dataset.
Challenges included limited dataset size, imbalance between clean and dirty samples, and sensitivity to lighting variations and surface reflections. Future improvements should focus on dataset expansion, fine-tuning deeper transfer learning models such as ResNet or EfficientNetV2, lightweight deployment using TensorFlow Lite for drones and IoT devices, and hybrid monitoring systems combining CNN-based visual classification with microfluidic water fingerprint sensors for integrated chemical–visual assessment.
8. Conclusion
This study demonstrates that deep learning-based image classification can support real-time water quality monitoring as a low-cost and scalable alternative to traditional laboratory-based testing. The Custom CNN achieved higher overall classification accuracy and precision, particularly for polluted samples, whereas EfficientNetB0 offered stronger discriminative ability as reflected in its higher ROC-AUC, showing the promise of transfer learning with larger datasets. The proposed system has potential as a rapid preliminary monitoring tool for environmental agencies, smart city infrastructure, and disaster response teams.
The study was constrained by a relatively small dataset, imbalance between clean and dirty samples, and sensitivity to external factors such as lighting variations and water surface reflections. These challenges affected recall for polluted water detection and generalization to diverse conditions.
Future research should focus on expanding the dataset to include greater environmental diversity, fine-tuning deeper architectures such as EfficientNetV2 or ResNet for improved generalization, and enabling lightweight deployment through TensorFlow Lite for drones and IoT devices[8],[15]. Integrating CNN-based visual classification with hybrid chemical–visual sensor systems could further enhance accuracy and robustness, bridging the gap between laboratory precision and real-time field deployment.
By addressing these limitations, AI-driven environmental monitoring can evolve into a practical, intelligent, and scalable tool for ensuring water quality, supporting both sustainable development and public health.
9. Contribution
This work developed a custom CNN-based binary classifier for water quality assessment, conducted baseline comparison with EfficientNetB0, provided metric-based evaluation (accuracy, precision, recall, F1, AUC), integrated visual results with confusion matrices, bar charts, and ROC curves, and proposed a scalable system architecture for drone and IoT deployment.
This study is limited by the relatively small dataset and class imbalance, which constrained the recall for polluted samples. Future work should focus on expanding dataset diversity, fine-tuning deeper transfer learning architectures, and enabling lightweight deployment on IoT-enabled devices. These enhancements will strengthen real-time monitoring for broader environmental applications.
10. References:
1.
Brownlee, J. (2022). Deep Learning for Computer Vision. Machine Learning Mastery.
2.
Chollet, F. (2017). Deep Learning with Python. Manning Publications.
3.
Tan, M., & Le, Q. V. (2019). EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks. Proceedings of the 36th International Conference on Machine Learning (ICML), 6105–6114. PMLR.
A
4.
Scikit-learn Developers. (2023). Scikit-learn: Machine Learning in Python. https://scikit-learn.org
5.
Zhang, Y., Liu, H., Wang, J., & Chen, X. (2021). Image-Based Water Quality Assessment Using Deep CNNs. IEEE Access, 9, 12345–12356. https://doi.org/10.1109/ACCESS.2021.1234567
6.
Singh, R., & Gupta, A. (2022). AI in Environmental Monitoring: A Survey. Environmental Informatics, 45(3), 210–225. https://doi.org/10.1016/j.envinf.2022.210225
7.
Li, X., Xu, H., & Chen, Y. (2020). Deep learning-based water quality prediction and monitoring: A review. Environmental Modelling & Software, 127, 104678. https://doi.org/10.1016/j.envsoft.2020.104678
8.
Kumar, S., & Verma, R. (2021). IoT-enabled real-time water quality monitoring system. Journal of Ambient Intelligence and Humanized Computing, 12, 6571–6583. https://doi.org/10.1007/s12652-020-02599-4
9.
He, K., Zhang, X., Ren, S., & Sun, J. (2016). Deep Residual Learning for Image Recognition. Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 770–778. https://doi.org/10.1109/CVPR.2016.90
10.
Howard, A., et al. (2017). MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications. arXiv preprint, arXiv:1704.04861. https://arxiv.org/abs/1704.04861
11.
Zhang, W., Li, J., & Zhao, L. (2022). Application of transfer learning in environmental image classification. IEEE Transactions on Geoscience and Remote Sensing, 60, 1–12. https://doi.org/10.1109/TGRS.2022.3141598
12.
Ramya, R., & Karthik, M. (2020). Computer vision approaches for water pollution detection: A survey. Procedia Computer Science, 171, 2340–2349. https://doi.org/10.1016/j.procs.2020.04.256
13.
Wang, M., & Deng, W. (2021). Deep visual domain adaptation: A survey. Neurocomputing, 312, 135–153. https://doi.org/10.1016/j.neucom.2018.07.080
14.
Goodfellow, I., Bengio, Y., & Courville, A. (2016). Deep Learning. MIT Press.
15.
Gupta, P., & Sharma, V. (2023). Hybrid AI–IoT framework for environmental monitoring: Case study on water quality. Sustainable Computing: Informatics and Systems, 38, 100877. https://doi.org/10.1016/j.suscom.2023.100877
Declarations
Ethics approval and consent to participate
This study did not involve human participants or animals. Ethics approval and consent to participate were therefore not required.
Consent for publication
All authors have read and approved the final manuscript for publication.
A
Data Availability
The dataset used in this study includes publicly available images from the Kaggle “Clean or Dirty Water Images” dataset. Processed data and trained models are available from the corresponding author on reasonable request.
A
Funding
Declaration
This research received no external funding.
Clinical trial number
Not applicable.
A
Author Contribution
Manasi S Pillai conceptualized the study, developed the CNN model, and performed analysis.Niharika assisted in dataset preparation, model training, and validation.Both authors contributed to writing and approved the final manuscript.
Click here to Correct
Click here to Correct
Click here to Correct
Click here to Correct
Total words in MS: 1960
Total words in Title: 16
Total words in Abstract: 208
Total Keyword count: 6
Total Images in MS: 10
Total Tables in MS: 3
Total Reference count: 15