# LieTom-RTDETR: A Lightweight Real-Time Tomato Detection System for Plant Factories
## 3 Materials and Methods
### Detailed Improvement Strategies for LiteTom-RTDETR
#### 3.3.3 SVFL Function  
The RTDETR employs the Hungarian matching algorithm to assign positive and negative samples with its original VFL classification function [20]. However, the fixed weighting parameters in VFL struggle to adapt to the dynamic label assignment used in RTDETR, leading to classification ambiguity in dense-object scenarios [35]. The Sliding Loss (SlideLoss) function [26], which dynamically adjusts sample weights based on their quality and distribution characteristics, was applied to address these limitations by enhancing the supervision signals in the boundary regions between positive and negative samples, effectively mitigating class imbalances and sample quality discrepancies in object detection. The adaptive weight variation of the Sliding Loss function, which prioritizes high-quality samples while suppressing noisy and ambiguous samples, is shown in Figure 8, where \(\upmu\) represents the threshold parameters for positive and negative samples. The proposed SVFL function integrates the dynamic sample weighting strategy of the VFL function with the sliding adaptive mechanism of the Sliding Loss function. This synergistic design enhances the adaptability of the model to heterogeneous sample distributions while optimizing convergence efficiency. The SVFL function dynamically adjusts the loss weights based on sample quality, prioritizing high-confidence positive samples while adaptively suppressing ambiguous or low-quality regions. This significantly enhances detection accuracy and robustness in dense-object scenarios. The SVFL function can be formulated given the smoothing factor \(\lambda\) (\(0\leq\lambda\leq 1\)) governing the trade-off between historical weight retention and current information integration, weight decay coefficient \(\beta\), and iteration step \(t\) to obtain the following dynamic updating rule for the positive sample weight parameter \(\alpha_{t}\):  
\[\alpha_{t}=\lambda\cdot\alpha_{t}-1+(1-\lambda)\cdot\frac{1}{N_{pos}}\underset {i\in pos}{\sum}p_{i}^{t} \tag{9}\]  
where \(N_{pos}\) denotes the number of positive samples and \(p_{i}^{t}\) represents the predicted score of the \(i\)-th positive sample at the \(t\)-th iteration. Figure 8: Dynamic weight variation schematic of the Sliding Loss function framework. The update rule for the \(\beta\) of the negative samples is given by  
\[\beta=\beta_{0}\cdot e^{-k\cdot t/T} \tag{10}\]  
where \(\beta_{0}\) denotes the initial value of the weight decay parameter, \(k\) is the decay coefficient controlling the decay rate, and \(T\) indicates the total number of iterations. In each update step, the weights are dynamically adjusted based on the quality of the positive samples and the threshold of the IoU between the predicted bounding box and the ground-truth box for the current positive sample using the following rule:  
\[\gamma_{pos}=\gamma_{base}+\mu\cdot(1-\text{IoU}) \tag{11}\]  
where \(\gamma_{pos}\) denotes the weighting factor for the positive samples; \(\gamma_{base}\) represents the base weight of the positive samples; and \(\mu\) is the scaling factor, which controls the rate at which the IoU influences weight adjustment.