Semantic Segmentation Algorithm of Animal Husbandry Image Based on an Improved U⁃Net Network

Jia Li, Jinjing Zhang, Fengjiao JiangInternational Journal of Advanced Computer Science and Applications 2025 · DOI

TL;DR

Researchers have developed LCA_Net, an enhanced U-Net architecture designed to tackle the messy reality of animal husbandry imagery. By strategically integrating Transformers for global context, CBAM attention for feature refinement, and ASPP for multi-scale edge detection, the model achieves superior segmentation accuracy (90.19% IoU) across multiple species, outperforming standard benchmarks like DeepLabv3+ and U-Net++.

What Problem Does This Paper Address?

In the controlled world of lab datasets, semantic segmentation is a solved problem. In the "wild" of a farm, it is anything but. Animal husbandry images are plagued by unclear edges (think fur and feathers), fuzzy features, complex backgrounds, and unpredictable lighting—from the glare of high noon to the graininess of infrared night vision.

Traditional convolutional neural networks (CNNs) like the standard U-Net often struggle here because their receptive fields are localized; they "see" the pixels but sometimes miss the "big picture" (global context). Furthermore, the direct skip connections in U-Net can introduce redundant or noisy information from the encoder to the decoder, leading to blurred boundaries. While previous research has targeted specific animals (like sheep or cattle), there is a need for a more versatile, robust architecture that can handle various livestock species in diverse environments.

Methods

The authors propose LCA_Net, which retains the classic symmetric encoder-decoder structure of U-Net but introduces three critical architectural "upgrades":

  1. Local-Global Attention Fusion (LGAF) Module: Located in the bottleneck layer, this module uses a dual-path approach. One path uses standard convolution to capture local texture details, while the other employs a CSWin Transformer (Cross-Window Transformer). This allows the network to simultaneously process fine-grained details and long-range dependencies (global shape), bridging the gap between "what" an object is and "where" its boundaries lie.
  2. CBAM (Convolutional Block Attention Module) in Skip Connections: Instead of simply concatenating features from the encoder to the decoder, the authors insert CBAM. This module applies both channel and spatial attention, effectively "filtering" the information to suppress background noise and highlight the most relevant target features before they reach the decoding stage.
  3. Optimized ASPP (Atrous Spatial Pyramid Pooling) Module: Positioned at the end of the decoder, the ASPP module uses dilated convolutions with varying rates (8, 12, 16). This helps the model recognize targets at different scales and preserves sharp edge details, which are often lost during upsampling.

Datasets

The model was evaluated on four distinct animal husbandry datasets to prove its versatility:

  • Horse Dataset: 327 high-resolution images with professional manual labeling.
  • Pigeon Dataset: 122 images of birds in outdoor environments.
  • Cattle Breeding Dataset: 200 images of cattle in indoor pens.
  • Pig Farm Dataset: 501 images, including challenging night-time and high-contrast lighting scenarios.

All images were resized to 256 × 256 pixels for model input, and data augmentation (rotations, flips, brightness adjustments) was used to improve generalization.

Key Insights and Ideas

  • Synergy over Isolation: The authors emphasize that while Transformers and attention modules aren't new, their synergistic placement is. Using the Transformer specifically at the bottleneck allows it to act on the most compressed, high-level semantic information, while CBAM acts as a gatekeeper for the spatial details flowing through skip connections.
  • Overcoming the "Semantic Gap": Standard U-Nets often suffer from a mismatch between the low-level features of the encoder and high-level features of the decoder. The inclusion of attention mechanisms helps "align" these features, leading to smoother, more accurate masks.
  • Robustness to Lighting: Qualitative results showed that LCA_Net significantly outperformed other models in extreme lighting conditions (night scenes in pig farms), suggesting that global context helps the model "infer" animal shapes even when pixel-level contrast is low.

Key Results

LCA_Net consistently outperformed U-Net, ResUnet, Unet++, DeepLabv3+, and DCSAU_Net across all metrics:

  • Horse Dataset: Achieved a 90.47% IoU and 94.94% Dice score, representing a ~1.8% and ~1.1% improvement over the baseline U-Net, respectively.
  • Pigeon Dataset: Reached a Dice score of 84.62%, notably higher than DeepLabv3+ (77.07%).
  • Ablation Studies: Removing any single component (CSWin, CBAM, or ASPP) led to a performance drop. The CSWin module provided the biggest boost to precision, while the combination of all three yielded the best edge localization.
  • Visual Quality: Segmentation maps showed significantly smoother boundaries and fewer "false positive" pixels in complex backgrounds compared to traditional CNN-only approaches.

Limitations and Future Work

The authors acknowledge a few hurdles remaining:

  • Dataset Scale: While effective, the datasets used are relatively small (hundreds of images). Larger-scale data would be required for true production-grade reliability.
  • Generalization: The model has not yet undergone rigorous cross-dataset testing (e.g., training on horses and testing on zebras) to assess its zero-shot adaptability.
  • Deployment: The current model is computationally heavy due to the Transformer components. The authors' next goal is to develop a lightweight version of LCA_Net suitable for low-power mobile monitoring systems and embedded devices on actual farms.

Summary updated

Abstract

Due to the limitations of unclear edges and fuzzy features in image segmentation tasks, this study proposes an enhanced U⁃Net semantic segmentation network utilizing the local and global fusion attention module in response to the drawbacks of fuzzy features and unclear edges in image segmentation tasks. Firstly, a feature extraction module combining convolution and Transformer is introduced in the bottleneck layer, so that the network can fully simultaneously capture local and global features, and effectively promote the fusion of local and global features. Secondly, the CBAM attention module is added to the skip connections between the encoder and decoder. Finally, the output feature map is processed using the ASPP module to enhance focus on target features and improve segmentation performance. Experiments conducted on four animal husbandry segmentation datasets show that the LCA_Net model proposed in this study achieves an IoU score of 90.19% and a Dice score of 94.83%, compared with U-Net and other mainstream segmentation networks, it has improved. This study offers effective technical support for advancing aquaculture status monitoring and lays a foundation for further development in this field.
BibTeX
@article{li2025semantic,
  author = {Jia Li and Jinjing Zhang and Fengjiao Jiang},
  title = {{Semantic Segmentation Algorithm of Animal Husbandry Image Based on an Improved U⁃Net Network}},
  journal = {International Journal of Advanced Computer Science and Applications},
  year = {2025},
  doi = {10.14569/ijacsa.2025.0161139},
}
Figure