Papers
Topics
Authors
Recent
Search
2000 character limit reached

What's Under the Skin? Estimating Swine Body Condition

Published 4 Jun 2026 in cs.CV | (2606.05611v1)

Abstract: Sow body condition is an important indicator for growers as it has a large impact on lactation performance and piglet survival. However, body condition measures used during production, such as visual scoring and calipers, correlate poorly with underlying tissue composition. Ultrasound scans can provide direct measurements of subcutaneous backfat thickness and loin muscle depth, but their operation is labor intensive and not scalable for production. We present PigFormer, an end-to-end two-stage system that takes raw depth frames from a ceiling-mounted RGB-D camera and predicts subcutaneous backfat thickness, loin muscle depth, and total tissue thickness at the last rib. Stage 1 is a geometric front-end that converts raw depth into a standardized height map via SAM3-to-MaskDINO segmentation distillation, ground-plane removal, and orientation normalization. Stage 2 is a Slice Attention Encoder that treats each height map as a sequence of cross-sectional slices and captures spatial relationships along the full dorsal surface. On a multi-site dataset of 319 sow and gilt instances from two facilities, PigFormer achieves 2.43 mm backfat MAE and 3.87 mm overall MAE. It outperforms strong single-stage ResNet-18 and ViT-small baselines. PigFormer offers a practical path toward continuous, automated, non-contact body condition monitoring in commercial swine production. Code is available at https://github.com/iambashar/Pigformer.

Summary

  • The paper introduces PigFormer, a two-stage RGB-D framework that directly regresses swine tissue metrics from ceiling-mounted imagery.
  • It employs a geometric front-end and transformer-based encoder, achieving MAEs of 2.43 mm for backfat and 5.01 mm for loin muscle depth.
  • The system offers high throughput and cross-site generalization, presenting a scalable alternative to labor-intensive ultrasound assessments.

Automated Swine Body Condition Estimation with PigFormer

Motivation and Background

Assessing sow body condition is critical for optimizing feed management, lactation performance, and piglet survival. Traditional approaches such as visual scoring and caliper-based assessments exhibit low correlation with actual subcutaneous fat and muscle composition as measured by ultrasound, which remains the gold standard. However, ultrasound acquisition is laborious, costly, and requires specialized personnel, limiting its scalability for large-scale, routine monitoring in commercial settings. These constraints highlight the need for an automated, high-throughput, non-contact solution for accurate body condition estimation.

Advances in computer vision have enabled 3D and RGB-D systems to estimate gross body weight and growth in pigs. However, direct estimation of tissue-level metrics such as backfat thickness and loin muscle depth from camera-based sensor data, particularly in an end-to-end and multi-target fashion, had not previously been realized at production-relevant accuracy and throughput.

The PigFormer Architecture

The paper introduces PigFormer, a two-stage, end-to-end system for regressing anatomically-relevant tissue measurementsโ€”backfat thickness, loin muscle depth, and total tissue depth at the rib-siteโ€”from raw ceiling-mounted RGB-D imagery. The system is comprehensively designed to handle geometric and pose variability, maximize spatial context, and support joint multi-target regression.

Stage 1: Geometric Front-End

Raw depth frames are processed to segment the pig, upper body, and ground plane using a distillation pipeline from SAM3 to MaskDINO, operating on depth alone for deployment portability. The pig's ground-relative dorsal profile is extracted and spatially normalized by rotating each map according to heading, ensuring pose invariance and canonical feature alignment. The result is a standardized 96ร—22496 \times 224 dorsal height map per frame.

Figure 1

Figure 1: Pipeline overview for PigFormer, from raw RGB-D input through geometric normalization and segmentation, to height map generation and sequence-based regression.

Stage 2: Slice Attention Encoder

The height map is processed as a sequence of 224 cross-sectional "slice" tokens, each representing the height profile at a longitudinal spine position. A transformer with rotary positional encoding enables global attention across distant segments of the back, essential for capturing anatomical relationships relevant to the regression targets. The encoder employs mean/max dual pooling before a final MLP head jointly regresses all three anatomical measurements. Supervision is via Huber loss on each target with total tissue depth (== backfat ++ loin) included explicitly to enforce target consistency.

Figure 2

Figure 2: Segmentation pipeline using SAM3 and MaskDINO distillation to generate pig, ground, and upper body masks from depth-only input.

Figure 3

Figure 3

Figure 3: RGB-D point cloud of a pig as captured by the ceiling-mounted sensor, before geometric transformation.

Figure 4

Figure 4: Heading normalization via upper-body mask, standardizing left-to-right orientation to eliminate pose ambiguity.

Empirical Evaluation

The dataset comprises 319 instances (from two distinct US research facilities) with 6,705 depth frames, fully annotated with site-matched ultrasound-derived fat and loin measurements under an instance-level split protocol (no animal overlap across splits). Strong baselines include single-stage ResNet-18 and ViT-small models taking raw (preprocessed) depth input, using only zz-score normalization, to establish the independent effects of PigFormerโ€™s geometric front-end.

Results demonstrate PigFormer achieves 2.43 mm MAE for backfat, 5.01 mm for loin, and an overall MAE of 3.87 mm across all three targets, outperforming ResNet-18 and ViT baselines by 22% and 39% in overall MAE, respectively. Notably, PigFormerโ€™s backfat MAE approaches the intra-operator variability of manual ultrasound (1.30 mm), indicating prediction accuracy near the practical limits of measurement repeatability.

Alternative geometric front-endsโ€”a pruned MaskDINO segmenter and a lightweight UNetโ€”achieve comparable accuracy (within 0.08 mm MAE of the original) while improving throughput, with the UNet-based pipeline running in approximately 7 ms/frame on A100, enabling real-time deployment.

Model Analysis and Attention Attribution

Critical ablation and attribution analyses confirm the necessity of spatially structured attention. Classical regression and CNN alternatives on handcrafted or local geometric features drastically underperform, indicating that regional anatomical attention, not global statistics, are required for precise tissue-depth estimation.

Interpretability studies using SmoothGrad-ร—\times-Input highlight that the encoderโ€™s attention is anatomically localizedโ€”fat and loin predictions concentrate on the dorsal regions near the rib and rump, mirroring the zones evaluated by expert ultrasound measurement.

Figure 5

Figure 5: Population-averaged normalized column importance (NCI) demonstrating anatomical localization of model attention along the dorsal axisโ€”rib and rump receive high attribution, disproving reliance on global shape regression.

Figure 6

Figure 6: Per-spine-column importance for one pig; peak attention for loin depth aligns with the last-rib anatomical region, confirming spatial specificity in tissue estimation targets.

Comparison with Conventional Scoring and Generalization

Correlation analysis between ultrasound-based measurements and production-caliber caliper scores reveals only modest agreement (r2=0.56r^2 = 0.56 for backfat, r2=0.44r^2 = 0.44 for loin), reinforcing the discrepancy between traditional scoring tools and direct tissue quantification.

PigFormer demonstrates strong cross-site generalization only when full data diversity is included during training; single-site models fail to extrapolate accurately due to marked differences in animal phenotype and management across sites.

Practical Implications and Future Directions

PigFormer constitutes a practical and rigorous alternative to ultrasound and caliper-based tissue estimation. The architectureโ€”modular and robustโ€”supports deployment in production environments, balancing out-of-distribution robustness (with a detection-based geometric front end) and inference speed as prioritized. The transformer backbone, with attention mechanisms attuned to swine anatomical structure, establishes a template for future extension to related tasks (e.g., multi-site generalization, integration of temporal or behavioral cues, application to other livestock).

Further developments may include large-scale, multi-farm datasets, broader breed and management representation, and benchmarking against continuous measurements in commercial-grade barns. Additionally, extensions to automated longitudinal monitoring and integration with nutrition management platforms could optimize feed efficiency and reproductive outcomes at scale.

Conclusion

The presented study details a fully automated, two-stage RGB-D vision framework for direct regression of continuous swine body composition phenotypes. PigFormer achieves state-of-the-art performance approaching reference-level measurement repeatability, demonstrates controllable trade-offs between robustness and throughput, and localizes prediction attention to anatomically meaningful regions. This advance bridges the gap between direct measurement and scalable monitoring, supporting improved decision-making in commercial swine production.

(2606.05611)

Paper to Video (Beta)

No one has generated a video about this paper yet.

Whiteboard

No one has generated a whiteboard explanation for this paper yet.

Open Problems

We haven't generated a list of open problems mentioned in this paper yet.

Tweets

Sign up for free to view the 1 tweet with 0 likes about this paper.