Skip to Content
InformationInformation
  • Article
  • Open Access

17 May 2026

17 Pages

MultiTask-Fish: A Shared Backbone Multitask Counting Method for Complex Fish School Scenes

,
and
1
Department of Intelligent Information Systems Engineering, Fukuoka Institute of Technology, Fukuoka 811-0295, Japan
2
Institute of Photonics and Communication, National Kaohsiung University of Science and Technology, Kaohsiung City 807618, Taiwan
*
Author to whom correspondence should be addressed.
This article belongs to the Section Artificial Intelligence

Abstract

With the growing demand for intelligent monitoring in land-based aquaculture, rapid and accurate fish counting from visual data has become important for stocking density regulation, feeding management, and production decisions. To address the challenges in above-water fish images, including scale variation, severe occlusion and adhesion, blurred boundaries, and frequent switching between low- and high-density scenes, this study proposes MultiTask-Fish, a shared backbone multitask counting method. The network uses ResNet34 as the backbone and integrates a feature pyramid network and channel attention to learn unified feature representations. It jointly predicts detection heatmaps, foreground masks, separation boundaries, density maps, density gating, and global count regression, allowing the model to combine local localization cues, structural information, and global statistics. Based on existing polygon annotations, heatmap, mask, boundary, and density supervision are automatically generated for integrated multitask training. Experiments on 495 fish images, including 346 training and 149 validation images, showed that the proposed method achieved an MAE of 5.875, an RMSE of 11.839, and an MAPE of 0.152 on the validation set, while reducing the MAE on the high-density subset from 16.717 to 13.895. These results demonstrate its effectiveness for fish counting in complex above-water aquaculture scenes.

1. Introduction

With the continuous growth in global demand for aquatic food products, aquaculture has become increasingly important in the fisheries and food supply system. According to The State of World Fisheries and Aquaculture 2024 released by the FAO [1], the total global production of fisheries and aquaculture reached 223.2 million tonnes in 2022, of which aquatic animal production accounted for 185.4 million tonnes. In the same year, farmed aquatic animal production reached 94.4 million tonnes, accounting for 51% of total aquatic animal production and surpassing capture fisheries for the first time, thereby becoming the primary source of aquatic animal products. This trend indicates that aquaculture is rapidly evolving from a traditionally experience-driven practice toward large-scale, refined, and intelligent management.
In this context, fish quantity monitoring has become a fundamental task for stocking density regulation, feeding management, growth assessment, and production decision-making. Traditional manual counting methods are intuitive, but they usually rely on continuous human labor and are easily affected by fatigue, subjective judgment, and environmental conditions, making them unsuitable for large-scale and continuous monitoring. In recent years, with the development of smart aquaculture, various monitoring technologies have gradually been introduced into aquaculture processes, which can generally be categorized into sensor-based monitoring, vision-based monitoring, acoustic monitoring, and multimodal fusion monitoring [2]. From the perspective of fish quantity measurement, commonly used methods in land-based aquaculture mainly include manual sampling or counting, mechanical fish counting during transfer, hydroacoustic estimation, binocular stereo-vision measurement, and intelligent vision-based counting using two-dimensional images [2,3]. Existing studies have shown that mechanical counting is suitable for fixed operational stages such as grading and transfer, with a high level of automation, but it is difficult to apply to continuous in-pond monitoring [3]. Hydroacoustic methods are non-contact and less dependent on illumination, but they suffer from relatively high equipment cost and limited spatial resolution [4]. Stereo-vision methods can provide both fish number and three-dimensional information such as body length, but they require stricter conditions in terms of equipment, calibration, and maintenance [5]. By contrast, two-dimensional vision-based methods are more flexible to deploy, more cost-effective, and easier to integrate with deep learning, and have therefore become an important technical route for fish behavior analysis, object detection, quantity estimation, and biomass evaluation [6,7].
From the methodological perspective, vision-based counting methods can generally be divided into instance-level approaches and density-based approaches. Instance-level approaches, such as object detection and instance segmentation, aim to identify or segment individual targets and then obtain the count from the number of detected instances. These methods are effective when object boundaries are clear, but their performance often degrades when targets are small, densely distributed, or strongly occluded. Density-based methods, which have been widely studied in crowded-object counting tasks such as crowd counting, regress a spatial density map and obtain the final count by integration. Representative studies such as MCNN and CSRNet have shown that density-map regression is effective for highly congested scenes and can be extended to other dense-object counting problems [8,9]. Similar ideas have also been introduced into fish counting and aquaculture monitoring, where density estimation and attention-based models have been used to address fish overlap, scale variation, and complex backgrounds [6,10]. However, pure density estimation usually provides weak individual-level localization constraints, whereas pure instance-level methods are vulnerable to adhesion and boundary ambiguity. Therefore, a unified framework that combines localization, structural segmentation, density estimation, and global count calibration is meaningful for complex fish school scenes.
The method investigated in this study belongs to vision-based fish monitoring using above-water imaging. Compared with underwater imaging systems, this type of approach is easier to deploy and maintain and can cover a larger observation area [11]. However, it is also more susceptible to water surface reflections, wave disturbances, fish occlusion, scale variation, and severe adhesion in high-density scenes, all of which increase the difficulty of fish detection and counting [7,11]. Figure 1a shows the deployment of an above-water camera in a land-based aquaculture environment, whereas Figure 1b and Figure 1c show typical low-density and high-density fish scenes, respectively. Compared with the low-density scene, where individual fish are relatively clear and distinguishable, the high-density scene is more affected by occlusion, blurred boundaries, target adhesion, and local reflections, which directly reduce the accuracy of fish quantity estimation.
Figure 1. Above-water fish monitoring scenario in land-based aquaculture. (a) Deployment of an above-water camera in a land-based aquaculture environment; (b) Representative low-density fish scene, where individual fish are relatively clear and distinguishable; (c) Representative high-density fish scene, where occlusion, blurred boundaries, target adhesion, and local reflections occur more frequently.
It should be noted that the imaging conditions in land-based aquaculture tanks differ from those in rivers, coastal waters, and offshore aquaculture systems. Open-water environments are generally affected by larger waves, stronger illumination changes, greater water-depth variation, water turbidity, floating objects, and more complex fish distributions. These factors may lead to different visual degradation patterns and counting difficulties. Therefore, the present study focuses specifically on above-water fish counting in land-based aquaculture tanks, where the imaging geometry and monitoring area can be more consistently controlled.
To address these issues, this paper proposes MultiTask-Fish, a shared backbone multitask counting network for complex fish school scenes. The proposed method jointly models detection heatmaps, foreground masks, separation boundaries, density maps, high-/low-density gating, and global count regression within a unified network. Through shared feature representation and multitask collaborative constraints, the model simultaneously acquires local localization capability, regional structural information, and global counting stability, thereby improving the counting accuracy and generalization ability in complex fish school scenes.

2. Method

2.1. Network Architecture

The proposed MultiTask-Fish adopts a shared backbone multitask learning framework, and its overall architecture is illustrated in Figure 2. The input image is first fed into a ResNet34 backbone to extract hierarchical multiscale feature maps, denoted as c2–c5 [12]. These multiscale features are then fused by a Feature Pyramid Network (FPN) through a top-down integration process, which enhances the complementarity between high-level semantic information and low-level spatial details [13]. Based on this, the highest-resolution fused feature generated by the FPN is further passed to a shared refinement module composed of Conv–SE Attention–Conv blocks, so as to strengthen the representation of local fish structures and details in crowded regions, producing the shared refined features [14].
Figure 2. Architecture of the proposed MultiTask-Fish network.
As shown in Figure 2, four pixel-level branches are built upon the shared refined features, including detection heatmap, foreground mask, boundary map, and density map, while two scene-level branches are used for density gating and global count regression. The pixel-level branches provide local localization and regional structural cues, whereas the scene-level branches introduce high-level density judgment and global numerical priors. Through this joint design, the model captures individual-level, region-level, and scene-level information within a single forward pass.
From the overall perspective, MultiTask-Fish follows the basic pipeline of “shared feature extraction–multibranch prediction–count inference.” The backbone and feature fusion modules are responsible for learning unified representations suitable for multitask learning, while different branches constrain the fish counting problem from different perspectives. Specifically, the detection heatmap and boundary branches focus more on local geometric structures, the foreground mask and density branches emphasize regional distribution patterns, and the gating and global count branches further introduce scene-level statistical cues, thereby improving the model’s adaptability to complex fish school scenes.
The main advantage of this architecture lies in the complementary roles of low-level high-resolution features and high-level semantic features. The former are beneficial for fish localization and boundary learning, while the latter are more suitable for scene density judgment and global count modeling. Their integration within a unified framework improves the overall representation ability of the model for complex fish school scenes. Overall, the architecture shown in Figure 2 provides a unified and effective feature basis for the subsequent count calibration and multitask collaborative optimization.

2.2. Working Principles and Roles of Each Module

The shared backbone network is designed to extract hierarchical visual representations. Shallow features preserve richer spatial details and are therefore suitable for describing fish edges, local contours, and positional distributions, whereas deeper features contain stronger semantic information and are more suitable for representing overall density patterns and scene crowding levels. To utilize both types of information simultaneously, an FPN is constructed on top of the multilevel outputs of ResNet34, so that features at different scales can be fused within a unified channel dimension, thereby improving the model’s ability to handle fish with scale variation. Furthermore, an SE attention mechanism is introduced into the shared refinement module to adaptively recalibrate channel responses and emphasize feature channels that contribute more to counting-related tasks.
The detection branch outputs a single-channel heatmap, whose supervision is generated by two-dimensional Gaussian responses centered at the polygon centers of fish instances. The purpose of this branch is not to recover complete instance contours, but to enhance the model’s sensitivity to fish center locations. Therefore, it is more suitable for providing clear individual-level localization cues in low-density scenes. Compared with methods that rely only on region segmentation, the center heatmap is more sensitive to local peaks in adhesion regions, and can alleviate, to some extent, the difficulty of identifying individuals in dense fish schools with blurred contours. In the current implementation, the Gaussian parameter for heatmap supervision is set to 1.8, and the output stride is 4.
The foreground mask branch is used to learn the overall occupied region of fish, and its role is to provide spatial constraints for counting. By predicting the regions where fish are located, the model can suppress background interference in subsequent peak counting and density distribution learning, thereby reducing false responses caused by water reflections, texture noise, or non-fish regions. The boundary branch further focuses on the separation structure between adjacent individuals. Since multiple fish in high-density scenes often appear as connected regions, a foreground mask alone is usually insufficient to provide instance separation information. Therefore, boundary supervision is introduced to strengthen the modeling of local structures in fish contact regions, enabling the network to learn which areas belong to fish interiors and which are more likely to represent boundaries between neighboring individuals. This joint modeling of foreground constraints and boundary constraints helps improve individual separability in crowded scenes.
The density branch outputs a non-negative density map, whose integral corresponds to the total number of fish in the image. Compared with counting fish one by one based on bounding boxes or masks, density estimation is more suitable for handling overlap and occlusion in medium- and high-density regions, because it focuses on the distribution intensity of targets per unit area rather than forcing the recovery of the complete contour of each fish. To ensure physical stability of the output, the density head adopts the softplus activation in the current implementation, so as to avoid negative density values.
The global counting branch concatenates the pooled deep semantic feature and the pooled shared feature, and then regresses a global count value, which provides a global quantity prior for correcting the systematic bias that may arise when relying only on density integration. The gating branch learns, from high-level features, the probability that an input image belongs to a high-density or low-density scene, thereby providing a basis for subsequent count calibration. The six branches are jointly optimized on the shared representation and form a complementary mechanism ranging from local geometry to global statistics.

2.3. Count Calibration Mechanism

To improve counting stability under scenes with different density levels, the proposed method does not directly use the output of a single branch as the final result. Instead, during inference, the density-integrated count and the global count prediction are adaptively fused. Let N d e n s denote the count obtained by integrating the density map, N g l o b denote the output of the global counting branch, and g denote the predicted high-density probability from the gating branch. Then, the calibration coefficient is defined as
α ( g ) = α l o w + ( α h i g h − α l o w ) g
and the final calibrated count is defined as
N c a l = ( 1 − α ( g ) ) N d e n s + α ( g ) N g l o b
where the parameters α l o w and α h i g h were empirically determined based on validation performance. Specifically, α l o w = 0.08 was chosen to keep the calibrated count mainly dependent on density integration in low-density scenes, while α h i g h = 0.38 was used to increase the contribution of the global counting branch in high-density scenes without overwhelming the density-based estimate. This design allows the model to preserve more local structural information from density integration in low-density scenes, while increasing the contribution of the global counting branch in high-density scenes, thereby improving the overall counting stability in crowded scenarios.
From the perspective of design motivation, fish individuals are relatively clear in low-density images, and the density map itself can often reflect the target distribution reasonably well. In contrast, in high-density images, severe occlusion and adhesion introduce greater uncertainty into the local density distribution. Under such conditions, incorporating a global count prior helps reduce systematic underestimation or overestimation. Therefore, by using the gating branch to control the fusion strength, the model can adaptively adjust its counting strategy according to the scene density characteristics. In the current implementation, the final output is directly taken as the calibrated count N c a l , without any additional post-fusion operation.

2.4. Loss Function Definition

To achieve collaborative multitask learning, the overall loss is defined as
L t o t a l = λ d e n L d e n + λ c n t L c n t + λ g l o b L g l o b + λ c a l L c a l + λ d e t L d e t + λ m a s k L m a s k + λ b n d L b n d + λ g a t e L g a t e
where L d e n denotes the density map regression loss, L c n t denotes the density-integrated count loss, L g l o b denotes the global count regression loss, L c a l denotes the calibrated count loss, L d e t denotes the detection heatmap loss, L m a s k denotes the foreground mask loss, L b n d denotes the boundary branch loss, and L g a t e denotes the gating classification loss. The loss weights were empirically determined through preliminary experiments and validation performance. Specifically, the density regression loss was treated as the primary task and used as the reference weight. The detection heatmap and foreground mask losses were assigned relatively higher weights because they provide strong individual localization and spatial constraints. The global count and calibrated count losses were given moderate weights to introduce scene-level numerical priors and direct supervision on the final output. In contrast, the boundary and gating losses were assigned relatively smaller weights, as they mainly serve as auxiliary constraints and overly large weights may interfere with the optimization of the main counting objective. The final settings were selected to balance overall counting accuracy and robustness in high-density scenes. In the current implementation, the corresponding weights are set to λ d e n = 1.0 , λ c n t = 0.10 , λ g l o b = 0.25 , λ c a l = 0.20 , λ d e t = 1.40 , λ m a s k = 1.0 , λ b n d = 0.15 , and λ g a t e = 0.3 .
The density-related losses are defined as
L d e n = S m o o t h L 1 ( D p r e d , D g t ) ,
L c n t = S m o o t h L 1 ∑ D p r e d , N g t ,
L g l o b = S m o o t h L 1 ( N g l o b , N g t ) ,
L c a l = S m o o t h L 1 ( N c a l , N g t ) .
Both pixel-level density supervision and count-level supervision are retained because they focus on different aspects of the task. Specifically, L d e n constrains the spatial shape of the density distribution, so that the prediction is locally consistent with the ground-truth distribution; L c n t directly constrains the integrated density value, preventing the network from learning density maps with similar spatial patterns but inaccurate total counts; L g l o b enables the global counting head to learn an independent regression prior for complex scenes; and L c a l further constrains the final calibrated count, so that the fused output can be directly optimized toward the ground-truth count. In the current implementation, all four losses adopt the Smooth L1 form, because it provides fine fitting when the error is small and is more stable than the L2 loss when the error is large, making it less sensitive to extreme samples.
The loss for the detection branch is defined as
L d e t = F o c a l B C E ( H p r e d , H g t ) .
Focal BCE is adopted instead of standard BCE because heatmap supervision is characterized by sparse foreground responses and a dominant background [15]. If all pixels are treated equally, the background region will dominate the gradient update, making it difficult for the model to learn the relatively few center peaks. By down-weighting easy samples and emphasizing hard foreground regions, Focal BCE encourages the network to focus more on key responses around true fish centers.
The mask and boundary branches both adopt a combined loss of BCE and Dice, defined as
L m a s k = B C E ( M p r e d , M g t ) + D i c e ( M p r e d , M g t ) ,
L b n d = B C E ( B p r e d , B g t ) + D i c e ( B p r e d , B g t ) .
Here, BCE emphasizes pixel-wise classification accuracy, whereas Dice focuses more on the overall overlap between the predicted region and the ground-truth region. Their combination makes it possible to preserve both local discriminative ability and global structural consistency. This is particularly important for the boundary task, because boundary regions occupy only a small portion of the full image. If only BCE is used, the training process is more likely to be affected by class imbalance, whereas Dice provides additional structural constraints for such sparse regions. In the current implementation, the boundary loss for low-density samples is further scaled down to avoid suppressing the learning of the detection heatmap and density branches in sparse scenes.
The gating branch adopts a binary cross-entropy loss, defined as
L g a t e = B C E ( g p r e d , g g t ) .
Its role is not to directly generate the final count, but to learn the probability that the current input belongs to a high-density or low-density scene, thereby determining the contribution strength of the global branch during count calibration. Because high-density and low-density scenes exhibit substantially different counting patterns, explicitly introducing gating supervision helps improve the model’s ability to distinguish scene-level statistical properties and reduces the interference caused by jointly regressing samples with different distributions.
In addition, to enhance the learning ability of the model on extremely crowded samples, a count-based reweighting strategy is introduced during training. When the ground-truth count exceeds the threshold T = 120 , the sampling probability and loss weight of that sample are increased, with an upper bound of 2.0 . The weighting function is defined as
w ( N ) = m i n 1 + β ⋅ m a x N − T T 0 , w m a x .
During sampling, β = 0.8 is used, whereas during loss weighting, β = 0.6 is adopted, and w m a x = 2.0 . The motivation behind this design is that fish counting datasets are usually dominated by low- and medium-density samples. Without reweighting, the model tends to bias toward these more prevalent and easier samples, which weakens its fitting ability on extremely crowded scenes.

2.5. Image Acquisition Setting and Dataset Construction

The images used in this study were acquired from land-based aquaculture tanks using an above-water camera. The camera was installed above the water surface and was not submerged. Therefore, the applicable depth in this study refers to the water depth of the photographed tanks rather than the operating depth of an underwater camera. The target water depth range was approximately 0.5–2.0 m, which corresponds to the typical tank depth range considered in this land-based aquaculture setting. This imaging configuration was designed for above-water monitoring of fish groups in tanks rather than for underwater, river, or offshore imaging.
The dataset used in this study consists of three parts: images, YOLO polygon annotation files, and density map files. During data loading, the program matches each “.jpg” image, “.txt” polygon annotation file, and “.h5” density map file according to the same filename. A sample is included in the training or validation set only when all three files are present. For each image, the total number of fish is directly determined by the number of polygon instances, which is further used to generate the count label and the gating label. In the current implementation, a sample is labeled as high-density when the ground-truth count is no less than 32; otherwise, it is labeled as low-density.
For supervision construction, the proposed method does not rely on additional manual annotations, but instead automatically derives multitask labels from the existing polygon annotations. Specifically, the detection heatmap is generated from the geometric center of each polygon and represented as a two-dimensional Gaussian response at the output resolution; the foreground mask is obtained by rasterizing all polygons; the instance boundary is constructed from the morphological gradient of each individual instance mask together with the overlapping regions produced by dilation between adjacent instances; and the density map is read from the “.h5” file and resized to the network output resolution while preserving the total count through integral conservation. This design allows a single set of raw annotations to simultaneously support four types of supervision, namely detection, mask, boundary, and density estimation, thereby reducing the additional annotation cost of multitask learning.
In terms of data preprocessing, all input images are uniformly resized to 768 × 1152, and the network output stride is set to 4. Before being fed into the network, images are converted to RGB format and normalized. During training, random horizontal flipping is adopted as a data augmentation strategy to improve the robustness of the model to pose variations and left-right appearance differences. The dataset used in this study contains 495 images in total, including 346 training images and 149 validation images.

2.6. Evaluation Metrics

The performance of the proposed method is evaluated using MAE (Mean Absolute Error), RMSE (Root Mean Squared Error), MAPE (Mean Absolute Percentage Error), and signed mean. Specifically, MAE measures the mean absolute difference between the predicted count and the ground-truth count, RMSE places greater emphasis on samples with large errors, MAPE reflects the relative error level, and signed mean is used to indicate the overall tendency of the model to overestimate or underestimate the fish count. Since the output of the proposed method is a continuous real-valued count, the exact rate is not adopted as a primary evaluation metric.

3. Experimental Results

3.1. Overall Counting Performance Comparison

Before presenting the quantitative comparison, representative examples from the validation set are shown in Figure 3 to illustrate the diversity of above-water fish monitoring scenes. As shown in Figure 3a, the high-density samples contain severe occlusion, adhesion, local reflection, and blurred boundaries, whereas the low-density samples in Figure 3b show clearer individual fish and more distinguishable contours. These examples indicate that the validation set covers both crowded and relatively sparse aquaculture scenes, providing a meaningful basis for evaluating model robustness. The final version of MultiTask-Fish was compared in a unified manner with the YOLO-seg baseline and the Mask R-CNN baseline used in the project [16]. The validation set contains 149 images with a total of 5935 fish, and the overall results are summarized in Table 1.
Figure 3. Representative validation images under different fish school densities and above-water imaging conditions. (a) High-density fish school examples are shown in the top row; (b) low-density fish school examples are shown in the bottom row. These examples illustrate the density variation and visual complexity of the validation set, including occlusion, adhesion, local reflection, and blurred boundaries.
Table 1. Counting results of different models on the validation set. Bold indicates the best result for each metric; for signed mean, the value closest to zero is preferred.
As shown in Table 1, MultiTask-Fish achieves the best performance on all major evaluation metrics. Specifically, its MAE is 5.875, which is 12.02% lower than that of YOLO-seg. Its RMSE is 11.839, which is also lower than the 12.231 obtained by YOLO-seg, indicating that the proposed method not only reduces the average counting error but also exhibits better stability when handling samples with large errors. At the same time, the MAPE is reduced from 0.174 to 0.152, suggesting that MultiTask-Fish also performs better in controlling relative counting errors across samples with different count magnitudes.
From the perspective of the signed mean, YOLO-seg yields a value of 3.604, indicating a tendency toward systematic overestimation, whereas MultiTask-Fish achieves a signed mean of −1.549, which is closer to zero and suggests a smaller overall prediction bias. In contrast, Mask R-CNN produces a signed mean of −35.221, indicating severe systematic underestimation on this dataset. Overall, MultiTask-Fish not only reduces the absolute counting error but also improves the global calibration behavior of the model to a certain extent.
Mask R-CNN performs substantially worse than the other two methods, with an MAE of 35.221 and an RMSE of 53.525. This result suggests that a general-purpose instance segmentation framework cannot be directly adapted to dense fish counting in complex fish school scenes. When severe occlusion, adhesion, and blurred boundaries occur among fish individuals, an instance-level recovery strategy is prone to merged instances, missed detections, or segmentation failures, which leads to rapid accumulation of counting errors. Overall, the results in Table 1 verify the effectiveness of the proposed shared backbone multitask learning strategy for complex fish counting scenarios.

3.2. Analysis on Low-Density and High-Density Subsets

To further evaluate the adaptability of the model under different density conditions, the validation set was divided into high-density and low-density subsets using a threshold of 32 fish per image, and the results were compared with the YOLO-seg baseline. The high-density subset contains 46 images with a total of 4453 fish, while the low-density subset contains 103 images with a total of 1482 fish. The results are shown in Table 2.
Table 2. MAE comparison on the high-density and low-density subsets.
As shown in Table 2, the major performance gain of MultiTask-Fish mainly comes from high-density scenes. On the high-density subset, the MAE is reduced from 16.717 for YOLO-seg to 13.895, corresponding to an improvement of 16.88%. This result indicates that when a scene contains a large number of fish with severe occlusion and adhesion, methods that rely purely on instance-level segmentation and object-by-object counting are more likely to suffer from missed counts and merged predictions, whereas MultiTask-Fish can recover the overall quantity more stably by introducing density modeling, boundary constraints, and global count calibration.
In contrast, on the low-density subset, YOLO-seg achieves an MAE of 2.194, which is slightly better than the 2.294 obtained by MultiTask-Fish. This suggests that in scenes where fish contours are clear and individual fish are more distinguishable, direct instance-level segmentation and counting still maintain a certain advantage. This is because, under low-density conditions, fish are more separated from one another, making it easier for detection or segmentation models to recover individual instances, while the advantage of density estimation and global calibration has not yet been fully reflected.
To more intuitively illustrate the performance differences among the models under different scene densities, Figure 4 further presents the MAE and RMSE comparisons on the high-density and low-density subsets of the validation set. It can be observed that MultiTask-Fish not only achieves a lower MAE on the high-density subset, but also shows a clear advantage in RMSE, indicating that it is more effective in suppressing large-error cases in crowded scenes. In contrast, on the low-density subset, the difference between MultiTask-Fish and YOLO-seg is relatively small, while both are substantially better than Mask R-CNN. This is consistent with the statistics shown in Table 2 and further demonstrates that the main advantage of the proposed method lies in improving counting robustness under high-density, heavily occluded, and strongly adhesive fish school conditions.
Figure 4. MAE and RMSE comparison of different models on the low-density and high-density subsets of the validation set.
Taken together, Table 1 and Table 2, and Figure 4 show that the main advantage of MultiTask-Fish is reflected in high-density and heavily occluded scenes, whereas its performance remains comparable to YOLO-seg in low-density scenes. A broader interpretation of this observation is provided in Section 4.

3.3. Error Distribution and Practical Performance Analysis

To further interpret the practical performance differences among the models, an error distribution analysis was conducted based on the per-image absolute counting errors. Three complementary indicators were used: win rate, median absolute error (Median AE), and the 90th percentile absolute error (P90 AE). The win rate was defined as the proportion of validation images for which a given model achieved the lowest absolute counting error among the compared methods. Median AE reflects the typical error level, whereas P90 AE indicates the magnitude of large-error cases. The results are summarized in Table 3.
Table 3. Compact error distribution comparison of different models on the validation set and density subsets. Values are reported as win rate/Median AE/P90 AE.
On the overall validation set, MultiTask-Fish achieved the highest win rate of 50.34%, slightly higher than YOLO-seg at 48.99%. Although YOLO-seg obtained a lower Median AE, MultiTask-Fish showed a lower P90 AE, decreasing from 18.20 to 13.20. This indicates that the advantage of MultiTask-Fish is mainly reflected in better suppression of large-error cases rather than uniformly reducing the error for every validation image.
In the low-density subset, YOLO-seg achieved a slightly higher win rate, whereas MultiTask-Fish obtained a slightly lower Median AE and P90 AE. This suggests that the two methods showed comparable performance in low-density scenes, where fish individuals are relatively clear and separable. In contrast, MultiTask-Fish showed a clearer advantage in the high-density subset. Its win rate reached 60.87%, compared with 39.13% for YOLO-seg, and its Median AE was reduced from 15.00 to 8.90. These results indicate that MultiTask-Fish provides more stable practical performance in crowded scenes with severe occlusion and adhesion.
Mask R-CNN showed much larger errors across all subsets. In the high-density subset, its win rate was 0.00%, with a Median AE of 81.00 and a P90 AE of 121.00, indicating that it is not well suited for complex above-water fish counting under dense and adhesive conditions. Overall, this error distribution analysis further supports the conclusion that MultiTask-Fish provides its clearest practical advantage in high-density scenes while maintaining comparable performance to YOLO-seg in low-density scenes.

3.4. Qualitative Analysis on Representative Samples

To further analyze the differences among the models on representative scenes, qualitative comparisons on typical high-density samples are presented in Figure 5. As shown in Figure 5a, for a high-density sample with a ground-truth count of 84, YOLO-seg predicts 109.0, resulting in obvious overestimation, while Mask R-CNN predicts only 3.0, indicating an almost complete failure in recovering valid instances. In contrast, MultiTask-Fish predicts 88.4, which is much closer to the ground truth. As shown in Figure 5b, for another high-density sample with a ground-truth count of 98, YOLO-seg predicts 139.0, Mask R-CNN predicts 2.0, and MultiTask-Fish predicts 123.0. Although the prediction of MultiTask-Fish still exhibits some overestimation, its deviation is still much smaller than those of the other two baselines.
Figure 5. Qualitative comparison of different models in representative high-density scenes. The colored boxes or masks in YOLO-seg and Mask R-CNN indicate predicted fish instances, with different colors used only for visualization. The colored overlay in MultiTask-Fish represents the predicted fish-related response region for density-based counting. (a) High-density sample 1; (b) High-density sample 2.
The qualitative results show that YOLO-seg is easily affected by fish adhesion, scale variation, and local occlusion in high-density scenes, leading to repeated counting or excessive segmentation, whereas Mask R-CNN often fails to recover valid instances in complex fish school images and therefore produces severe undercounting. In contrast, MultiTask-Fish does not rely solely on instance-level recovery. Instead, it jointly models heatmap, boundary, density, and global count information on shared features, which enables it to provide a more stable estimate of the overall quantity in severely crowded regions. Therefore, the qualitative results in Figure 5 support the quantitative findings that MultiTask-Fish is more robust than the instance-level baselines in high-density scenes with severe occlusion and adhesion.

4. Discussion

4.1. Advantages in Relation to Previous Vision-Based Counting Methods

The quantitative and qualitative results indicate that the main value of MultiTask-Fish lies not only in reducing the overall counting error, but also in providing a unified framework for complex fish school counting. Previous studies on automatic fish counting have shown that different counting strategies are suitable for different visual conditions. Instance-level methods, including object detection and instance segmentation, are generally effective when individual fish are clearly visible and separable, because the count can be obtained directly from detected or segmented instances [2,7,16]. However, in crowded aquaculture scenes, fish bodies often overlap or adhere to each other, and the visible boundaries between individuals become ambiguous. Under such conditions, pure instance-level recovery becomes unstable and may lead to missed detections, merged instances, or repeated counting.
Density-based methods provide an alternative strategy by estimating the spatial distribution of targets rather than explicitly recovering every individual. This idea has been widely used in crowded-object counting. For example, MCNN introduced a density-map regression framework for crowd counting under different densities and perspectives, while CSRNet used dilated convolution to improve counting performance in highly congested scenes [8,9]. Similar density-based ideas have also been applied to aquaculture, where attention or transformer-based models have been explored for fish density estimation and counting in complex breeding environments [6,10]. These studies support the usefulness of density estimation when individual targets are difficult to separate. However, density-based methods usually provide weaker individual-level localization cues and may be less effective when the scene is sparse and individual fish are clearly distinguishable.
The results of this study are consistent with these previous findings. YOLO-seg remained competitive in low-density scenes, where individual fish contours were relatively clear, whereas MultiTask-Fish showed its clearest practical advantage in high-density scenes with severe adhesion and occlusion. This indicates that neither pure instance segmentation nor pure density estimation alone is sufficient for all density conditions. The proposed method addresses this limitation by integrating detection heatmaps, foreground masks, boundary maps, density maps, density gating, and global count regression within a shared backbone framework. In this design, the heatmap and boundary branches provide individual-level and structural priors, the mask and density branches model regional distribution, and the gating and global count branches introduce scene-level numerical constraints. Therefore, the improved robustness of MultiTask-Fish in high-density scenes can be interpreted as the result of multitask collaboration rather than the effect of a single counting strategy.
Compared with previous methods that mainly emphasize either instance recovery or density regression, MultiTask-Fish provides a more balanced formulation for above-water fish counting in land-based aquaculture. The framework is especially suitable for scenes in which the visual condition changes between sparse and crowded distributions. Nevertheless, its applicability to broader aquaculture environments still requires further validation, particularly across different tanks, fish species, camera positions, illumination conditions, and water-surface characteristics.

4.2. Challenges and Limitations

Although MultiTask-Fish achieved improved overall performance, several challenges remain. First, the current dataset is still limited in scale and imaging diversity. The experiments were mainly conducted using images collected from land-based aquaculture tanks, and the model has not yet been systematically evaluated across different tanks, camera positions, illumination conditions, imaging devices, fish species, or aquaculture environments. Therefore, although the proposed framework has the potential to be extended to broader aquaculture monitoring scenarios, its cross-scene generalization ability still requires further validation. This limitation is important because previous studies have shown that visual aquaculture monitoring models can be sensitive to imaging geometry, water conditions, species appearance, and background complexity [7,11]. Similarly, density-map-based counting models developed for crowded scenes may perform well within a specific dataset but still require adaptation when the object scale, camera perspective, or environmental distribution changes [8,9]. Therefore, the present results should be interpreted as evidence of the effectiveness of the proposed framework under the above-water land-based tank setting, rather than as proof of universal applicability across all aquaculture scenarios.
Second, the current study focuses on above-water imaging in land-based aquaculture tanks with a target water depth of approximately 0.5–2.0 m. The proposed method has not yet been validated in rivers, coastal waters, or offshore aquaculture systems. Compared with land-based tanks, open-water environments usually involve larger waves, greater water-depth variation, stronger illumination changes, different turbidity conditions, floating objects, and more complex fish distributions. These factors may introduce visual degradation patterns that differ from those considered in this study. Therefore, when applying the method to sea-surface or river-based aquaculture scenarios, the image processing pipeline and model adaptation strategy may need to be modified.
Third, the low-density subset results show that MultiTask-Fish does not consistently outperform YOLO-seg. This suggests that instance-level cues still have strong advantages when fish contours are clear and individuals are well separated. In such scenes, direct segmentation and object-level counting can remain highly competitive. Therefore, the exploitation of individual peak information in low-density scenes can still be improved, for example, by strengthening heatmap peak localization or introducing a more explicit low-density instance refinement strategy.
Fourth, the model may still exhibit noticeable underestimation or overestimation in extremely crowded samples. This indicates that the current density map and global count calibration mechanism may still be insufficient when fish bodies are severely overlapped and local visual cues become highly ambiguous. Such cases remain challenging because the visible image evidence may no longer be enough to clearly separate individuals, even with boundary and density supervision.

4.3. Future Perspectives

Future work will focus on improving both generalization and deployability. From the perspective of data generalization, a larger and more diverse dataset should be constructed by collecting images from different tanks, camera heights, illumination conditions, fish species, and aquaculture facilities. In addition to increasing dataset size, external validation across independent farms or aquaculture systems should be conducted to evaluate whether the model can maintain stable performance under unseen imaging conditions. Cross-domain evaluation and domain adaptation will also be important for clarifying how much of the learned representation can be transferred from the current land-based tank setting to other aquaculture environments.
From the perspective of model improvement, higher-resolution decoding structures and local density refinement modules may be introduced to improve the recovery of fine-grained density distributions in extremely crowded regions. In addition, curriculum learning or hard-sample mining strategies could be used to increase the model’s sensitivity to difficult samples, especially those with severe adhesion, strong reflection, or abnormal fish distribution. For low-density scenes, a more explicit peak-based refinement mechanism may further improve individual-level counting accuracy.
From the perspective of practical deployment, lightweight model design and knowledge distillation will be important directions. Land-based aquaculture facilities often require low-cost and stable monitoring systems, and lightweight versions of MultiTask-Fish could help reduce computational cost while maintaining acceptable counting accuracy. In the long term, the proposed framework may be extended from fish counting to broader intelligent aquaculture applications, such as biomass estimation, growth monitoring, feeding decision support, and abnormal behavior detection. These extensions would further enhance the practical value of above-water vision-based monitoring systems in smart aquaculture.

5. Conclusions

This study proposed MultiTask-Fish, a shared backbone multitask fish counting method for above-water monitoring in land-based aquaculture. The method was designed to address common challenges in complex fish school images, including scale variation, severe occlusion and adhesion, blurred boundaries, and large differences between low-density and high-density scenes. By integrating detection heatmaps, foreground masks, boundary maps, density maps, density gating, and global count regression within a unified ResNet34-FPN framework, the proposed model combines individual-level localization cues, region-level structural information, and scene-level global counting priors.
Experimental results demonstrated that MultiTask-Fish achieved an MAE of 5.875, an RMSE of 11.839, and an MAPE of 0.152 on the validation set, outperforming the YOLO-seg and Mask R-CNN baselines overall. The improvement was particularly evident in high-density scenes, where the MAE was reduced from 16.717 for YOLO-seg to 13.895. The error distribution analysis further showed that MultiTask-Fish achieved a higher win rate and lower median absolute error in the high-density subset, indicating better practical robustness under crowded and highly occluded conditions.
Overall, the results suggest that unified multitask collaboration is a promising strategy for fish counting in complex above-water aquaculture scenes. Compared with pure instance segmentation or pure density estimation, the proposed framework provides a more balanced solution by combining local localization, structural separation, density distribution, and global count calibration. Future work will focus on improving cross-scene generalization, extending validation to more diverse aquaculture environments, and developing lightweight models for practical deployment in intelligent aquaculture monitoring systems.

Author Contributions

Conceptualization, S.W., J.-W.W. and C.L.; methodology, S.W.; software, S.W.; validation, S.W. and C.L.; formal analysis, S.W.; investigation, S.W.; data curation, S.W.; writing—original draft preparation, S.W.; writing—review and editing, S.W. and C.L.; visualization, S.W.; supervision, C.L. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Institutional Review Board Statement

Ethical review is not required for this study, as confirmed by the Comprehensive Research Organization of Fukuoka Institute of Technology. The research involved only non-invasive, non-contact image acquisition of fish with no harm to animals, which was in line with the institution’s rules.

Data Availability Statement

The data, code, and training configurations supporting the findings of this study are available from the corresponding author upon reasonable request. Public sharing is restricted due to confidentiality obligations arising from a collaborative agreement.

Acknowledgments

The authors gratefully acknowledge Marinetech Co., Ltd. for providing the experimental site and for their assistance throughout the experiments. The authors also thank Marinetech Co., Ltd. for granting permission to use the image data for research and publication purposes. Their support was essential for conducting the image data collection in the aquaculture environment.

Conflicts of Interest

The authors declare no conflict of interest.

Abbreviations

The following abbreviations are used in this manuscript:
MAEMean Absolute Error
RMSERoot Mean Square Error
MAPEMean Absolute Percentage Error
FPNFeature Pyramid Network
SESqueeze-and-Excitation
BCEBinary Cross Entropy
Median AEMedian Absolute Error
P90 AE90th Percentile Absolute Error

References

  1. FAO. The State of World Fisheries and Aquaculture 2024. Blue Transformation in Action; The State of World Fisheries and Aquaculture (SOFIA); FAO: Rome, Italy, 2024. [Google Scholar]
  2. Li, D.; Miao, Z.; Peng, F.; Wang, L.; Hao, Y.; Wang, Z.; Chen, T.; Li, H.; Zheng, Y. Automatic Counting Methods in Aquaculture: A Review. J. World Aquac. Soc. 2021, 52, 269–283. [Google Scholar] [CrossRef] [Scilit]
  3. Qian, L.; Yu, G.; Liu, H.; He, J.; He, Z. Aquaculture Fish Counting and Mass Estimation Method via Vibration Signal Processing. Aquac. Eng. 2025, 108, 102478. [Google Scholar] [CrossRef] [Scilit]
  4. Orduna, C.; Encina, L.; Rodríguez-Ruiz, A.; Rodríguez-Sánchez, V. Hydroacoustics for Density and Biomass Estimations in Aquaculture Ponds. Aquaculture 2021, 545, 737240. [Google Scholar] [CrossRef] [Scilit]
  5. Shafait, F.; Harvey, E.S.; Shortis, M.R.; Mian, A.; Ravanbakhsh, M.; Seager, J.W.; Culverhouse, P.F.; Cline, D.E.; Edgington, D.R. Towards Automating Underwater Measurement of Fish Length: A Comparison of Semi-Automatic and Manual Stereo–Video Measurements. ICES J. Mar. Sci. 2017, 74, 1690–1701. [Google Scholar] [CrossRef] [Scilit]
  6. Yu, X.; Wang, Y.; An, D.; Wei, Y. Counting Method for Cultured Fishes Based on Multi-Modules and Attention Mechanism. Aquac. Eng. 2022, 96, 102215. [Google Scholar] [CrossRef] [Scilit]
  7. Al-Abri, S.; Keshvari, S.; Al-Rashdi, K.; Al-Hmouz, R.; Bourdoucen, H. Computer Vision Based Approaches for Fish Monitoring Systems: A Comprehensive Study. Artif. Intell. Rev. 2025, 58, 185. [Google Scholar] [CrossRef] [Scilit]
  8. Zhang, Y.; Zhou, D.; Chen, S.; Gao, S.; Ma, Y. Single-Image Crowd Counting via Multi-Column Convolutional Neural Network. In Proceedings of the 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR); IEEE: Las Vegas, NV, USA, 2016; pp. 589–597. [Google Scholar]
  9. Li, Y.; Zhang, X.; Chen, D. CSRNet: Dilated Convolutional Neural Networks for Understanding the Highly Congested Scenes. In Proceedings of the 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition; IEEE: Salt Lake City, UT, USA, 2018; pp. 1091–1100. [Google Scholar]
  10. Zhu, K.; Yang, X.; Yang, C.; Fu, T.; Ma, P.; Hu, W. FCFormer: Fish Density Estimation and Counting in Recirculating Aquaculture System. Front. Mar. Sci. 2024, 11, 1370786. [Google Scholar] [CrossRef] [Scilit]
  11. Li, G.; Yao, Z.; Hu, Y.; Lian, A.; Yuan, T.; Pang, G.; Huang, X. Deep Learning-Based Fish Detection Using Above-Water Infrared Camera for Deep-Sea Aquaculture: A Comparison Study. Sensors 2024, 24, 2430. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  12. He, K.; Zhang, X.; Ren, S.; Sun, J. Deep Residual Learning for Image Recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR); IEEE: New York, NY, USA, 2016; pp. 770–778. [Google Scholar]
  13. Lin, T.-Y.; Dollar, P.; Girshick, R.; He, K.; Hariharan, B.; Belongie, S. Feature Pyramid Networks for Object Detection. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition; IEEE: New York, NY, USA, 2017; pp. 2117–2125. [Google Scholar]
  14. Hu, J.; Shen, L.; Albanie, S.; Sun, G.; Wu, E. Squeeze-and-Excitation Networks. arXiv 2019, arXiv:1709.01507. [Google Scholar]
  15. Lin, T.-Y.; Goyal, P.; Girshick, R.; He, K.; Dollar, P. Focal Loss for Dense Object Detection. In Proceedings of the IEEE International Conference on Computer Vision (ICCV); IEEE: New York, NY, USA, 2017; pp. 2980–2988. [Google Scholar]
  16. He, K.; Gkioxari, G.; Dollár, P.; Girshick, R. Mask R-CNN. arXiv 2018, arXiv:1703.06870. [Google Scholar]
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.