Foam Segmentation in Wastewater Treatment Plants: A Federated Learning Approach with Segment Anything Model 2

Mehmet Batuhan Duman, Alejandro Carnero, Cristian Martín, Daniel Garrido, Manuel Díaz · 2025

Read Foam Segmentation in Wastewater Treatment Plants: A Federated Learning Approach with Segment Anything Model 2 by Mehmet Batuhan Duman, Alejandro Carnero, Cristian Martín, Daniel Garrido, Manuel Díaz (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2511-08130.txt.

Introduction

Mehmet Batuhan Duman and co-authors combine federated learning with a modern segmentation model to track foam in wastewater treatment plants. Foam lowers treatment efficiency and raises costs, so plants want real time measures of foam coverage. Labeled images are scarce and uneven, and plants will not share operational data for privacy reasons.

Federated training lets plants improve one model together without centralizing their images. The Segment Anything Model 2 supplies strong pretrained weights, fine tuned on edge clients through the Flower framework under a fog server. Training used real images from Granada, synthetic foam data, and public sets to broaden generalization.

Catalog record

CREATORMehmet Batuhan Duman, Alejandro Carnero, Cristian Martín, Daniel Garrido, Manuel Díaz
YEAR2025
COLLECTIONPAPERS
FORMATTXT
FILE SIZE59 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2511-08130

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

Foam Segmentation in Wastewater Treatment Plants: A Federated Learning Approach with Segment Anything Model 2 Mehmet Batuhan Duman, Alejandro Carnero, Cristian Martín, Daniel Garrido, Manuel Díaz Abstract Foam formation in Wastewater Treatment Plants (WTPs) is a major challenge that can reduce treatment efficiency and increase costs. The ability to automatically examine changes in real-time with respect to the percentage of foam can be of great benefit to the plant. However, large amounts of labeled data are required to train standard Machine Learning (ML) models. The development of these systems is slow due to the scarcity and heterogeneity of labeled data. Additionally, the development is often hindered by the fact that different WTPs do not share their data due to privacy concerns. This paper proposes a new framework to address these challenges by combining Federated Learning (FL) with the state-of-the-art base model for image segmentation, Segment Anything Model 2 (SAM2). The FL paradigm enables collaborative model training across multiple WTPs without centralizing sensitive operational data, thereby ensuring privacy. The framework accelerates training convergence and improves segmentation performance even with limited local datasets by leveraging SAM2’s strong pre-trained weights for initialization. The methodology involves fine-tuning SAM2 on distributed clients (edge nodes) using the Flower framework, where a central Fog server orchestrates the process by aggregating model weights without accessing private data. The model was trained and validated using various data collections, including real-world images captured at a WTPs in Granada, Spain, a synthetically generated foam dataset, and images from publicly available datasets to improve generalization. This research offers a practical, scalable, and privacy-aware solution for automatic foam tracking in WTPs. The findings highlight the significant potential of integrating large-scale foundational models into FL systems to solve real-world industrial challenges characterized by distributed and sensitive data. 1 Introduction Foaming in Wastewater Treatment Plants (WTPs) is a significant operational challenge that reduces treatment efficiency and increases operating costs. The presence of foam in aeration tanks and clarifiers leads to reduced oxygen transfer, decreased biomass concentration, odor problems, and increased maintenance expenses 7 ; 24 . Therefore, accurate foam detection and quantification are essential for implementing timely control measures and optimizing WTPs performance. Foam generation in WTPs arises from a complex interplay of factors, including surfactants and detergents present in influent wastewater, excessive growth of filamentous bacteria, imbalances within the biological treatment process, and the presence of proteins and lipids 30 . Filamentous bacteria such as Microthrix parvicella and Gordonia species produce biosurfactants that stabilize foams 20 . If not addressed, uncontrolled foam significantly compromises treatment efficacy, raises safety concerns, and risks the discharge of partially treated effluent into the environment. Traditionally, foam monitoring has relied on visual inspection or basic sensor systems, offering limited precision and objectivity. Advanced image analysis techniques promise more accurate, automated, and real-time foam segmentation but remain challenged by data privacy, heterogeneous foam characteristics between facilities, scarce labeled data, and the requirement for low-latency processing 34 . Recent studies in diverse domains underscore similar hurdles: distributed data with privacy constraints in medical imaging 27 ; 19 , water-level prediction 29 , and agricultural irrigation 1 all highlighting the need for collaborative, privacy-aware methods to manage non-identical data distributions. Deep learning approaches, notably Convolutional Neural Networks (CNNs), have proven effective for image segmentation in fields such as medical diagnosis 23 and industrial defect detection 12 ; 9 . However, directly applying deep learning methods to WTPs foam segmentation is complicated by sensitive operational data and the wide variability in plant designs 2 . Federated Learning (FL) is emerging as a viable solution: a distributed machine learning paradigm that enables training models across geographically dispersed systems. Models are trained locally on decentralized devices (or servers) without sharing their private data, thus maintaining privacy 16 . FL has already shown promise in multiple use cases, including pothole detection 26 , sustainable transportation 35 , and remote sensing 36 , but these efforts often face slow convergence or reduced performance under non-Independent and Identically Distributed (non-IID) data conditions. This paper primarily focuses on proposing a novel framework for foam detection that leverages the advantages of FL combined with initialization from a large-scale foundation model. Specifically, we harness the Segment Anything Model 2 (SAM2) 22 , whose broad segmentation capabilities have been successfully adapted to specialized domains 17 . Leveraging SAM2’s pre-trained weights accelerates training convergence and increases performance, particularly where labeled data are scarce. In this context, we further explore SAM2, a hierarchical variant of SAM designed for multi-scale feature extraction and point-based prompting. Together, these models provide a robust foundation for foam segmentation in real-world WTPs conditions. This work contributes significantly to the wastewater treatment domain by delivering a privacy-preserving, high-performance foam segmentation strategy adaptable to diverse plant conditions. Beyond WTPs, the insights gained may extend to other resource management and industrial applications where data sharing is restricted and produced in real-time, where distributed learning is crucial. Similar insights can be drawn from knowledge distillation approaches, which reduce communication overhead in federated scenarios 28 , but our focus is on leveraging SAM/SAM2 initialization for more resilient foam segmentation. Our method features three main components: • A FL framework tailored for WTPs foam segmentation. • A novel initialization strategy using SAM2, adapted to the unique characteristics of foam images. • A systematic evaluation under both IID and non-IID data splits, reflecting realistic WTPs heterogeneity. Experiments on real WTPs data demonstrate that FL models initialized with SAM2 converge in a significantly smaller number of communication rounds compared to models with random initialization. Our SAM2-based approach achieves a Dice score of 84.38% using FL with two clients. The hierarchical architecture of SAM2 further contributes to the refinement of segmentation boundaries, facilitating accurate foam detection under difficult conditions. While classical segmentation models such as U-Net and DeepLabV3+ can achieve higher scores on certain metrics in centralized training, SAM2 is shown to provide highly competitive and robust performance within the practical constraints of a federated, privacy-preserving system. The reasons for these performance characteristics are explored in our prompt-sensitivity analysis, which shows that despite differences in evaluation scores, SAM2’s visual outputs are comparable to other leading models. This paper details the fine-tuning process of SAM2 for foam segmentation, the methodology for creating the specialized training dataset, the implementation of the federated learning framework across different clients, and the final deployment and evaluation in real-world WTPs. The present study begins with a contextualization of the research within the existing literature on foam segmentation and distributed learning. Next, we delineate our primary contribution: a novel framework integrating disparate datasets and a federated learning methodology based on the SAM2 model. We also provide a detailed exposition of its practical implementation. The paper concludes with a comprehensive performance evaluation, a discussion of the project’s challenges, and a summary of our findings and future research directions. 2 Related Work The formation and detection of foam in WTPs have been the subject of research for several decades. Researchers have investigated foam formation from various angles, including understanding the underlying causes and developing advanced detection and monitoring techniques. Across domains such as manufacturing 12 , water conservation 1 , and river segmentation 32 , the challenge often lies in handling heterogeneous data and environmental factors that

Read the complete text