Skip to Content
Applied SciencesApplied Sciences
  • Article
  • Open Access

2 February 2026

Lightweight Semantic Segmentation for Fermentation Foam Monitoring: A Comparative Study of U-Net, DeepLabV3+, Fast-SCNN, and SegNet

,
,
,
,
and
1
Institute of Power Engineering and Control Systems, Lviv Polytechnic National University, 12 Stepan Bandera Str., 79013 Lviv, Ukraine
2
Department of Fundamentals of Computer Science, University of the National Education Commission, 30-084 Krakow, Poland
3
Department of Technical and Computer Education, University of the National Education Commission, 30-084 Krakow, Poland
*
Author to whom correspondence should be addressed.

Abstract

This study aims to identify an effective neural network architecture for the task of semantic segmentation of the surface of beer wort at the stage of primary fermentation, using deep learning methodologies. Four contemporary architectures were evaluated and contrasted. The following networks are presented in both baseline and optimized forms: U-Net, DeepLabV3+, Fast-SCNN, and SegNet. The models were trained on a dataset of images depicting real beer surfaces at the primary fermentation stage. This was followed by the validation of the models using key metrics, including pixel classification accuracy, Mean Intersection over Union (mIoU), Dice Coefficient, inference time per image, and Graphics Processing Unit (GPU) resource utilization. Results indicate that the optimized U-Net achieved the optimal balance between performance and efficiency, attaining a validation accuracy of 88.85%, mIoU of 76.72%, and a Dice score of 86.71%. With an inference time of 49.5 milliseconds per image, coupled with minimal GPU utilization (18%), the model proves suitable for real-time deployment in production environments. Conversely, complex architectures, such as DeepLabV3+, did not yield the anticipated benefits, thereby underscoring the viability of utilizing compact models for highly specialized industrial tasks. This study establishes a novel quantitative metric for the assessment of fermentation. This is based on the characteristics of the foam surface and thus offers an objective alternative to traditional subjective inspections. The findings emphasize the potential of adapting optimized deep learning architectures to quality control tasks within the food industry, particularly in the brewing sector, and they pave the way for further integration into automated computer vision systems.

1. Introduction

Image segmentation is a pivotal component of computer vision, a field of growing significance within the food industry. Modern manufacturing facilities strive to reduce manual labor and enhance the objectivity of quality control by implementing automated systems that are informed by artificial intelligence. This is particularly evident in processes where visual characteristics can serve as indicators of the technological state of products [1,2].
A crucial phase in the brewing process is the primary fermentation of beer in open vats, where the formation and characteristics of the foam are instrumental in determining the outcome of the fermentation process. During fermentation, yeast enzymes catalyze the conversion of sugars into alcohol and carbon dioxide, resulting in the formation of a thick foam layer. Over time, dead yeast cells and other by-products accumulate on the surface, forming a layer known as “contaminated foam”. The premature removal of this foam has the potential to result in the contamination of the young beer and the deterioration of the organoleptic properties of the final product. Consequently, timely visual inspection of the foam—its composition, area, and type—is imperative for maintaining consistent product quality. The visual characteristics of foam—in particular, its color, shape, structure, and changes over time—are traditional indicators of the stages of primary fermentation [3]. Consequently, foam assessment is not only critical for purity control, but also facilitates the determination of the fermentation process phase.
Currently, most breweries that utilize open fermentation tanks rely on subjective evaluation of a technologist, a process prone to errors and variability. Computer vision technologies have been identified as a potential solution to this problem. The segmentation of wort surface images facilitates the automatic identification of key areas, including clean foam, characterized by a light, homogeneous structure; contaminated foam, exhibiting a brown hue and dark particles, indicative of the presence of dead yeast and residues of by-products arising from the brewing process; and the image background, comprising the vat, walls, or other equipment. The division of the sample into these three classes is based on the actual needs of the technological process: the ratio of clean and contaminated foam visually reflects the transitional stages of fermentation, clean foam is left, contaminated foam is collected, and the background helps to localize the segmentation contours [3].
The utilization of artificial neural networks, particularly segmentation architectures, has become a prevalent approach in contemporary research endeavours. This methodology has been demonstrated to facilitate the attainment of high precision, even when dealing with intricate visual data. In the food industry, such approaches have been employed for the classification of grain crops [4], the assessment of beverage quality [2], and the monitoring of fermentation processes based on sensory data [5]. Nevertheless, the application of foam structure segmentation in images during the process of beer fermentation represents a novel research direction that merits further investigation.
This study relies on the hypothesis that specialized, structurally optimized lightweight neural network architectures can ensure sufficient segmentation accuracy for foam monitoring, even when trained on a limited dataset, while satisfying the strict low-latency requirements for deployment on edge devices.
Accordingly, the objective of this study is to develop and investigate a segmentation model based on deep learning for the automatic recognition of three visual classes in an image of the surface of beer wort: clean foam, contaminated foam, and image background. Emphasis is placed on optimizing the neural architecture for operation in real production conditions. These conditions involve variable lighting, uneven foam texture and dynamic changes in its structure during the fermentation process. The optimization strategy adopted in this study focuses on balancing computational efficiency with segmentation accuracy. In order to align the model complexity with the relatively homogeneous texture of beer foam, specific structural adjustments were made to the considered lightweight architectures. These modifications included a reduction in network depth, a decrease in the number of filters, and the implementation of separable convolutions.
The primary contributions of this paper are as follows:
1. A comparative analysis of four deep learning architectures specifically tailored for the monitoring of brewery fermentation processes.
2. The development of structurally optimized lightweight models capable of real-time segmentation (inference time < 50 ms) on cost-effective consumer-grade hardware, facilitating accessible on-premise deployment.
3. The introduction of a novel quantitative metric for fermentation assessment derived from the semantic segmentation of the beer wort surface, establishing an objective process parameter analogous to temperature or gravity to replace subjective manual inspections.

2. Deep Learning Architectures for Image Segmentation

Deep learning has emerged as a primary research direction in modern computer vision. This is of particular pertinence in the food industry, where the necessity for exact visual process control is paramount [1,2,6]. In the domain of brewing, a pivotal responsibility is to meticulously monitor the surface foam that emerges during the fermentation process. Currently, this process relies on manual inspection, which increases temporal and human resource costs. Among the most effective architectures for image segmentation are U-Net, DeepLabV3+, SegNet, and Fast-SCNN, each of which has its own advantages and limitations.
U-Net was developed for the purpose of biomedical segmentation [7] and has been demonstrated to preserve spatial information effectively due to the symmetrical connections between layers. The system has been shown to provide accurate segmentation of complex shapes, even with a limited number of training examples. Subsequent advancements, exemplified by UNet++ [8], have diminished the semantic discrepancy between the encoder and decoder. Moreover, recent modifications, such as INVU-Net [9], have underscored the significance of this methodology. U-Net has been established as the fundamental benchmark for foam segmentation in open vats, due to its capacity to operate with limited samples and accentuate objects with indistinct contours.
The development of DeepLab has made a significant contribution to the field of segmentation, primarily through the integration of atrous convolutions and multi-scale context analysis [10,11]. DeepLabV3+ [12] combines the ASPP module with a lightweight decoder and separable convolutions, allowing it to process high-resolution images and restore object boundaries. The journal version of DeepLab [11] further corroborates the efficacy of this approach. In the context of foam segmentation, this architecture facilitates the accurate consideration of heterogeneous textures and surface reflections of the wort.
SegNet [13] implements an encoder–decoder architecture with max-pooling index preservation, which allows for accurate spatial structure restoration. The efficacy of the architecture in tasks involving the analysis of microorganisms and agricultural images has been demonstrated [14]. The employment of augmentation techniques [15] has been shown to enhance performance in circumstances where data is limited. In the context of foam segmentation, SegNet can be considered a balanced solution between quality and speed, especially when resistance to noise and heterogeneous backgrounds is important.
The Fast-SCNN [16] algorithm was developed with the specific purpose of real-time segmentation on mobile devices. The approach under discussion combines pre-downsampling with a deep semantic path, achieving a compromise between speed and accuracy. Lightweight MobileNet architectures [17,18] have become the basis for such optimized models, and quantization methods [19] enable their implementation on low-power edge devices. This renders Fast-SCNN a potentially viable option for utilization in brewery production lines.
Regarding specific related works, the following approaches to the assessment of beer quality using spectroscopy, electronic noses, and neural networks should be given due consideration [20,21]. Research has demonstrated the efficacy of automatic systems in the classification of visual characteristics, including color, foam, and the presence of defects. In [22], the implementation of online identification of beer fermentation phases based on sensor signals and machine learning models is described.
In [23], a model of the fermentation process of mixed cultures in beer wort is proposed, with the model being based on AutoRegressive Recurrent Neural Network (AR-RNN). Despite the absence of any consideration of image segmentation in the paper, the created model allows for the prediction of the dynamics of fermentation over a long period of time.
Notwithstanding considerable progress in the field of natural and biomedical image segmentation, the prevailing architectures are inherently constrained when it comes to the analysis of foam:
  • blurred boundaries between classes (texture merging) lead to a decrease in mask quality;
  • the uniformity of the background and foam colors complicates pixel classification;
  • the presence of noise, glare and bubbles requires models that are resistant to false visual signals.
It is precisely these aspects that determine the feasibility of comparative analysis of architectures in the context of the specifics of visual assessment of the surface of beer wort.
The present study focuses on four architectures (Table 1): U-Net, DeepLabV3+, SegNet, and Fast-SCNN. This choice was driven by the need to find an equilibrium between accuracy, structural reproducibility, and computational costs. In particular, Fast-SCNN is regarded as a promising architecture for real-time implementation, while DeepLabV3+ is capable of achieving the highest levels of accuracy. SegNet represents a compromise between simplicity of implementation and quality, whereas U-Net is the baseline for complex textures.
Table 1. Comparative characteristics of baseline neural network architectures.

3. Methodology

The study began with the creation of a dataset comprising image masks. The data was collected at a brewery that utilizes open fermentation technology. Image acquisition was performed using an iPhone 12 Pro camera (Apple Inc., Cupertino, CA, USA) under standard production lighting conditions (fluorescent lamps). For the purposes of the study, 150 images representing different beer wort varieties and primary fermentation stages were selected from distinct fermentation batches. This approach is designed to ensure diversity in viewing angles, foam densities, and lighting conditions, thereby reflecting real-world industrial variability.
In order to accentuate the primary area of the beer wort surface, an analysis of the image contours was conducted. To facilitate the identification process, the image was converted to grayscale. Prior to image segmentation, preliminary smoothing was carried out to remove noise resulting from variations in lighting and shooting angles. Gaussian blurring was applied for this purpose [24,25].
In order to differentiate between low-contrast contours and the vat boundaries, an adaptive binarization process was applied. Notably, due to the heterogeneous texture of the foam and the variable lighting conditions, a fixed threshold proved ineffective. Consequently, the threshold value was empirically adjusted within the range of N ∈ [1, 30] for each sample, with a view to balancing sensitivity to object boundaries. This necessity for manual parameter tuning highlights the limitations of classical computer vision methods in this particular domain, further substantiating the transition to deep learning approaches.
The image was subjected to contour analysis in order to highlight the primary area of the beer wort surface using the cv2.findContours and cv2.drawContours from the OpenCV library [26,27].
The subsequent stage of the process involved the creation of a binary mask, the dimensions of which corresponded to those of the original image. The selected contour was rendered in white (value 255 in shades of grey).
The process of creating a mask leads to the formation of a new image, wherein only the pixels corresponding to the delineated contour area are retained. All other regions are assigned a value of zero, indicated by the color black. Therefore, an image is obtained in which extraneous background elements not pertaining to the surface under study have been eliminated.
Image segmentation was performed using the K-means algorithm [28], a methodology that groups pixels based on color similarity.
It is imperative to note that, in order to mitigate the potential bias of the semi-automatic K-means annotation, all generated masks underwent a rigorous visual verification and manual correction process by domain experts. This process ensured that the boundaries accurately reflected the technological states of the foam.
As a consequence of the image processing and segmentation procedures, a high-quality dataset was created. This consisted of 150 original images and their corresponding segmented images with three mask classes (Figure 1):
Figure 1. Example of an original (a) and segmented (b) image (Green: background; Beige: clean foam; Brown: contaminated foam).
  • Green background (tank, wall and other elements).
  • Contaminated foam (brown shades).
  • White clean foam.
As demonstrated in Table 2, the statistical distribution of pixels across these classes is highly variable, thus illustrating the heterogeneity of the dataset.
Table 2. Pixel distribution across semantic classes in the dataset.
In order to ensure a fair comparison of neural network performance, identical training and testing conditions were created. All the models were trained on the same dataset, which included images of the surface of beer wort measuring 384 × 512 pixels and corresponding masks containing three classes (background—0, clean foam—1, contaminated foam—2).
The set of images was divided into three subsets in a ratio of 70/15/15 [29]:
  • training set—105 (70%),
  • validation set—22 (≈15%),
  • test set—23 (≈15%).
Training was executed on a GeForce GTX 1650 (NVIDIA Corp., Santa Clara, CA, USA) graphics card with 4 GB of memory.
In each epoch, the primary metric for evaluating the quality of training was Pixel Accuracy [30,31], which is defined as the proportion of correctly classified pixels out of the total number of pixels in the test or validation data:
A c c u r a c y = T P + T N T P + T N + F P + F N ,
where TP are true positive, TN are true negative, FP are false positive, FN are false negative values, respectively.
However, to ensure a more comprehensive assessment, the set of metrics for the final comparison was expanded [31]. The mean intersection over union (mIoU) metric was utilized to evaluate the overlap between predictions and actual data:
m I o U = 1 C i = 0 C T P i T P i + F P i + F N i ,
where C is the total number of classes.
The Dice Coefficient was utilized to evaluate the spatial overlap accuracy. For a specific class i, it is defined as:
D i c e = 2 T P i 2 T P i + F P i + F N i ,
where TPi, FPi, and FNi represent the true positive, false positive, and false negative pixels for class i, respectively. To provide a single performance metric for the entire model, we calculated the Mean Dice Coefficient by averaging the scores across all three semantic classes.
The duration of the inference process was measured in milliseconds per frame (ms/frame). This metric is limited in its scope, as it solely accounts for the GPU forward pass time, while disregarding the latency associated with data loading.
In the process of training segmentation models, categorical cross-entropy [29] is used as a loss function, which is the standard for multi-class classification tasks when the model output is represented in one-hot encoding format.
During the testing phase, Categorical Cross-Entropy was employed to ensure the stable and effective training of all the architectures from Table 1, particularly in conditions of multi-class semantic image segmentation. The employment of the modern Adam optimizer has been demonstrated to facilitate expeditious and consistent convergence of models, obviating the necessity for intricate hyperparameter selection.
The Adam optimizer was utilized to minimize the loss function, thereby ensuring rapid and efficient optimization through the integration of the Momentum and RMSprop methods [32].
The following callbacks were used to enhance the learning process [29]:
  • ModelCheckpoint—saving the best model during training according to the validation accuracy metric.
  • EarlyStopping—stop training if validation loss does not improve over 10 epochs, which prevents overfitting.
  • ReduceLROnPlateau—dynamically decrease the learning rate if validation loss does not improve over 5 epochs.
The augmentation was executed utilizing the Albumentations library [15] and encompassed the following components:
  • horizontal mirroring (with a probability of 50%);
  • scaling, shifting, rotation (±15°);
  • random changes in contrast and brightness.

4. Research on Neural Network Architectures

4.1. Baseline U-Net

U-Net is recognized as one of the most effective architectures for semantic segmentation [7]. The system comprises an encoder that extracts the distinctive characteristics of an image, and a decoder that restores its resolution. Consequently, U-Net functions effectively on modest datasets, a crucial consideration in the context of our study.
The architecture of U-Net includes:
  • initial convolutional layer for extracting features from the image;
  • Max pooling for gradually reducing the dimensionality and preserving the most important characteristics;
  • Upsampling for restoring spatial resolution;
  • use of Concatenation, which helps to preserve information from the initial layers.
The detailed layer-by-layer specification of the baseline architecture is provided in Appendix A (Table A1).

4.2. Optimized U-Net

The U-Net architecture was modified to optimize the process of segmenting images of beer wort in open vats. During the development of the architecture, the principles of modern modifications, in particular UNet++ [8], were taken into account. However, the opposite strategy was applied, namely the simplification of the structure with a view to reducing the number of parameters and increasing performance in conditions of limited computing resources. The principal alterations implemented in this version comprise the incorporation of a batch normalization layer and a reduction in the quantity of network parameters. Batch Normalization (BN) [33] is a process that normalizes the output data of each layer of the neural network. This ensures the stability of the mean and standard deviation of activations (neuron output values). This approach has been shown to accelerate the training process and enhance the model’s resilience to variations in the distribution of layer output data, a crucial consideration when dealing with limited mini-batches [34]. Furthermore, Batch Normalization has been demonstrated to mitigate the issue of vanishing or exploding gradients.
The main changes included:
  • the introduction of a batch normalization layer to stabilize and accelerate training;
  • reducing the number of parameters and network depth to reduce computational complexity.
Batch Normalization is a process that standardizes the activations of each layer within a mini-batch to a zero mean and unit variance, thereby reducing internal covariate shift, accelerating convergence, and reducing the risk of gradient vanishing/explosion [33]. In the context of segmentation tasks, this approach ensures more stable training, even in scenarios where mini-batches are small and data illumination is variable. Moreover, recent studies have demonstrated accelerated Convolutional Neural Networks (CNNs) training and practical benefits of batch normalization in production pipelines [34].
For each convolutional layer, Batch Normalization performs the following operations:
1. The arithmetic mean and variance are calculated as follows:
μ B = 1 m i = 1 m x i ,
σ B 2 = 1 m i = 1 m ( x i μ B ) 2 ,
where xi is the initial value of the neuron, m is the size of the mini-batch, µB is the mean of the mini-batch, σB2 is the variance of activations in the mini-batch.
2. Normalization of the output values x in each layer is performed:
x ^ i = x i μ B σ B 2 + ε ,
where ε is the small constant to prevent division by zero.
3. The trained offset parameters β and scaling parameters γ are added during the training to determine the mini-batch label:
y i = λ x ^ i + β ,
where λ and β are trained parameters that allow Batch Normalization to adapt to the specifics of the task [33].
This operation is intended to circumvent the issue of overfitting within the network, thereby ensuring its flexibility.
The implementation of Batch Normalization has enabled the following:
  • reduced variability of activations between layers;
  • faster convergence;
  • resistance to noise and scene variations, which improves segmentation quality [33,34].
In addition to stabilizing training with Batch Normalization, structural changes were made to optimize the computational complexity of the architecture. The baseline U-Net architecture contains a substantial number of parameters, which has the potential to result in overfitting, particularly in cases where the available training data is limited. In the standard architecture, the number of filters in the first convolutional layer is 64, doubling at each level of network depth, reaching 1024 filters in the deepest layer [7].
As demonstrated in [8], the incorporation of flexible or nested skip connections between layers has been shown to enhance the accuracy of segmentation. This enhancement is attributed to the reduction in the semantic discrepancy between the encoder and decoder. The UNet++ architecture implements this approach by adding intermediate convolutional blocks between decoding layers. However, the research employs a contrary strategy–it simplifies the architecture and reduces the number of connections, thereby reducing computational complexity and accelerating inference without a significant loss of accuracy. In order to address this issue, a modification was made to reduce the number of parameters. In particular, the number of filters in the convolutional layers was reduced by half at each level. In this case, the progression was 32→ 64 → 128 instead of the more customary progression of 64 → 128 → 256 → 512 → 1024. Such a reduction in parameters not only reduces the computational complexity but also improves the generalization ability of the model, reducing the risk of overfitting. A comparable approach to architecture optimization is outlined in [9], wherein it is demonstrated that decreasing the number of parameters in the InvU-Net network leads to accelerated training and reduced hardware requirements without a discernible decline in accuracy.
The number of layers was also significantly reduced, which increased the speed of the model:
  • the number of convolutional layers has been reduced from 18 to 6;
  • the number of max pooling layers was reduced from 4 to 2;
  • the number of upsampling layers was reduced from 4 to 2;
  • the number of concatenation layers was reduced from 4 to 2.
These modifications have enabled a substantial reduction in the total number of parameters, with the final count standing at 205,027. This represents a more than 150-fold decrease compared to the baseline architecture.
The complete specification of the optimized architecture is presented in Appendix A (Table A2).

4.3. Comparison of the Baseline and Optimized U-Net

The following section presents a comparison of the baseline U-Net architecture with its optimized version, which has been developed to optimize the process of segmenting images of beer wort in open vats.
The objective of the modification is to reduce computational complexity and inference time without significantly reducing segmentation accuracy.
The baseline U-Net model has over 31 million parameters (31,379,075), which results in a significant computational load and long inference time. The optimized version contains 205,027 parameters, which is approximately 0.65% of the number of parameters in the baseline model. This substantial reduction in parameters was achieved by decreasing the depth of the network, the number of channels in the convolutional layers, and by introducing batch normalization, which reduces internal covariate shift and helps to stabilize and accelerate the training process [33,34].
The findings of the training process (see Table 3) and the image segmentation (see Figure 2) demonstrate that the optimized model outperforms the baseline model in terms of validation accuracy (val accuracy = 0.8885 vs. 0.8695), indicating an enhancement in segmentation quality despite a substantial reduction in the number of parameters.
Table 3. Comparison of the training results of the baseline and optimized U-Net.
Figure 2. Segmentation results of the U-Net architecture: (a) optimized; (b) original image; (c) baseline (Black: background; White: clean foam; Red: contaminated foam).
In addition to enhanced accuracy, the optimized model demonstrates a substantial increase in prediction generation speed: the total processing time for the test set was reduced from 6.6949 s to 1.138 s. This optimization is critical for tasks with limited resources or strict time requirements, such as mobile devices, embedded systems, or real-time modules [16,19,35].
As illustrated in Figure 3, the optimized U-Net demonstrates accelerated growth and earlier stabilization, resulting in higher accuracy values. It is evident that the baseline model demonstrates a slower rate of learning and exhibits a greater curve volatility. This dynamic is consistent with the changes made, which reduce internal distribution shift, improve gradient stability, and accelerate convergence without compromising generalization ability.
Figure 3. Graph of changes in the accuracy of segmentation of the validation set for the optimized and baseline U-Net architectures.
This behavior confirms that the proposed optimized architecture provides a superior balance between accuracy and speed, while concurrently maintaining training stability and model generalization ability.
In order to achieve optimal results in subsequent analyses, it is recommended to employ the optimized U-Net architecture, as it has been demonstrated to provide an optimal balance between accuracy and data processing speed.

4.4. Baseline DeepLabV3+

The DeepLabV3+ model represents an enhancement over the original DeepLabV3 model. Its core concept involves integrating advanced feature extraction techniques with precise spatial resolution recovery. This design facilitates the model’s ability to simultaneously consider both fine details and the global context of the scene [10,11,12].
The architecture consists of four components:
  • Initial convolutional block—primary feature extraction
  • Encoder (Xception Backbone)—deep extraction of semantics using depthwise separable convolutions and skip connections [36];
  • ASPP (Atrous Spatial Pyramid Pooling)—parallel branches with different dilation coefficients for multi-scale context [10,12];
  • Decoder—restores the segmentation map to its original resolution [12].
Table 4 presents the general structure of the network, while detailed layer-by-layer specifications are provided in Appendix B.
Table 4. General structure of the DeepLabV3+ network.
The total quantity of parameters in our implementation is as follows: the total number of trainable elements is 36,785,259, whereas the number of non-trainable elements is 58,240. It is acknowledged that deviations from the figures cited in the extant literature may be attributable to a number of factors, including the selection of a particular backbone, the quantity of channels, and the precise configuration of the layers [11,12].
1. Initial Convolution Block (1–7 layers)
Initial image processing is performed through two consecutive convolutional blocks (Conv2D + BatchNorm + ReLU), which extract basic patterns (contours, gradients) and prepare data for deep processing. The resolution is reduced from 384 × 512 × 3 to 189 × 253 × 64, creating an initial feature map. (see Table A3 in Appendix B for detailed layer configuration).
2. Encoder (8–133 layers)
The encoder is constructed using Xception blocks. Each of these methods employs depthwise separable convolutions (a combination of channelwise convolution and 1 × 1 pointwise), batch normalization, rectified linear units (ReLU activation), and skip connections (Add) to stabilize the training process and enhance gradient flow [36]. Downsampling is performed in a gradual manner as the number of channels increases (128 → 256 → 728 → 1024 → 2048), thereby enabling the network to recognize increasingly complex patterns. Separable convolutions have been demonstrated to result in a substantial reduction in the number of parameters and computations when compared with classical Conv2D, while preserving feature expressiveness [17,18,36]. The detailed structure of Xception blocks is presented in Table A4, Appendix B.
The Skip Connections (Add) function performs a summation of features that have been passed through separable convolution with the current layer after Pooling. This stabilizes training, reduces gradient loss, and preserves local details. The output of the final encoder layer block14_sepconv2_act is a feature map of size (12 × 16 × 2048), which is then processed by the ASPP block.
The employment of separable convolutional layers in this composition serves to reduce the number of parameters and enhance the stability of the training process [11,36]
3. ASPP (Atrous Spatial Pyramid Pooling) module (layers 134–149)
The ASPP constitutes the central component of DeepLab, thereby providing a multi-scale context (Table A4 in Appendix B). Four parallel branches with convolutions of varying dilation rates (e.g., d = 1, 6, 12, 18) form features from different fields of perception [10,12].
The four branches are then amalgamated into a single large tensor with dimensions (12 × 16 × 1024), after which convolution is applied to reduce the number of channels. The feature map that results from this process, which has dimensions of (12 × 16 × 256), is then fed into the Decoder. (Table A5 in Appendix B).
4. Decoder (150–169 layers)
Subsequent to processing in ASPP, the network progresses to the spatial resolution recovery stage [12]. In order to restore the original resolution (384 × 512), the following process is applied: repeated Upsampling blocks with sequential convolution layers, packet normalization, and ReLU activation.
The final layer produces a 3-channel class logit for each segment of the image. The step-by-step restoration process is outlined in Table A6, which can be found in Appendix B.
DeepLabV3+ uses Xception blocks for deep feature extraction, ASPP for multi-scale analysis, and a decoder for resolution recovery. This approach ensures that the model can perform semantic segmentation with high accuracy while remaining applicable to complex visual inspection tasks in manufacturing and biotechnological processes.

4.5. Optimized DeepLabV3+

In the optimization of the DeepLabV3+ neural network, the primary objective was to minimize computational complexity without substantial compromise to the quality of segmentation.
The original DeepLabV3+ architecture employs Xception as the foundational network for feature extraction. In the initial version, all Xception layers were left trained, which resulted in a substantial increase in the number of parameters.
The optimized model employs a pre-trained version of Xception, with all layers being frozen. The utilization of pre-trained weights constitutes an effective strategy for enhancing the stability and efficiency of deep model training [37]. A similar approach has been successfully implemented for MobileNetV2, where a reduction in computations is achieved without a noticeable loss of quality [17].
Freezing the parameters of the baseline network made it possible to:
  • reduce the number of trained parameters from 36,785,259 to 15,978,307, a decrease of 56.6%;
  • accelerate the training process by reducing computational costs;
  • reduce the risk of overfitting by using generalized high-level features.
At this stage of the modifications, the optimization was only applied to the base part of the network, while the other components remained unchanged.
The Atrous Spatial Pyramid Pooling (ASPP) module is important for the capture of multi-scale context; however, it is very expensive computationally due to the utilization of the substantial number of filters.
Research has demonstrated that the reduced number of filters in ASPP preserves the model’s capacity to capture context without substantial compromise to segmentation accuracy [10]. Furthermore, the optimization of normalization (Batch Normalization) has been demonstrated to enhance convergence stability during the training process [33].
Consequently, the reduction in ASPP and the enhancement of normalization may represent efficacious pathways for the subsequent evolution of the model.
In order to reach a compromise, the decoder is maintained in a compact form. This is achieved by means of a cascade of UpSampling2D → Conv2D + BN + ReLU, with a gradual reduction in channels (256→128→64→64) to form a 384 × 512 × 3 final output. In scenarios where even more intensive acceleration is required, the decoder can be narrowed and convolutional layers can be partially replaced with Separable convolution.
In the event of quality degradation, a partial “unfreezing” of the upper encoder blocks (initially block14, followed by block13) can be implemented, utilizing a modest learning rate and early stopping.
The proposed modification of DeepLabV3+ with complete freezing of Xception and training of only ASPP and the decoder has been shown to reduce the number of trained parameters by 56.6%, leading to significant reductions in computational costs and acceleration of training.
In consideration of the established outcomes pertaining to pre-training [17,37] and multi-scale context [10], this configuration represents a pragmatic compromise for systems that are constrained by computational resources. It is evident that the further narrowing of ASPP, the fine-tuning of Batch normalization [33], and the partial retraining of the upper layers of the encoder provide a flexible balance between speed and accuracy for specific data and hardware constraints.

4.6. Comparison of the Results of the Baseline and Optimized DeepLabV3+

This section will compare the fundamental DeepLabV3+ architecture with its optimized version. The objective of the latter is to reduce the number of trained parameters and the overall computational complexity of the model without significantly compromising segmentation quality [12].
The objective of the modification was to reduce training time and computational costs by freezing the Xception encoder and partially optimizing the ASPP module. It was hypothesized that this would preserve segmentation quality while concomitantly effecting a substantial reduction in the number of trained parameters.
Despite a substantial simplification, the outcomes of the experiments demonstrated a minor decline in segmentation accuracy on the validation dataset (see Table 5). The optimized model demonstrates an accuracy of 77.12%, while the baseline DeepLabV3+ achieves 81.85%. The loss function value also increased, indicating a loss of the model’s ability to adapt effectively due to limitations in training “frozen” layers.
Table 5. Comparison of the training results for the baseline and optimized DeepLabV3+ models.
As demonstrated in Figure 4, the validation curve of the optimized model exhibits a reduced growth amplitude and earlier stabilization, suggesting accelerated learning but with reduced depth. A reduction in the number of trained parameters was found to have a positive effect on the training time, but no significant increase in inference speed was observed.
Figure 4. Graph of changes in the segmentation accuracy of the validation set for the optimized and baseline DeepLabV3+.
The total inference time for the entire test set (23 images) remained virtually unchanged at approximately 4 s (avg. ~173 ms/frame). This confirms that the majority of the computational overhead is attributable to convolution operations performed on the GPU, irrespective of the training status of the layers [12,37].
Freezing the encoder resulted in a reduction in the model’s adaptability to specific data, which led to a loss of detail in object boundaries and a deterioration in segmentation quality. As illustrated in Figure 5, the visual outcomes of both models are evident.
Figure 5. Segmentation results of DeepLabV3+ architecture: (a) optimized: (b) original image; (c) baseline (Black: background; White: clean foam; Red: contaminated foam).
Notwithstanding a substantial diminution in the quantity of trained parameters, the model’s overall structure remains substantial, thereby exerting a considerable demand on the GPU. During the process of inference, the advantages of freezing layers are negligible, as kernel initialization, thread synchronization, and data transfer between the CPU and GPU have a substantial impact on the overall computation time.
Moreover, the limitations of deep learning libraries (TensorFlow, CUDA) preclude the full use of parameter reduction to enhance performance. It can thus be concluded that a decrease in architecture complexity does not necessarily result in a corresponding decrease in processing time, particularly in the context of high-performance GPUs.
In order to enhance the efficiency of the model, it is recommended to employ hardware-oriented optimization methods.
Pruning involves the elimination of superfluous parameters and connections with the objective of reducing the model’s size and accelerating its operational speed [35].
Quantization can be defined as the process of reducing the bit depth of weights and activations (for example, 32-bit to 8-bit) without significant loss of accuracy [35,38].
Hardware-specific optimization is achieved through the utilization of compilers such as TensorRT or TVM. These compilers facilitate the efficient operation of models on GPUs and mobile devices [39].

4.7. Baseline Fast-SCNN

Fast-SCNN is a compact and efficient architecture for real-time semantic image segmentation [16]. The software in question has been adapted in such a manner that it is able to run on devices with limited computing resources, thereby providing an optimal balance between speed and accuracy. The fundamental concept is to initially reduce the spatial resolution (in order to minimize the cost of subsequent computations), subsequently extract the global context from small feature maps, and ultimately integrate it with the detailed features of the preceding layers. The model employs depthwise separable convolutions (comparable to MobileNetV2 [34]) and Batch Normalization to ensure stable and efficient training [33].
The main components of the Fast-SCNN architecture [16]:
1. Learning to Downsample—early reduction in spatial resolution using standard and depthwise convolutions with Batch Normalization and ReLU activation; preserves local details with minimal Floating Point Operations (FLOPs).
2. Global Feature Extractor—a sequence of (depthwise) convolutions with BN/ReLU, which forms a global context on a reduced representation. In the original, it is possible to use linear bottlenecks and inverted residuals [34].
3. Feature Fusion Module—merging of “detailed” (early) and “global” (late) features through Upsampling + Concatenation and subsequent light convolution processing (DWConv + 1 × 1).
4. Classifier Head—final 1 × 1 convolution to the number of classes and scaling of the output to the size of the input frame.
The detailed layer-by-layer structure of the baseline Fast-SCNN architecture is provided in Appendix C (Table A7).
The Fast-SCNN architecture is distinguished by its low processing latency, a property that facilitates its operation in real time, even on mobile or embedded devices [16,26]. The model under consideration is notable for its considerably reduced parameter count of approximately 341,651, a figure that is substantially lower than that of classic segmentation models (e.g., DeepLabV3+). This renders Fast-SCNN particularly well-suited to edge devices and industrial control systems.
However, it exhibits marginally diminished accuracy in comparison to more intricate architectures, particularly during the processing of voluminous and heterogeneous datasets [16,34]. The model demonstrates a restricted capacity to analyze the deep context of complex scenes, a limitation that can be attributed to the Global Feature Extractor’s architecture, which has been simplified.
Nevertheless, Fast-SCNN remains a promising solution for tasks where high processing speed and limited resources are critical, particularly for the visual control of technological processes in the food industry [1,16].

4.8. Optimized Fast-SCNN

The objective of the modification was twofold: firstly, to reduce the computational complexity and the number of parameters of Fast-SCNN; and secondly, to achieve this without significantly compromising segmentation quality. This would enable the model to operate stably in near real-time mode on systems with limited resources [16,26].
The key optimization approach entailed the implementation of Separable Convolutions (Separable convolution), which integrate depthwise (channel-by-channel) and pointwise (1 × 1) convolutions, superseding the conventional convolutional layers. The separation of spatial and inter-channel filtering has been demonstrated to reduce parameters and FLOPs significantly [36,38].
  • Depthwise—applies a separate filter (e.g., 3 × 3) to each channel;
  • Pointwise—performs 1 × 1 convolution to combine information between channels.
The number of parameters in a standard convolution with computational complexity is formally defined.
O ( D K × D K × M × N ) ,
is reduced to
O ( D K × D K × M + M × N )
where Dk is the size of the convolution kernel, M is the number of input channels, N is the number of output channels.
Thus, using separable convolutions significantly increases model efficiency. For example:
  • Standard convolution: 3 × 3 × 32 × 64 = 18,432 operations.
  • Separable Convolution: 3 × 3 × 32 + 32 × 64 = 288 + 2048 = 2336 operations.
In addition, further optimization was carried out on the optimized version of Fast-SCNN:
  • the number of filters in the initial layers was reduced to reduce the load on the GPU;
  • the number of convolutional blocks was reduced while retaining the Concatenation layer to combine local and global features. This allowed information to be preserved without significantly increasing complexity;
  • the 384 × 512 spatial resolution was preserved, simplifying the model structure but slightly increasing the FLOPs compared to the baseline Fast-SCNN containing the Learning to Downsample stage [16];
  • batch normalization [33] is applied to each block after each separable convolution to stabilize the training process and reduce internal distribution shifts.
Consequently, the number of model parameters has decreased to 25,470—a reduction of over 13 times compared to the baseline Fast-SCNN implementation (341,651 parameters).
The detailed specification of the optimized structure is presented in Appendix C (Table A8).

4.9. Comparison of the Results of the Baseline and Optimized Fast-SCNN

Despite the substantial reduction in parameters in the optimized version of Fast-SCNN (25,470 versus 341,651 in the baseline version), the inference time was found to be significantly longer—91.3 ms versus 41.7 ms (see Table 6). On initial observation, the result appears to contradict the anticipated relationship between the number of parameters and processing speed. However, a technical explanation exists to account for this discrepancy.
Table 6. Comparison of the results of training the baseline and optimized Fast-SCNN.
As demonstrated in Figure 6, the optimized Fast-SCNN demonstrates a faster convergence rate, exhibits a more pronounced rise in the validation accuracy curve, and subsequently stabilizes with minimal fluctuations. It is evident that the baseline model requires a greater number of epochs to reach a plateau; only after the 18th–22nd epoch does it gradually approach ~0.84–0.85. During the training process, the optimized version consistently exhibited higher validation accuracy and reduced variability following stabilization, suggesting accelerated and more dependable generalization.
Figure 6. Graph of changes in the segmentation accuracy of the validation set for the optimized and baseline Fast-SCNN.
The study proposes a modification to the Fast-SCNN architecture so that the spatial resolution of the input image is not reduced prematurely. In contrast to the baseline model, which contains a ‘Learning to Downsample’ block in which the majority of convolution operations are performed on 96 × 128 reduced tensors, the optimized architecture utilizes 384 × 512 tensors for the majority of the computational process. This results in a substantial increase in spatial FLOPs, despite a concurrent reduction in parameters [16].
With regard to the efficacy of separable convolutions (SeparableConv2D), it is important to acknowledge that, in principle, these convolutions offer a substantial reduction in computational complexity (Xception and MobileNet V1/V2) [17,36,38]. However, the practical performance enhancement is contingent on the extent to which the execution environment is optimized with respect to both hardware and software. It is important to note that not all execution environments (backends) have optimized kernels for depthwise convolution operations in equal measure. However, the expected benefits of such convolutions may not be implemented in practice without proper optimizations at the compiler level. These optimizations include combining adjacent operations into shared kernels, auto-tiling and optimized operator scheduling [39].
Batch Normalization layers are key to training stability, yet their use during the inference stage also impacts real-time performance. In the absence of preliminary folding (merging Batch Normalization → Convolutional layer) in the inference graph, additional operational costs are incurred [19,33]. Research has indicated that, in the absence of optimization for the target platform, Batch Normalization has the potential to act as a bottleneck in high-speed applications.
Summarizing, it should be noted that the actual inference speed depends not only on the number of parameters or FLOPs, but also on the following:
  • the depth of downsampling and the spatial dimensions of intermediate tensors;
  • the effectiveness of implementing individual layers in a specific framework;
  • the presence or absence of computational graph compilation (ONNX, TVM, TensorRT);
  • hardware architecture features (GPU type, memory size, caching, TensorCore operation support, etc.).
In the context of real-time tasks, it is imperative to profile the model on the target platform, taking into account the actual execution path, as opposed to merely focusing on nominal efficiency. When optimizing, it is advised to utilize specialized graph compilation tools such as TensorRT, TVM and ONNX Runtime, in addition to testing different execution modes (eager/static, XLA).
A comparative analysis of the baseline and optimized Fast-SCNN architectures (Table 6) reveals that while the optimized model exhibits a longer inference time, it concomitantly provides enhanced segmentation accuracy (0.8659 vs. 0.8479). A comparison of the results presented in Figure 7 indicates that the shallow depth of the neural network and the absence of downsampling contribute to enhanced segmentation detail.
Figure 7. Segmentation results of Fast-SCNN architecture: (a) optimized; (b) original image; (c) baseline (Black: background; White: clean foam; Red: contaminated foam).
Given the paramount importance of result quality within the present study, it was determined that the optimized version of Fast-SCNN represents the optimal compromise between speed and accuracy, a critical consideration for visual control in a production process.

4.10. Baseline Segnet

SegNet is a classic deep learning architecture designed for semantic image segmentation, providing high-quality results at moderate computational cost [13]. The key concept is the use of a symmetric encoder–decoder structure, in which the decoding layers restore spatial resolution by upscaling feature maps and using the max-pooling indices obtained during the encoding stage.
This approach enables object contours to be reconstructed with high accuracy, even when there are only a few training examples available.
SegNet was chosen for comparison in this study due to its effectiveness in processing complex textures and contours in images. This makes it well-suited to visual inspection in industrial settings, particularly when training samples are limited [13,14].
The SegNet architecture is made up of the following main components:
  • Encoder: A convolutional layer, Batch normalization and ReLU activation sequence is followed by a Max pooling operation, which gradually reduces the spatial resolution (384 × 512 to 24 × 32) and increases the number of channels (64 to 512). During pooling, the maximum indices are stored and are then used in the decoder to accurately restore the positions.
  • Decoder: restores spatial resolution symmetrically using upsampling, convolutional layer, BN and ReLU activation at each level, gradually reducing the number of channels from 512 to 64. Unlike other architectures, SegNet does not use skip connections; instead, it relies on pooling indices, which reduces memory usage [13].
  • Final classifier: The output image is formed by the last convolutional layer, which has a number of channels equal to the number of classes [13].
The complete structure of the baseline SegNet architecture is detailed in Appendix D (Table A9). The total number of parameters is 11,743,875.
The advantages of SegNet include the effective restoration of spatial structure through the reuse of pooling indices, which prevents the loss of detail when reducing feature sizes [13]. Its implementation also requires less memory during training than architectures with skip connections (e.g., U-Net) because there is no direct copying of feature maps [40].
This architecture is also suitable for segmenting objects with complex morphology, particularly when processing images with a limited number of training examples.
However, SegNet also has its disadvantages. It is more computationally complex and has more parameters than compact architectures such as Fast-SCNN [13,16], and the absence of skip connections can lead to lower accuracy when localizing small objects.

4.11. Optimized SegNet

The baseline version of SegNet contains over 11.7 million parameters, a limitation that restricts its real-time application on devices with limited resources. The objective of the optimization process was to achieve a substantial reduction in the number of parameters and computational complexity, while preserving high segmentation quality.
As part of the optimization process, standard convolutional layers were replaced with Separable Convolutions, which significantly reduced computational costs while maintaining quality [16,18]. The merits of this approach have already been demonstrated on Fast-SCNN: a reduction in FLOPs, a decrease in memory consumption and an enhancement in throughput.
Structural optimization of the architecture:
  • Batch normalization was added after each convolution operation to stabilize training and eliminate internal covariate bias [33];
  • the number of filters at each level has been reduced to minimize the computational load;
  • the classic encoder–decoder structure has been preserved to ensure the controlled restoration of the image’s spatial structure;
  • the number of channels at different levels has been reduced to minimize computational complexity while ensuring accurate segmentation [13].
The detailed specification of the optimized SegNet is provided in Appendix D (Table A10).
The outcome of this process is a substantial decrease in the number of parameters, from 11,743,875 to a mere 43,102. Furthermore, the incorporation of Separable Convolutions and Batch Normalization has enhanced computational efficiency and training stability.
The employment of separable convolutions in conjunction with a minimalist approach to constructing the ascending path ensures an optimal balance between segmentation quality and processing speed. This renders the optimized version of SegNet particularly well-suited for deployment in mobile and embedded applications [13,16,18,33].

4.12. Comparison of the Results of the Baseline and Optimized SegNet

This section will compare the baseline SegNet architecture with its optimized version, which has been designed to reduce computational complexity and increase performance without compromising segmentation accuracy.
The comparison results (Table 7) demonstrate that the baseline model attained its maximum accuracy at the 32nd epoch, while the optimized model continued to improve until the 47th training epoch, indicating more stable convergence and better generalization. The validation accuracy increased from 81.38% to 83.54%, and the loss function decreased from 0.4568 to 0.3879, thus confirming the positive effect of structural optimization.
Table 7. Comparison of the training results of the baseline and optimized SegNet.
As illustrated in Figure 8, the dynamics of accuracy change during training are evident. As is evident, the optimized model exhibits a more gradual and consistent enhancement in accuracy, devoid of any abrupt fluctuations. This suggests a diminution in overfitting and an enhancement in gradient stability due to the implementation of Batch Normalization and a reduction in parameters.
Figure 8. Graph of changes in segmentation accuracy of the validation set for the optimized and baseline SegNet.
As illustrated in Figure 9, the optimized architecture provides clearer object boundaries and more accurate reproduction of fine details, while the baseline model tends to blur the contours.
Figure 9. SegNet architecture segmentation results: (a) optimized; (b) original image; (c) baseline (Black: background; White: clean foam; Red: contaminated foam).
In addition to enhancing the quality, the optimized model exhibited a substantial enhancement in performance. The inference time was reduced by 4.7 times, and the average GPU load decreased from 77% to 33%. These results indicate a significant increase in the efficiency of computing resource utilization.
This acceleration can be attributed to the implementation of separable convolutions (depthwise and pointwise), a reduction in the number of filters, and a simplified decoder architecture, which collectively result in a substantial reduction in FLOPs without compromising the model’s representative power [13,16,18,33,35].
The optimized model has been demonstrated to enhance performance and segmentation accuracy, and is suitable for real-time operation on devices with limited resources. Consequently, it will be selected for further research and applications.

5. Selecting a Neural Network for the Task of Beer Surface Segmentation During the Main Fermentation Stage

This phase aimed to identify the most efficacious neural network architecture for the task of semantic segmentation of the beer wort surface during primary fermentation.
The primary evaluation criterion was pixel classification accuracy. However, to ensure a comprehensive assessment, Mean Intersection over Union (mIoU) and Dice Coefficient were also analyzed.
In the context of beer foam surface analysis, these metrics are crucial because they provide accurate separation of clean and contaminated foam areas, allowing for assessment of the fermentation process and beer environment stability [2,21].
Following the conclusion of the experimental phase, a selection process was initiated. This process involved the identification of the most appropriate model from each pair, with the baseline and the optimized model being the candidates. The comparative outcomes of training these models are presented in Table 8.
Table 8. Comparison of the training results of the best neural networks.
The performance criterion indicates that lightweight architectures (SegNet-opt, U-Net-opt) are particularly suitable for scenarios where resources are limited, while the heavy DeepLabV3+ architecture does not offer competitive latency.
In order to address the specific requirement of detecting contaminated foam, the per-class accuracy was analyzed (see Table 9).
Table 9. Class-wise classification accuracy.
As illustrated in Table 9, optimized U-Net attains the maximum accuracy of 78.23% for the “Contaminated Foam” category, which is recognized as the most challenging and technologically significant class.
An examination of the segmentation results presented in Figure 10 of the test image (c) reveals discernible qualitative disparities among the architectures. U-Net (a) is the most accurate method of reproducing the contour of the fermentation vat and the shape of the foam, while also preserving the fine texture and local “islands” of contamination. However, in some places, it gives isolated false-positive pixels inside the foam array. DeepLabV3+ (b) generates a mask that is excessively smoothed: the edge zone is delineated coarsely, resulting in the loss of fine internal details. The Fast-SCNN (d) model demonstrates a balanced result, exhibiting a distinct edge and moderate sensitivity to internal inhomogeneities. However, the model does not fully capture all the fine inclusions. SegNet (e) has been demonstrated to correctly highlight the boundaries and overall shape, while also preserving local inhomogeneities to a greater extent than DeepLabV3+. However, it has been observed that some minor inclusions are still “smoothed out”. Visual illustrations are consistent with quantitative metrics.
Figure 10. Image segmentation results: (a) optimized U-Net; (b) baseline DeepLabV3+; (c) original image; (d) optimized Fast-SCNN; (e) optimized SegNet (Black: background; White: clean foam; Red: contaminated foam).
The validation accuracy curve (Figure 11) demonstrates that the behavior of the curves indicates the dependence of accuracy on the architectural balance between preserving local details and the ability to generalise the global context. Models that preserve high spatial resolution (U-Net, Fast-SCNN) have been shown to perform better in the segmentation of beer foam, while architectures incorporating deep downsampling or a simplified decoder (DeepLabV3+, SegNet) have been demonstrated to be inferior in terms of accuracy.
Figure 11. Graph of segmentation accuracy changes in the validation set U-Net Optimized, DeepLabV3+ baseline, Fast-SCNN Optimized, SegNet optimized. Horizontal dashed lines of corresponding colors indicate the maximum accuracy achieved by each model.
Following a comparative analysis, the optimized U-Net architecture was selected as the final solution. It offers an optimal compromise between high quality (mIoU 76.72%), reliable detection of contaminated foam, and real-time capability (49.5 ms/frame).

Limitations of the Study

Initially, the dataset was collected from a single brewery, which may have introduced variations in tank geometry or significant differences in lighting conditions at other facilities. Such variations might necessitate domain adaptation or fine-tuning of the models. Secondly, the ground truth masks were generated using a semi-automatic K-means approach. Despite the fact that these masks were subjected to visual verification by experts, this method may introduce minor boundary inaccuracies when compared to pixel-perfect manual annotation. Finally, the inference speed was measured on a specific desktop GPU configuration (GTX 1650). In the context of deployment on low-power embedded processors (e.g., Raspberry Pi or Jetson Nano), it may be necessary to undertake additional optimization steps, such as quantization or model pruning, which were not addressed in the present study.

6. Conclusions

The results of the analysis allow the following conclusions to be drawn:
The optimized U-Net model demonstrated the highest level of accuracy (86.43% for the test set). Notably, it attained the highest mIoU (76.72%) and exhibited superior performance in detecting the “Contaminated Foam” class (78.23%), which is the primary indicator for process quality. It exhibits minimal GPU load (18%) and a low inference time (49.5 ms), making it the optimal choice in terms of quality, suitable for real-time systems.
DeepLabV3+ exhibits a satisfactory level of accuracy (Test 76.97%), yet it is the most resource-intensive (ASPP + deep Xception), consequently resulting in an inference time of 174 ms—a duration that is considerably longer than that of other models.
The optimized Fast-SCNN model offers a satisfactory compromise; however, the high GPU load (95%) and the time of 91 ms indicate that actual performance is contingent on downsampling depth and backend.
Optimized SegNet demonstrates balanced performance (Test 83.09%) and the shortest inference time in our experiment—44.6 ms, with moderate GPU load (33%). While it is the most expeditious option, qualitative analysis revealed a tendency to smooth out fine details of contamination.
Given the paramount importance of accuracy metrics for the segmentation task and the detection of contaminated foam, the optimized version of U-Net was identified as the most suitable architecture for analyzing the surface of beer during primary fermentation. The system has been demonstrated to provide optimal accuracy with reduced resource consumption.
Therefore, the Optimized U-Net is recommended for subsequent implementation in automated visual control systems for fermentation processes.
The findings of the study can be utilized as a foundation for the development of an automated robotic system for the selective collection of contaminated foam, as well as for the construction of systems for the monitoring of fermentation processes. This will reduce dependence on the human factor, improve reproducibility and ensure stable quality of beer products.

7. Prospects for Further Research

The optimization of deep learning models is a key area of development for computer vision systems, particularly in real-world production environments where computing resources are frequently constrained. It has been demonstrated that tasks such as beer wort surface segmentation do not necessitate the utilization of excessively deep neural networks.
In this study, a range of optimization approaches were evaluated. The most practical of these were parameter reduction, separable convolutions (depthwise and pointwise), Batch Normalization, and structural network simplification [13,16,17,36,38]. In particular, in our implementation, the optimized U-Net reduced the model size by more than 150 times relative to the baseline configuration, without a significant loss of accuracy.
However, the study also highlighted the limitations of generic approaches, such as the ineffectiveness of “freezing” pre-trained layers for specific texture recognition tasks like beer foam analysis.
Future research will focus on the following directions to further enhance the system’s performance:
  • Advanced Model Compression. We plan to investigate Pruning techniques to eliminate insignificant weights and redundant connections in the U-Net decoder. This approach has been shown to result in substantial compression accompanied by minimal quality loss [35].
  • Hardware-Specific Optimization. Further acceleration can be achieved through Post-Training Quantization (PTQ). Transitioning weights and activations to INT8 is expected to result in substantial reductions in memory requirements and significant enhancements in computational speed on Tensor Core-enabled GPUs (see [19] for detailed discussion).
  • Graph Compilation. Deploying the model using hardware-aware compilers such as TensorRT, TVM, or OpenVINO will facilitate operator fusion and kernel auto-tuning. The efficacy of such compilation in reducing inference latency without compromising accuracy is substantiated by extant references [39].
  • System Integration. The final stage involves integrating the optimized U-Net into the control loop of a Cartesian coordinate robot, developing algorithms to convert segmentation masks into mechanical trajectories.
This development presents novel prospects for the incorporation of deep learning algorithms into real-time quality control and monitoring systems, ensuring that narrow computer vision tasks in the agri-food sector are addressed by architectures that are both efficient and robust.

Author Contributions

Conceptualization, M.V.; Methodology, M.V. and A.M.; Software, M.V. and G.L.; Validation, P.M. and K.K.-C.; Formal analysis, G.L. and P.M.; Data curation, G.L. and T.K.; Writing—review & editing, T.K., A.M. and K.K.-C.; Visualization, T.K. and K.K.-C.; Supervision, A.M.; Project administration, A.M.; Funding acquisition, G.L., P.M. and K.K.-C. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Institutional Review Board Statement

Not applicable.

Data Availability Statement

The raw data supporting the conclusions of this article are not publicly available due to a Non-Disclosure Agreement (NDA) with the industrial partner. However, the data presented in this study are available on request from the corresponding author.

Conflicts of Interest

The authors declare no conflicts of interest.

Appendix A

Table A1. Baseline U-Net architecture.
Table A2. Optimized U-Net architecture.

Appendix B

Table A3. Initial convolutional layers of the DeepLabV3+ network.
Table A4. Structure of Xception blocks of the DeepLabV3+ network.
Table A5. ASPP module of the DeepLabV3+ network.
Table A6. Step-by-step image restoration of the DeepLabV3+ network.

Appendix C

Table A7. Baseline Fast-SCNN architecture.
Table A8. Optimized Fast-SCNN architecture.

Appendix D

Table A9. Baseline SegNet architecture.
Table A10. Optimized SegNet architecture.

References

  1. Addanki, M.; Patra, P.; Kandra, P. Recent Advances and Applications of Artificial Intelligence and Related Technologies in the Food Industry. Appl. Food Res. 2022, 2, 100126. [Google Scholar] [CrossRef] [Scilit]
  2. Gonzalez Viejo, C.; Torrico, D.D.; Dunshea, F.R.; Fuentes, S. Emerging Technologies Based on Artificial Intelligence to Assess the Quality and Consumer Preference of Beverages. Beverages 2019, 5, 62. [Google Scholar] [CrossRef] [Scilit]
  3. Kunze, W.; Manger, H.-J. Technology Brewing & Malting; 5th revised English ed.; VLB: Berlin, Germany, 2014. [Google Scholar]
  4. Velesaca, H.O.; Suárez, P.L.; Mira, R.; Sappa, A.D. Computer Vision Based Food Grain Classification: A Comprehensive Survey. Comput. Electron. Agric. 2021, 187, 106287. [Google Scholar] [CrossRef] [Scilit]
  5. Bowler, A.L.; Pound, M.P.; Watson, N.J. Domain Adaptation and Federated Learning for Ultrasonic Monitoring of Beer Fermentation. Fermentation 2021, 7, 253. [Google Scholar] [CrossRef] [Scilit]
  6. Diéguez, Á.; Moreno, S.; Moncada-Madrazo, S.; Caravaca, O.; Diéguez, J.; Canals, J.; Benito-Altamirano, I.; Prades, J.D.; Vilà, A. Chip-Sized Microscopy for Continuous Monitoring: Application in White Wine Fermentation and Yeast Cell Counting via Deep Learning. Eng. Proc. 2024, 78, 1. [Google Scholar] [CrossRef] [Scilit]
  7. Ronneberger, O.; Fischer, P.; Brox, T. U-Net: Convolutional Networks for Biomedical Image Segmentation. In Medical Image Computing and Computer-Assisted Intervention—MICCAI 2015; Navab, N., Hornegger, J., Wells, W.M., Frangi, A.F., Eds.; Lecture Notes in Computer Science; Springer International Publishing: Cham, Switzerland, 2015; Volume 9351, pp. 234–241. [Google Scholar] [CrossRef] [Scilit]
  8. Zhou, Z.; Rahman Siddiquee, M.M.; Tajbakhsh, N.; Liang, J. UNet++: A Nested U-Net Architecture for Medical Image Segmentation. In Deep Learning in Medical Image Analysis and Multimodal Learning for Clinical Decision Support; Stoyanov, D., Taylor, Z., Carneiro, G., Syeda-Mahmood, T., Martel, A., Maier-Hein, L., Tavares, J.M.R.S., Bradley, A., Papa, J.P., Belagiannis, V., et al., Eds.; Lecture Notes in Computer Science; Springer International Publishing: Cham, Switzerland, 2018; Volume 11045, pp. 3–11. [Google Scholar] [CrossRef] [Scilit]
  9. Slyusar, V.I. Inverse Architecture U-Net—InvU-Net. Artif. Intell. 2024, 4, 115–132. [Google Scholar] [CrossRef] [Scilit]
  10. Chen, L.-C.; Papandreou, G.; Schroff, F.; Adam, H. Rethinking Atrous Convolution for Semantic Image Segmentation. arXiv 2017, arXiv:1706.05587. [Google Scholar] [CrossRef] [Scilit]
  11. Chen, L.-C.; Papandreou, G.; Kokkinos, I.; Murphy, K.; Yuille, A.L. DeepLab: Semantic Image Segmentation with Deep Convolutional Nets, Atrous Convolution, and Fully Connected CRFs. IEEE Trans. Pattern Anal. Mach. Intell. 2018, 40, 834–848. [Google Scholar] [CrossRef] [Scilit]
  12. Chen, L.-C.; Zhu, Y.; Papandreou, G.; Schroff, F.; Adam, H. Encoder-Decoder with Atrous Separable Convolution for Semantic Image Segmentation. In Proceedings of the European Conference on Computer Vision (ECCV), Munich, Germany, 8–14 September 2018; pp. 801–818. [Google Scholar] [CrossRef] [Scilit]
  13. Badrinarayanan, V.; Kendall, A.; Cipolla, R. SegNet: A Deep Convolutional Encoder-Decoder Architecture for Image Segmentation. IEEE Trans. Pattern Anal. Mach. Intell. 2017, 39, 2481–2495. [Google Scholar] [CrossRef] [Scilit]
  14. Kulwa, F.; Li, C.; Zhao, X.; Cai, B.; Xu, N.; Qi, S.; Chen, S.; Teng, Y. A State-of-the-Art Survey for Microorganism Image Segmentation Methods and Future Potential. IEEE Access 2019, 7, 100243–100269. [Google Scholar] [CrossRef] [Scilit]
  15. Shorten, C.; Khoshgoftaar, T.M. A Survey on Image Data Augmentation for Deep Learning. J. Big Data 2019, 6, 60. [Google Scholar] [CrossRef] [Scilit]
  16. Poudel, R.P.K.; Liwicki, S.; Cipolla, R. Fast-SCNN: Fast Semantic Segmentation Network. In Proceedings of the British Machine Vision Conference (BMVC), Cardiff, UK, 9–12 September 2019; p. 289. [Google Scholar] [CrossRef] [Scilit]
  17. Howard, A.G.; Zhu, M.; Chen, B.; Kalenichenko, D.; Wang, W.; Weyand, T.; Andreetto, M.; Adam, H. MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications. arXiv 2017, arXiv:1704.04861. [Google Scholar] [CrossRef] [Scilit]
  18. Howard, A.; Sandler, M.; Chu, G.; Chen, L.-C.; Chen, B.; Tan, M.; Wang, W.; Zhu, Y.; Pang, R.; Vasudevan, V.; et al. Searching for MobileNetV3. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), Seoul, Republic of Korea, 27 October–2 November 2019; pp. 1314–1324. [Google Scholar] [CrossRef] [Scilit]
  19. Jacob, B.; Kligys, S.; Chen, B.; Zhu, M.; Tang, M.; Howard, A.; Adam, H.; Kalenichenko, D. Quantization and Training of Neural Networks for Efficient Integer-Arithmetic-Only Inference. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Salt Lake City, UT, USA, 18–23 June 2018; pp. 2704–2713. [Google Scholar] [CrossRef] [Scilit]
  20. Gonzalez Viejo, C.; Fuentes, S.; Hernandez-Brenes, C. Smart Detection of Faults in Beers Using Near-Infrared Spectroscopy, a Low-Cost Electronic Nose and Artificial Intelligence. Fermentation 2021, 7, 117. [Google Scholar] [CrossRef] [Scilit]
  21. Gonzalez Viejo, C.; Torrico, D.D.; Dunshea, F.R.; Fuentes, S. Development of Artificial Neural Network Models to Assess Beer Acceptability Based on Sensory Properties Using a Robotic Pourer: A Comparative Model Approach to Achieve an Artificial Intelligence System. Beverages 2019, 5, 33. [Google Scholar] [CrossRef] [Scilit]
  22. Buonocore, D.; Ciavolino, G.; Dello Iacono, S.; Liguori, C. Online Identification of Beer Fermentation Phases. Fermentation 2024, 10, 399. [Google Scholar] [CrossRef] [Scilit]
  23. O’Brien, A.; Zhang, H.; Allwood, D.M.; Rawsthorne, A. From Data to Draught: Modelling and Predicting Mixed-Culture Beer Fermentation Dynamics Using Autoregressive Recurrent Neural Networks. Modelling 2024, 5, 201–222. [Google Scholar] [CrossRef] [Scilit]
  24. Strasburger, H.; Bach, M.; Heinrich, S.P. Blur Unblurred—A Mini Tutorial. i-Perception 2018, 9, 2041669518765850. [Google Scholar] [CrossRef] [Scilit]
  25. Boateng, K.O.; Asubam, B.W.; Laar, D.S. Improving the Effectiveness of the Median Filter. Int. J. Comput. Appl. 2012, 35, 0975–8887. [Google Scholar]
  26. OpenCV. Contours: Getting Started (Python). Available online: https://docs.opencv.org/4.x/d4/d73/tutorial_py_contours_begin.html (accessed on 20 January 2025).
  27. Bradski, G. The OpenCV Library. Dr. Dobb’s J. Softw. Tools 2000, 120, 120–125. [Google Scholar]
  28. Celebi, M.E.; Kingravi, H.A.; Vela, P.A. A Comparative Study of Efficient Initialization Methods for the K-Means Clustering Algorithm. Expert Syst. Appl. 2013, 40, 200–210. [Google Scholar] [CrossRef] [Scilit]
  29. Bengio, Y. Practical Recommendations for Gradient-Based Training of Deep Architectures. In Neural Networks: Tricks of the Trade; Montavon, G., Orr, G.B., Müller, K.-R., Eds.; Lecture Notes in Computer Science; Springer: Berlin/Heidelberg, Germany, 2012; Volume 7700, pp. 437–478. [Google Scholar] [CrossRef] [Scilit]
  30. Everingham, M.; Van Gool, L.; Williams, C.K.I.; Winn, J.; Zisserman, A. The Pascal Visual Object Classes (VOC) Challenge. Int. J. Comput. Vis. 2010, 88, 303–338. [Google Scholar] [CrossRef] [Scilit]
  31. Dice, L.R. Measures of the Amount of Ecologic Association Between Species. Ecology 1945, 26, 297–302. [Google Scholar] [CrossRef] [Scilit]
  32. Kingma, D.P.; Ba, J. Adam: A Method for Stochastic Optimization. In Proceedings of the 3rd International Conference on Learning Representations (ICLR), San Diego, CA, USA, 7–9 May 2015. [Google Scholar] [CrossRef] [Scilit]
  33. Ioffe, S.; Szegedy, C. Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift. In Proceedings of the 32nd International Conference on Machine Learning (ICML), Lille, France, 6–11 July 2015; pp. 448–456. [Google Scholar] [CrossRef] [Scilit]
  34. Jung, W.; Jung, D.; Kim, B.; Lee, S.; Rhee, W.; Ahn, J.H. Restructuring Batch Normalization to Accelerate CNN Training. In Proceedings of the SysML Conference, Palo Alto, CA, USA, 31 March–2 April 2019. [Google Scholar] [CrossRef] [Scilit]
  35. Han, S.; Mao, H.; Dally, W.J. Deep Compression: Compressing Deep Neural Networks with Pruning, Trained Quantization and Huffman Coding. In Proceedings of the International Conference on Learning Representations (ICLR), San Juan, Puerto Rico, 2–4 May 2016. [Google Scholar] [CrossRef] [Scilit]
  36. Chollet, F. Xception: Deep Learning with Depthwise Separable Convolutions. In Proceedings of the 2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR); IEEE: Honolulu, HI, USA, 2017; pp. 1800–1807. [Google Scholar] [CrossRef] [Scilit]
  37. He, K.; Zhang, X.; Ren, S.; Sun, J. Deep Residual Learning for Image Recognition. In Proceedings of the 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR); IEEE: Las Vegas, NV, USA, 2016; pp. 770–778. [Google Scholar] [CrossRef] [Scilit]
  38. Sandler, M.; Howard, A.; Zhu, M.; Zhmoginov, A.; Chen, L.-C. MobileNetV2: Inverted Residuals and Linear Bottlenecks. In Proceedings of the 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition; IEEE: Salt Lake City, UT, USA, 2018; pp. 4510–4520. [Google Scholar] [CrossRef] [Scilit]
  39. Chen, T.; Moreau, T.; Jiang, Z.; Zheng, L.; Yan, E.; Cowan, M.; Shen, H.; Wang, L.; Hu, Y.; Ceze, L.; et al. TVM: An Automated End-to-End Optimizing Compiler for Deep Learning. In Proceedings of the 13th USENIX Symposium on Operating Systems Design and Implementation (OSDI’18), Carlsbad, CA, USA, 8–10 October 2018; pp. 578–594. [Google Scholar] [CrossRef] [Scilit]
  40. Milletari, F.; Navab, N.; Ahmadi, S.-A. V-Net: Fully Convolutional Neural Networks for Volumetric Medical Image Segmentation. In Proceedings of the 2016 Fourth International Conference on 3D Vision (3DV); IEEE: Stanford, CA, USA, 2016; pp. 565–571. [Google Scholar] [CrossRef] [Scilit]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Article Metrics

Citations

Article Access Statistics

Multiple requests from the same IP address are counted as one view.