WMSP-RTDETR: An RT-DETR with Weighted Multi-Scale Fusion and Position-Enhanced Attention for Pig Detection in Crowded Barn Scenes

Accurate pig detection in crowded barns is hindered by frequent body contact, similar appearance, overlapping torso boundaries, and scale variations, which weaken instance separation and bounding-box localisation. In the original Real-Time DEtection Transformer (RT-DETR) architecture, limited interactions between shallow boundary details and deep semantic features, together with insufficient complementary positional modelling in the encoder, may lead to missed, merged, or shifted detections in crowded pig scenes. A detector that strengthens both cross-scale feature interaction and spatial positional representation without excessive parameter growth is therefore needed. This study proposes the Weighted Multi-Scale and Position-Enhanced RT-DETR (WMSP-RTDETR), an RT-DETR-based detector for crowded pig scenes. The Weighted Multi-Scale Context Network (WMSC-Net) uses weighted cross-scale fusion and is designed to transfer shallow boundary cues to semantic features and enhance scale-aware representation. The Positional-Enhanced Mamba-Inspired Linear Attention Encoder (PE-MILA Encoder) employs linear attention, Rotary Position Embedding (RoPE), Locally Enhanced Positional Encoding (LePE), and Convolutional Position Enhancement (CPE), and is designed to enhance global context modelling and spatial localisation with limited parameter growth. Experiments on 8070 farm images show that WMSP-RTDETR reaches 61.1% AP, 95.4% AP50, and 63.6% AP75. Compared with ResNet-50-based RT-DETR (R50-RTDETR), the proposed model improves AP, AP50, and AP75 by 1.6, 0.5, and 2.0 percentage points, respectively. Parameters decline from 42.7 M to 29.1 M, and computational complexity declines from 137.7 to 99.1 giga floating-point operations (GFLOPs), whereas inference speed decreases from 21 to 16 frames per second (FPS). These results suggest improved overall detection and high-IoU localisation accuracy under the evaluated conditions. The proposed detector provides an accuracy-oriented solution for automated pig perception in crowded barn scenes.

Authors

Institutions

Publication Details

Journal
Agriculture
Published
2026-08-14
DOI
https://doi.org/10.3390/agriculture16161745
Primary Topic
Animal Behavior and Welfare Studies
Type
article
Field-Weighted Citation Impact
0.00

Funders

Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

WMSP-RTDETR: An RT-DETR with Weighted Multi-Scale Fusion and Position-Enhanced Attention for Pig Detection in Crowded Barn Scenes

Yifan Chen, Le Yang, Shuai Xu, Hua Yang et al.
Agriculture
Animal Behavior and Welfare Studies
article

WMSP-RTDETR: An RT-DETR with Weighted Multi-Scale Fusion and Position-Enhanced Attention for Pig Detection in Crowded Barn Scenes

Yifan Chen, Le Yang, Shuai Xu, Hua Yang, Wangli Hao, Meng Han, Shicong Li
article en

Abstract

Accurate pig detection in crowded barns is hindered by frequent body contact, similar appearance, overlapping torso boundaries, and scale variations, which weaken instance separation and bounding-box localisation. In the original Real-Time DEtection Transformer (RT-DETR) architecture, limited interactions between shallow boundary details and deep semantic features, together with insufficient complementary positional modelling in the encoder, may lead to missed, merged, or shifted detections in crowded pig scenes. A detector that strengthens both cross-scale feature interaction and spatial positional representation without excessive parameter growth is therefore needed. This study proposes the Weighted Multi-Scale and Position-Enhanced RT-DETR (WMSP-RTDETR), an RT-DETR-based detector for crowded pig scenes. The Weighted Multi-Scale Context Network (WMSC-Net) uses weighted cross-scale fusion and is designed to transfer shallow boundary cues to semantic features and enhance scale-aware representation. The Positional-Enhanced Mamba-Inspired Linear Attention Encoder (PE-MILA Encoder) employs linear attention, Rotary Position Embedding (RoPE), Locally Enhanced Positional Encoding (LePE), and Convolutional Position Enhancement (CPE), and is designed to enhance global context modelling and spatial localisation with limited parameter growth. Experiments on 8070 farm images show that WMSP-RTDETR reaches 61.1% AP, 95.4% AP50, and 63.6% AP75. Compared with ResNet-50-based RT-DETR (R50-RTDETR), the proposed model improves AP, AP50, and AP75 by 1.6, 0.5, and 2.0 percentage points, respectively. Parameters decline from 42.7 M to 29.1 M, and computational complexity declines from 137.7 to 99.1 giga floating-point operations (GFLOPs), whereas inference speed decreases from 21 to 16 frames per second (FPS). These results suggest improved overall detection and high-IoU localisation accuracy under the evaluated conditions. The proposed detector provides an accuracy-oriented solution for automated pig perception in crowded barn scenes.

AgricultureVol. 16(16)
Shanxi Agricultural University (CN), Jinzhong University (CN)
Key Research and Development Program of Zhejiang Province
Openalex Percentile: Top 8%
Animal Behavior and Welfare Studies
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.