A pen-side device-oriented online self-iterative method for captive animal weight modeling
Patent Information
- Application Number
- CN202610914935.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-24
- Publication Date
- 2026-09-22
- Estimated Expiration
- 2046-06-24
AI Technical Summary
现有体重估测模型的迭代优化,普遍依赖人工进场称重完成样本标注,不仅人工成本高、工作效率低,还易造成动物应激反应,影响正常生长与养殖收益,无法适配规模化养殖场的高频迭代需求
本发明通过出栏环节真实体重真值反向时序回溯打标,实现零人工、无应激的训练样本自动生成,大幅降低了模型迭代成本,完全适配规模化养殖的全流程运行节奏;采用冻结主干网络、仅微调低秩适配分支的轻量化增量微调方法,大幅压缩迭代算力消耗,可在养殖场端侧边缘设备上离线完成全流程迭代,无需云端算力支持,规避养殖核心数据的隐私泄露风险的同时,又不受养殖场偏远区域网络环境限制;本发明还通过独立校验样本集对两个模型进行并行精度校验,仅当新模型精度达标时完成替换,规避了模型迭代退化风险,保障了估测业务连续稳定运行。
Smart Images

Figure CN122473615B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of edge AI model optimization technology, and in particular to an online self-iterative method for a captive animal weight model oriented towards edge devices. Background Technology
[0002] With the rapid development of large-scale, intensive livestock farming, machine vision-based non-contact weight estimation technology for captive animals has become one of the core applications of intelligent and refined management in livestock farming. Existing weight estimation models generally rely on manual weighing and sample labeling for iterative optimization. This is not only costly and inefficient, but also prone to causing stress in animals, affecting normal growth and farming profits, and cannot meet the high-frequency iteration needs of large-scale farms. Some unsupervised iterative solutions use pseudo-labeling technology, but these suffer from low label reliability and are prone to model accuracy degradation. Existing model iterations generally rely on cloud computing power for full parameter retraining, which not only places high demands on the farm's network environment but also poses a privacy risk of uploading core farming data to the cloud, making offline autonomous iteration impossible. Furthermore, existing edge-side iteration solutions lack robust security verification and fallback mechanisms, easily leading to a decrease in model accuracy after iteration, failing to guarantee the continuous and stable operation of farming operations. Summary of the Invention
[0003] The main objective of this invention is to provide an online self-iterative method for a captive animal weight model oriented towards end-side devices. By backtracking the time series of real weight values at the slaughter stage, reliable training labels are generated for historical images. After completing lightweight incremental fine-tuning and accuracy verification of the model on the end-side, the method automatically iterates and replaces the labels. This achieves a captive animal weight estimation model with no human intervention, a fully closed-loop online self-iterative process on the end-side, reducing iteration costs and improving the model's scene adaptation accuracy.
[0004] To achieve the above objectives, this invention provides an online self-iterative method for modeling the weight of captive animals using end-side devices, comprising the following steps: Using edge vision acquisition devices, extract the trunk visual features of the target captive animals that can be stably distinguished during the breeding cycle, generate a unique individual feature ID, and bind the collected valid animal images, corresponding acquisition timestamps, and individual feature IDs. When the target captive animals are weighed at the time of slaughter, the visual features of the animal’s trunk are collected in real time and matched with the stable feature vector corresponding to the pre-stored individual feature ID to obtain the unique individual feature ID of the corresponding animal. At the same time, the true weight value of the weighing equipment is obtained, and a one-to-one correspondence between the individual feature ID and the true weight value is established. Based on the bound weight true value, combined with the pre-built growth pattern model of the target captive animal corresponding to the breed, the time-series backtracking of the full-cycle historical valid images corresponding to each individual feature ID is performed to generate a reliable weight label corresponding to each historical valid image. Using historical valid images with reliable weight labels as incremental training samples, lightweight incremental fine-tuning is performed on the pre-deployed weight estimation model on the edge, freezing the weights of the model backbone network and only fine-tuning the parameters of the low-rank adaptation branch of the network. A validation sample set is constructed based on the true weight of the target captive animals at the time of slaughter. The accuracy of the fine-tuned weight estimation model is validated. After the validation is passed, the pre-deployed weight estimation model on the end side is automatically replaced, completing a single online self-iteration of the model.
[0005] Furthermore, the screening steps for valid animal images include: By using a visual detection model deployed on the edge, target detection is performed on the raw images acquired in real time by the visual acquisition device, and the torso region of captive animals in the images is identified. The integrity of the identified torso region is checked to determine whether the entire torso of the captive animal is within the image acquisition range, and original images with truncated torso regions are discarded. The occlusion degree of the image that has completed the integrity check is checked to determine the proportion of the torso region that is occluded, and the original image with the occlusion ratio exceeding the preset threshold is removed. Images that pass the occlusion level check are then checked for sharpness. Original images with image sharpness below a preset threshold or inability to identify the torso outline are discarded to obtain valid animal images.
[0006] Further, the step of generating a unique individual feature ID and binding the collected valid animal image, the corresponding collection timestamp, and the individual feature ID includes: For the selected valid animal images, a lightweight feature extraction network is used to extract the visual features of the torso region of the captive animals in the images; For the trunk visual features extracted from multiple effective images of the same captive animal within a continuous time period, mean fusion and feature normalization are performed to unify the dimension and distribution benchmark of the feature vector and generate a stable feature vector for the corresponding captive animal. Based on the generated stable feature vector, a unique individual feature ID is assigned to the corresponding captive animal, and a pre-stored mapping relationship between the individual feature ID and the corresponding stable feature vector is established. Each valid animal image and its collection timestamp are associated and bound with the individual feature ID of the captive animal in the corresponding image to complete the identification tagging of a single valid image.
[0007] Furthermore, the steps for establishing a one-to-one correspondence between individual feature IDs and true weight values include: When captive animals pass through the weighing channel to be sold, continuous images of the weighed animals are acquired in real time through the visual acquisition device in the channel, and the visual features of the animal's torso are extracted from each frame of the image. The extracted visual features of the torso are matched with the stable feature vectors corresponding to the pre-stored individual feature IDs to determine the unique individual feature IDs of the weighed animals. The system synchronously acquires the true weight value output by the weighing device, which is synchronized with the time of the weighing image acquisition, and records the corresponding acquisition timestamp. Based on the unidirectional movement sequence of captive animals passing through the weighing channel in the exit channel, and combined with the matching time sequence of individual feature IDs and the collection time sequence of true weight values, a one-to-one binding of individual feature IDs with the corresponding true weight values of animals is completed, generating real weight samples with identity tags.
[0008] Furthermore, before the step of performing time-series backtracking on the full-cycle historical valid images corresponding to each individual feature ID, a step of adapting and correcting the pre-built growth pattern model of the target captive animal's corresponding breed is also included, including: Retrieve the historical slaughter weight of the same breed of captive animals in this farm, as well as the corresponding breeding cycle and feeding conditions data; Based on the retrieved historical data, the pre-built general breed growth pattern model is fitted and corrected, and the growth rhythm parameters of the model are adjusted so that the corrected growth pattern model matches the animal weight gain pattern in the local breeding environment. The revised growth pattern model is stored locally on the edge and used as a baseline model for time-series backtracking calculation of the weight labels corresponding to historical images.
[0009] Furthermore, the step of generating a reliable weight label corresponding to each historically valid image includes: Based on the true weight value bound to the slaughter stage, determine the benchmark weight of the corresponding captive animal at the slaughter time point; Based on the baseline weight at slaughter and the corrected growth pattern model, combined with the time difference between the acquisition timestamp of historical valid images and the slaughter time, the theoretical weight value of captive animals corresponding to the acquisition time of historical valid images is calculated back, and the theoretical weight value is used as the initial weight label. The pose and quality of the historical valid images used to generate the initial weight labels are checked twice to determine whether the trunk pose of the animal in the corresponding image meets the preset weight estimation requirements. If it does not meet the preset weight estimation requirements, the corresponding image and the associated initial weight label are removed. The initial weight labels that pass the secondary verification are classified into trust levels, and the initial weight labels that meet the trust requirements are retained as trustworthy weight labels for association with historical valid images.
[0010] Furthermore, the steps for constructing the training sample set for lightweight incremental fine-tuning include: The historical valid images with reliable weight labels are divided into a subset of training samples, which will be used as the main training dataset for this incremental fine-tuning. The local pre-stored benchmark sample library on the device side is retrieved. The benchmark sample library contains general weight estimation effective samples covering multiple scenarios and environments, which serve as the benchmark performance guarantee dataset for this incremental fine-tuning. The training sample subset is mixed with samples from the benchmark sample library to form the training sample set for this lightweight incremental fine-tuning. The training sample set is used for incremental training of the weight estimation model to be iterated on the edge.
[0011] Furthermore, the steps of performing lightweight incremental fine-tuning on the pre-deployed weight estimation model on the edge, freezing the weights of the model backbone network, and only fine-tuning the parameters of the low-rank adaptation branches of the network include: Lock all weight parameters of the backbone network of the pre-deployed weight estimation model on the edge, and fix all weight parameters of the backbone network without updating them during fine-tuning; Only the trainable parameters of the low-rank adaptation branch in the weight estimation model are made available. The low-rank adaptation branch is a parameterized low-rank adaptation module connected in parallel or in series in the backbone network of the model, and it is the only iterative update object for this incremental fine-tuning. Based on the completed training sample set, incremental training of the model is performed locally on the device, and the parameters of the low-rank adaptation branch are iteratively updated to complete the adaptation of the model to the local captive animal weight estimation scenario. After completing the set training iteration process, a fine-tuned weight estimation model is generated and stored locally on the device for verification.
[0012] Furthermore, the step of constructing a validation sample set based on the true weight of the target captive animals at the time of slaughter includes: From the valid samples with true weight values obtained at the slaughter stage, we screened out independent samples that did not participate in this incremental fine-tuning training. The selected independent samples were uniformly sampled, and the sampled independent samples covered different collection time periods, different animal individuals, and different lighting environments. The independent samples that have been sampled are combined to form a verification sample set, which is used to perform accuracy verification on the fine-tuned weight estimation model.
[0013] Furthermore, the accuracy of the fine-tuned weight estimation model is verified. Upon successful verification, the pre-deployed weight estimation model on the endpoint is automatically replaced, completing the single online self-iteration step of the model, including: Based on the completed verification sample set, the weight estimation accuracy test was performed on the weight estimation model generated in this fine-tuning and the weight estimation model currently pre-deployed and running on the edge. By comparing the estimation errors of the two models on the same validation sample set, it is determined whether the accuracy of the weight estimation model generated in this fine-tuning meets the preset validation pass standard. If the verification passes, the weight estimation model generated in this fine-tuning will automatically replace the pre-deployed weight estimation model on the device side, completing the iterative update of the model parameters. If the verification fails, the model parameters generated in this fine-tuning will be discarded, the weight estimation model that has been pre-deployed and run on the edge before the accuracy test will be retained, and the online self-iterative process will be terminated.
[0014] The online self-iterative method for modeling the weight of captive animals oriented towards end-side devices provided by this invention has the following beneficial effects: This invention achieves automatic generation of training samples with zero manual intervention and no stress by backtracking and labeling the true weight of animals at the slaughter stage, significantly reducing model iteration costs and fully adapting to the entire process of large-scale farming. It employs a lightweight incremental fine-tuning method that freezes the backbone network and only fine-tunes low-rank adaptation branches, greatly reducing iteration computational power consumption. The entire iteration process can be completed offline on edge devices at the farm, without cloud computing support, avoiding the risk of privacy leaks of core farming data while not being limited by the network environment of remote areas of the farm. Furthermore, this invention performs parallel accuracy verification of two models using independent verification sample sets, replacing the model only when the new model's accuracy meets the standard, avoiding the risk of model iteration degradation and ensuring the continuous and stable operation of the estimation business. Attached Figure Description
[0015] Figure 1 This is a flowchart illustrating an online self-iterative method for modeling the weight of captive animals in relation to end-side devices, according to an embodiment of the present invention.
[0016] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0017] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0018] Reference Figure 1This is a flowchart illustrating an online self-iterative method for modeling the weight of captive animals using end-side devices, as proposed in this invention. The method includes the following steps: S1. Through the end-side visual acquisition device, extract the trunk visual features that can be stably distinguished within the breeding cycle of the target captive animal, generate a unique individual feature ID, and bind the acquired valid animal image, the corresponding acquisition timestamp, and the individual feature ID. S2, when the target captive animals are weighed at the time of slaughter, the visual features of the torso of the weighed animals are collected in real time and matched with the stable feature vector corresponding to the pre-stored individual feature ID to obtain the unique individual feature ID of the corresponding weighed animal. The true weight value of the weighing equipment is obtained simultaneously, and a one-to-one correspondence between the individual feature ID and the true weight value is established. S3, based on the bound weight true value, combined with the pre-built growth law model of the target captive animal corresponding to the breed, performs time-series backtracking of the full-cycle historical valid images corresponding to each individual feature ID, and generates a reliable weight label corresponding to each historical valid image. S4 uses historical valid images with reliable weight labels as incremental training samples to perform lightweight incremental fine-tuning on the pre-deployed weight estimation model on the edge, freezes the weights of the model backbone network, and only fine-tunes the parameters of the low-rank adaptation branch of the network. S5 constructs a verification sample set based on the true weight of the target captive animals at the time of slaughter, performs accuracy verification on the fine-tuned weight estimation model, and automatically replaces the pre-deployed weight estimation model on the end side after the verification passes, completing a single online self-iteration of the model.
[0019] As described in step S1 above, visual acquisition devices adapted to the low-light, high-dust environment of the farm, including fixed-point monitoring cameras in the pens and visual acquisition modules mounted on patrol robots, are deployed at the end. The system continuously collects raw images of captive animals for hours. A lightweight visual detection model deployed locally on the device performs a progressive screening of valid animal images. Specifically, it performs object detection on the raw images to accurately identify the torso region of the captive animals. Then, it performs integrity checks on the identified torso regions, discarding images with truncated torso areas. It performs occlusion checks, discarding images where the occlusion percentage exceeds a preset threshold. Finally, it performs sharpness checks, discarding images with sharpness below a preset threshold or where torso outline details cannot be identified. This process ultimately yields valid animal images that meet the requirements for subsequent feature extraction, preventing invalid images from introducing feature extraction errors at the source. For the selected valid animal images, a lightweight feature extraction network extracts the torso visual features that can be stably distinguished throughout the breeding cycle of the target captive animal. These features specifically include the animal's spinal curve, torso length-to-width ratio, distribution of body surface wrinkles, and inherent skin markings—features determined by genes and unaffected by weight gain or posture. This method utilizes stable features influenced by changes in the animal's physical state and the progress of the breeding cycle to avoid the problems of high occlusion rate and unstable features encountered when using facial feature recognition. Furthermore, it extracts torso visual features from multiple valid images of the same captive animal over consecutive time periods, performs mean fusion and feature normalization processing to unify the dimension and distribution benchmark of the feature vectors, generating stable feature vectors for the corresponding captive animals. This eliminates feature deviations caused by changes in animal posture in a single frame, ensuring the stability and uniqueness of features throughout the entire breeding cycle. Based on the generated stable feature vectors, a unique individual feature ID is assigned to the corresponding captive animal, and a pre-stored mapping relationship between the individual feature ID and the corresponding stable feature vector is established simultaneously. Finally, each valid animal image, its corresponding acquisition timestamp, and the individual feature ID corresponding to the captive animal in the image are associated and bound together, achieving identity labeling for each valid image. The entire process is non-invasive, with zero additional breeding costs and no human intervention, fully adaptable to the full-scenario breeding needs of large-scale, intensive farms. Step S1 addresses the core pain points of existing technologies for individual identification of captive animals, which rely on invasive chips, cannot accurately bind to acquired images, and are easily affected by the breeding environment. It establishes a unique and non-invasive identity anchor for subsequent full-cycle individual traceability and accurate binding of true value at slaughter. As described in step S2 above, when the target captive animals pass through the farm's dedicated one-way weighing channel, a visual acquisition device fixedly installed within the channel and synchronized with the weighing equipment acquires continuous images of the animals passing through in one direction in real time. Simultaneously, the torso visual features of the animals in each frame are extracted. These extracted torso visual features are then matched with the stable feature vectors corresponding to the individual feature IDs pre-stored in step S1 to determine the unique individual feature ID of each animal, thus solving the problem of accurate identification of animals during dynamic movement in the weighing scenario. Simultaneously, the weighing equipment, synchronized with the visual acquisition device, acquires images with precise timing of the weighing image acquisition. The system accurately aligns the true weight values of the animals being weighed, records the timestamps corresponding to these true weight values, and then, based on the rule that captive animals can only pass through the weighing channel in a one-way, sequential manner, combines the matching sequence of individual feature IDs with the collection sequence of true weight values to complete a one-to-one binding between individual feature IDs and the corresponding animal's true weight value. This generates a true weight sample with an identity tag, avoiding the mismatch between identity and true weight values that occurs when multiple animals are weighed consecutively. The entire process requires no manual intervention, fully reusing the existing weighing process of large-scale farms, without requiring any additional modifications to the existing farming process. Without increasing farming costs, it provides a zero-cost, highly reliable true value benchmark for model self-iteration. Step S2 achieves precise binding between the individual identity of captive animals and their true weight at slaughter by obtaining true weight anchor points. This differs from the industry's conventional understanding that slaughter weighing data is only used for final model accuracy verification and cannot be used as core data for model iteration.
[0020] As described in step S3 above, based on the true weight value bound in step S2 during the slaughtering stage, the baseline weight of the corresponding captive animal at the slaughtering time is determined. Then, a pre-built growth pattern model for the target captive animal's corresponding breed is used. This growth pattern model is pre-fitted and corrected based on historical slaughtering weight values of the same breed of captive animals in the farm, the corresponding animal's breeding cycle, and feeding conditions. The growth rhythm parameters of the model are adjusted to match the corrected growth pattern model with the animal weight gain pattern under the farm's breeding environment. The corrected model is stored locally on the endpoint as the baseline model for time-series backtracking calculations. Based on the time difference between the acquisition timestamp of the historical valid image and the slaughtering time, combined with the slaughtering baseline weight and the corrected growth pattern model, the acquisition time of the historical valid image is calculated backtrackingly. The theoretical weight values of captive animals are used as initial weight labels. Then, the posture and quality of historical valid images used to generate these initial weight labels are subjected to secondary verification to determine if the animal's torso posture in the corresponding image meets the preset weight estimation requirements. If not, the corresponding image and associated initial weight labels are removed. The initial weight labels that pass the secondary verification are then graded for reliability, and only those that meet the reliability requirements are retained as reliable weight labels associated with the corresponding historical valid images. Ultimately, this achieves zero-cost, high-reliability labeling of historical samples throughout the entire breeding cycle using real weight data from the end of the breeding process, completely bypassing the label acquisition bottleneck of existing technologies and providing high-quality, high-matching training samples for subsequent incremental fine-tuning of the model. Step S3 uses the reliable weight values from the slaughter stage at the end of the breeding process to generate high-reliability weight labels for historical valid images throughout the entire breeding cycle of captive animals. This solves the problems of high manual labeling costs, strong animal stress, low reliability of general pseudo-labels, and easy model degradation caused by existing technologies that rely on model iteration.
[0021] As described in step S4 above, a training sample set for incremental fine-tuning is constructed. The historical valid images with reliable weight labels generated in step S3 are divided into a training sample subset, which serves as the main training dataset for this incremental fine-tuning. Simultaneously, a local benchmark sample library is retrieved. This benchmark sample library contains general weight estimation valid samples covering multiple farming scenarios, lighting environments, and breeds, serving as the benchmark performance guarantee dataset for this incremental fine-tuning. The training sample subset is then mixed with samples from the benchmark sample library to construct the complete training sample set for this lightweight incremental fine-tuning. This sample set is used for incremental training of the pre-deployed weight estimation model to be iterated on the device, ensuring the model's adaptability to the current farming scenario after fine-tuning. Furthermore, the benchmark sample library maintains the model's estimation stability and generalization performance in the original general scenarios, avoiding the loss of historical learning ability and abnormal fluctuations in overall estimation results caused by training only with incremental samples. Lightweight incremental fine-tuning of the model is then performed locally on the device. The system locks all weight parameters of the backbone network of the pre-deployed weight estimation model on the edge, and fixes these parameters without updating them during fine-tuning. Only the trainable parameters of the low-rank adaptation branches in the weight estimation model are made available. These low-rank adaptation branches are parameterized low-rank adaptation modules connected in parallel or series in the model's backbone network, serving as the sole iterative update target for this incremental fine-tuning. The low-rank adaptation structure significantly reduces the number of trainable parameters and computational power consumption, enabling it to adapt to the hardware conditions of the edge computing devices on the farm. Based on the completed training sample set, incremental training of the model is performed locally on the edge, iteratively updating the parameters of the low-rank adaptation branches to adapt the model to the farm's captive animal weight estimation scenario. After completing the set training iteration process, the fine-tuned weight estimation model is generated and stored locally on the edge for verification. The entire fine-tuning process can be executed during the idle time of the edge device's non-fence-patrol estimation business, without occupying the computational resources of the daily weight estimation business or affecting the normal operation of the original system. Step S4 solves the problems in the prior art where model iteration must rely on cloud computing power, full parameter training consumes a lot of computing power, is prone to catastrophic forgetting, and cannot be completed autonomously on the device by completing lightweight incremental fine-tuning of the weight estimation model locally on the device. It realizes model iteration on the device without human intervention and with low computing power consumption.
[0022] As described in step S5 above, a verification sample set is constructed based on the true weight values of the target captive animals at the time of slaughter. From the valid samples with true weight values obtained at the slaughter stage, independent samples that did not participate in this incremental fine-tuning training are selected. These selected independent samples are then uniformly sampled to ensure that the sampled independent samples cover different collection times, different animal individuals, and different lighting environments. The sampled independent samples are then combined to form a verification sample set. This verification sample set is used to perform accuracy verification on the fine-tuned weight estimation model to ensure the independence and scene coverage of the verification samples, avoiding the problem of distorted verification results and false approvals caused by duplication of training and verification samples. Based on the constructed verification sample set, the weight estimation model generated in this fine-tuning and the weight estimation model currently pre-deployed and running on the current edge are respectively... The model is tested by performing a weight estimation accuracy test. The estimation errors of the two models are compared under the same validation sample set to determine whether the accuracy of the weight estimation model generated in this fine-tuning meets the preset validation pass standard. If the validation passes, the weight estimation model generated in this fine-tuning is automatically used to replace the pre-deployed weight estimation model on the client side, completing the iterative update of the model parameters and realizing the autonomous optimization of the model estimation accuracy. If the validation fails, the model parameters generated in this fine-tuning are discarded, the weight estimation model that was pre-deployed and running on the client side before the accuracy test is retained, and the online self-iteration process is terminated. This establishes a rigid safety net for unattended self-iteration on the client side, avoiding business interruption or estimation accuracy reduction caused by model iteration failure, and ensuring that the entire self-iteration process can run long-term, stably, and without human intervention.
[0023] In one embodiment, step S1, the screening step for valid animal images, includes: By using a visual detection model deployed on the edge, target detection is performed on the raw images acquired in real time by the visual acquisition device, and the torso region of captive animals in the images is identified. The integrity of the identified torso region is checked to determine whether the entire torso of the captive animal is within the image acquisition range, and original images with truncated torso regions are discarded. The occlusion degree of the image that has completed the integrity check is checked to determine the proportion of the torso region that is occluded, and the original image with the occlusion ratio exceeding the preset threshold is removed. Images that pass the occlusion level check are then checked for sharpness. Original images with image sharpness below a preset threshold or inability to identify the torso outline are discarded to obtain valid animal images.
[0024] Specifically, to address the issues of high noise levels, high invalid frame rates, and potential distortion in subsequent feature extraction and individual identification caused by the complex environment of large-scale farms, an effective image screening process is implemented using a progressive, edge-executable approach. The entire process is completed locally on the edge using lightweight algorithms, eliminating the need for cloud data transmission and minimizing the consumption of excessive computing resources, thus ensuring screening efficiency. In the specific implementation process, a lightweight visual detection model deployed on the edge performs target detection on the raw images acquired by the visual acquisition device in real time 24 hours a day. This model has been pre-adapted to the low-light, high-dust, and complex background operating environment of the farm, and can quickly and accurately identify the torso region of the captive animals in the raw images. Unlike conventional whole-animal target detection, this step only locks the torso region that is strongly related to weight estimation and individual feature extraction, rather than the head and limb regions that are easily occluded or have large posture fluctuations. This can directly eliminate interference from irrelevant content such as pen background, non-target animals, and debris, and lock the core effective area for subsequent processing. After the torso region is identified, an integrity check is performed on the identified torso region. The core is to determine whether the complete torso structure of the captive animal is entirely within the image acquisition frame. If the torso region is truncated, it will directly affect the subsequent extraction of the torso. Incomplete visual features, deviations in individual feature ID generation, and decreased weight estimation accuracy mean that this step directly removes original images with truncated trunk regions to ensure that all retained images contain the complete trunk structure of captive animals, providing a complete feature carrier for subsequent feature extraction. For images that have passed integrity verification, occlusion verification is further performed. In actual farm scenarios, the trunk region of captive animals is easily occluded by pen railings, feed troughs, water troughs, and other animals in the same pen. Occlusion will cause the loss of core trunk features and distortion of feature extraction, which will lead to failure of individual feature matching and incorrect ID binding. In this embodiment, a lightweight instance segmentation network deployed on the edge is used to identify the complete mask and the visible effective mask of the trunk region. The visible percentage of the trunk region is calculated by dividing the number of pixels in the visible effective mask by the number of pixels in the complete trunk mask, and finally the percentage of the occluded part is obtained.The images are compared with a preset occlusion threshold, and original images with an occlusion percentage exceeding the threshold are removed. This preset occlusion threshold is determined through pre-experimentation: using animal image samples with different occlusion percentages from the farm, feature extraction and weight estimation tests are performed respectively. The maximum occlusion percentage, ensuring the integrity of the core trunk features and that the weight estimation error is within the allowable range, is used as a benchmark. This is flexibly adjusted based on the farm's pen structure and stocking density to ensure that the core trunk feature areas of the retained images are not severely occluded, preventing invalid features from entering subsequent processing. For images that pass the occlusion degree verification, a sharpness verification is finally performed. Animals in captivity within the farm are in a state of continuous movement, making them prone to... Motion blur, along with low light conditions at night, dust adhering to the lens surface, and fogging due to moisture, can also cause a decrease in image sharpness. Blurred images cannot extract stable and distinguishable visual features of the torso, which will directly lead to the failure of individual feature matching in the subsequent slaughtering process. This embodiment uses an image sharpness detection algorithm, such as the Brenner gradient function method on the adapted end side, to perform sharpness detection. It calculates the sum of squares of the gray-level differences between adjacent pixels in the image. The larger the sum of squares of the differences, the sharper the edge contour of the image and the higher the gradient value. Conversely, the smaller the sum of squares, the more blurred the image. A sharpness threshold is set in advance based on the gradient value distribution of sharp and blurry samples. The preset clarity threshold is determined by collecting clear and blurry samples under different lighting and movement conditions in the field, statistically analyzing the lowest gradient value of samples that can stably extract effective trunk features and complete individual identification, and combining this with the hardware parameter calibration of the end-side visual acquisition device. When the gradient calculation value of the image is lower than the preset threshold, it is determined that the image clarity does not meet the standard, and the original image with image clarity lower than the preset threshold and unable to identify trunk outline details is discarded. The final retained image is the effective animal image that meets the requirements of subsequent feature extraction, ID binding, and weight estimation. Through a four-layer progressive screening process, invalid frames in the original image can be efficiently filtered, which greatly improves the efficiency and accuracy of subsequent data processing.
[0025] In one embodiment, step S2, which involves generating a unique individual feature ID and binding the collected valid animal image, the corresponding collection timestamp, and the individual feature ID, includes: For the selected valid animal images, a lightweight feature extraction network is used to extract the visual features of the torso region of the captive animals in the images; For the trunk visual features extracted from multiple effective images of the same captive animal within a continuous time period, mean fusion and feature normalization are performed to unify the dimension and distribution benchmark of the feature vector and generate a stable feature vector for the corresponding captive animal. Based on the generated stable feature vector, a unique individual feature ID is assigned to the corresponding captive animal, and a pre-stored mapping relationship between the individual feature ID and the corresponding stable feature vector is established. Each valid animal image and its collection timestamp are associated and bound with the individual feature ID of the captive animal in the corresponding image to complete the identification tagging of a single valid image.
[0026] Specifically, for valid images that have been screened, a lightweight feature extraction network pre-deployed on the edge is invoked to complete feature calculation. The network structure is adapted to the computing power limit of the edge device, and real-time processing can be completed without cloud computing power support. The target area for feature extraction is locked to the animal trunk, rather than the head, limbs, or other parts that are easily occluded or have large changes in posture. The extracted features focus on the inherent morphological features of the trunk determined by the animal's genes. These features will not change fundamentally with the animal's weight gain or changes in daily activity posture during the breeding cycle, ensuring the long-term distinguishability of the features. For the trunk features extracted from multiple valid images of the same animal within the same continuous time period, a dimensional mean fusion process is performed to obtain the fused initial feature vector. Then, the Z-Score normalization method is used to normalize the initial feature vector, using the mean of each dimension of the feature vector as the benchmark and the standard deviation as the scale to unify the dimensionality and numerical distribution benchmark of the feature vector, offsetting the random fluctuations of features caused by the shooting angle and the animal's instantaneous posture in a single frame image. Then, the fused features are normalized again to unify the dimensionality and numerical distribution range of all feature vectors, eliminating the feature distribution offset caused by different lighting and shooting environments, and finally generating a stable feature vector for the corresponding animal, avoiding the problems of insufficient feature matching and discontinuous identity identification of the same animal at different time periods. Based on the generated stable feature vectors, a unique digital identity is assigned to each animal. Simultaneously, a mapping relationship between the identity and the corresponding stable feature vector is established and stored locally on the device, forming an offline index library of individual identities. Subsequent tracking of individual behavior during daily patrols and identity verification at the slaughter stage can be achieved by comparing the extracted torso features with the vectors in the index library using a cosine similarity algorithm. The closer the cosine similarity value is to 1, the higher the matching degree between the two feature vectors, quickly identifying the corresponding identity without requiring additional intrusive identification devices or relying on the farm's network environment. For each valid image, it is associated and bound with its own collection timestamp and the corresponding animal's unique identity, completing the identity labeling of a single image. All bound data is stored locally on the device, forming an image dataset with complete identity and time information. After obtaining the animal's actual slaughter weight data, all historical images throughout the entire breeding cycle of the animal can be accurately traced back through the identity, and the corresponding weight label can be calculated by combining the collection timestamp, providing traceable and complete data support for incremental training of subsequent models.
[0027] In one embodiment, step S2, the step of establishing a one-to-one correspondence between individual feature IDs and true weight values, includes: When captive animals pass through the weighing channel to be sold, continuous images of the weighed animals are acquired in real time through the visual acquisition device in the channel, and the visual features of the animal's torso are extracted from each frame of the image. The extracted visual features of the torso are matched with the stable feature vectors corresponding to the pre-stored individual feature IDs to determine the unique individual feature IDs of the weighed animals. The system synchronously acquires the true weight value output by the weighing device, which is synchronized with the time of the weighing image acquisition, and records the corresponding acquisition timestamp. Based on the unidirectional movement sequence of captive animals passing through the weighing channel in the exit channel, and combined with the matching time sequence of individual feature IDs and the collection time sequence of true weight values, a one-to-one binding of individual feature IDs with the corresponding true weight values of animals is completed, generating real weight samples with identity tags.
[0028] Specifically, during the process of captive animals being taken out of the market through a dedicated one-way weighing channel, a visual acquisition device, pre-installed within the channel and synchronized with the weighing equipment, acquires continuous images of the animals passing through in real time. Visual features of the animal's torso region are extracted from each frame of the image simultaneously. The rules for feature extraction are completely consistent with the rules for feature extraction collected daily during the breeding cycle, ensuring that the feature system is of the same origin and providing a unified comparison benchmark for subsequent identity matching. Continuous acquisition avoids feature extraction failures caused by occlusion or blurring in single-frame images, improving the fault tolerance rate of identity recognition in the market exit scenario. The process involves extracting torso features from a single frame image. These extracted features are then compared with stable feature vectors corresponding to individual feature IDs generated during the breeding cycle and stored locally on the device. A cosine similarity algorithm is used for comparison. The result with the highest matching degree and a cosine similarity value exceeding a preset matching threshold is the unique individual feature ID corresponding to the animal being weighed. This preset matching threshold is determined through pre-experimentation: statistical analysis of the cosine similarity distribution of features from multiple frames of the same individual in the farm, and the cosine similarity distribution of features from different individuals. In this embodiment, an ROC curve is used to determine the optimal threshold that balances matching accuracy and recall, ensuring that the success rate of matching the same individual and the false matching rate of different individuals both meet the preset requirements. The entire matching process is completed locally on the device, eliminating the need for cloud data transmission and adapting to the unstable network environment in remote areas of the farm. Simultaneously, a time-calibrated weighing device is used to obtain the true weight value precisely aligned with the image acquisition time, and the acquisition timestamp corresponding to this true weight value is recorded synchronously. This time synchronization avoids time misalignment between image acquisition and weight data acquisition during dynamic animal weighing, reducing the risk of mismatch between identity and weight data from the source. Based on the one-way passage rule of the weighing channel for captive animals, which allows them to pass through the weighing area in a single direction and not to turn back, the matching time sequence of individual feature IDs and the collection time sequence of true weight values have a strict positive correspondence. By combining the timestamps of both, double verification is completed, which realizes the accurate one-to-one binding of individual feature IDs and corresponding true weight values of animals, and generates real weight samples with identity tags. This solves the common industry problem of mismatch between identity and weight data in scenarios where multiple animals are weighed continuously.
[0029] In one embodiment, before step S3, which involves time-series backtracking of the full-cycle historical valid images corresponding to each individual feature ID, a step of adapting and correcting the pre-built growth pattern model of the target captive animal's corresponding breed is included, comprising: Retrieve the historical slaughter weight of the same breed of captive animals in this farm, as well as the corresponding breeding cycle and feeding conditions data; Based on the retrieved historical data, the pre-built general breed growth pattern model is fitted and corrected, and the growth rhythm parameters of the model are adjusted so that the corrected growth pattern model matches the animal weight gain pattern in the local breeding environment. The revised growth pattern model is stored locally on the edge and used as a baseline model for time-series backtracking calculation of the weight labels corresponding to historical images.
[0030] Specifically, the system retrieves the true weight values of the same breed of captive animals collected in the past slaughter stages from the historical breeding data stored locally on the device, as well as core breeding data such as the full breeding cycle duration and daily feeding plan of the corresponding batch of animals. These data are all standardized data naturally generated in the daily breeding and slaughtering process of the farm, without the need for additional manual collection or hardware investment. They can be directly used for model correction, while ensuring that the correction data comes entirely from the actual breeding scenario of the farm, rather than the industry-standard large sample average data. Based on the retrieved historical breeding and weight data of this farm, this embodiment uses nonlinear least squares method to perform fitting correction on the pre-built general breed growth law model constructed based on the Gompertz growth curve. This general model is a basic model built on the industry-wide general growth characteristics of the corresponding breed of captive animals, reflecting the animal weight gain law under the industry average. However, there are differences in feeding nutrition levels, pen environment, disease prevention and control levels, and breeds among different farms. Directly using the general model will result in a large deviation between the backtested weight value and the actual animal weight, which cannot meet the label accuracy requirements of model training. Therefore, by using the farm's historical real data for fitting correction, the growth rhythm-related parameters of the model are adjusted in a targeted manner, so that the corrected model can accurately match the animal weight gain law under the farm's breeding environment, thereby improving the credibility of the weight labels generated in subsequent backtesting from the source. The adapted and corrected growth pattern model is stored locally on the device, serving as the sole benchmark model for calculating the weight tags corresponding to valid historical images in subsequent time-series backtracking. This local model storage design ensures that subsequent time-series backtracking calculations can be completed offline on the device, without relying on cloud computing power or network conditions. This adapts to the operating conditions of remote areas of the farm while ensuring that a unified benchmark model is used for backtracking calculations within the same batch, guaranteeing the consistency and comparability of the generated weight tags. This embodiment, by localizing and correcting a pre-built general-variety growth pattern model, provides a benchmark model that fits the actual farming conditions for subsequent time-series backtracking calculations of historical image weight tags, solving the problem of excessive backtracking tag errors caused by the mismatch between the general growth pattern model and the farm's farming environment and feeding conditions.
[0031] In one embodiment, the step of generating a trusted weight label for each historically valid image includes: Based on the true weight value bound to the slaughter stage, determine the benchmark weight of the corresponding captive animal at the slaughter time point; Based on the baseline weight at slaughter and the corrected growth pattern model, combined with the time difference between the acquisition timestamp of historical valid images and the slaughter time, the theoretical weight value of captive animals corresponding to the acquisition time of historical valid images is calculated back, and the theoretical weight value is used as the initial weight label. The pose and quality of the historical valid images used to generate the initial weight labels are checked twice to determine whether the trunk pose of the animal in the corresponding image meets the preset weight estimation requirements. If it does not meet the preset weight estimation requirements, the corresponding image and the associated initial weight label are removed. The initial weight labels that pass the secondary verification are classified into trust levels, and the initial weight labels that meet the trust requirements are retained as trustworthy weight labels for association with historical valid images.
[0032] Specifically, the true weight of the animal at the slaughter stage, which is the only reliable benchmark for individual identification, is used to determine the fixed benchmark weight of the corresponding captive animal at the slaughter time. The true weight is directly collected by the farm's standard weighing equipment and is the only real weight data that has been physically calibrated throughout the entire process. This serves as the anchor point for backtracking calculations, ensuring the credibility of the subsequently generated labels from the source, unlike the industry-standard pseudo-label generation schemes that lack anchor points. Based on the determined slaughter benchmark weight, the locally adapted and corrected growth pattern model, and the time difference between the acquisition timestamp of a single historical valid image and the slaughter time, the weight backtracking calculation at the corresponding moment is completed to obtain the theoretical weight value of the captive animal at the time of the historical image acquisition. This value is used as the initial weight label for the corresponding image. By combining the slaughter anchor point, the localized growth model, and the precise time difference, the generated initial label ensures that it closely matches the actual weight growth rhythm of the corresponding individual in the farm's breeding environment, significantly reducing the deviation between the label and the actual weight. At the same time, no manual intervention is required throughout the entire process, fully reusing existing data resources in the breeding process, and generating batch training labels at no additional cost. For historically valid images with initial weight labels assigned, a secondary validation of pose and quality is performed to meet the model training requirements. This validation differs from the initial image screening during the earlier breeding cycle. The initial image screening was a pre-entry validation during real-time acquisition, focusing solely on the physical properties of the images to determine if they contained a complete, unobstructed, and clearly identifiable animal torso. Only images with truncated torsos, excessive occlusion, or blurry images were removed. As long as the basic identifiability requirements were met, the images could proceed to subsequent feature extraction and ID binding stages, without assessing whether the animal's pose was suitable for the weight estimation task. This secondary validation, however, is a post-training applicability validation for the model, performed on the images... Assuming the basic screening has passed, ID binding and label assignment have been completed, refined verification rules are set for the training requirements of the weight estimation model. The core judgment is whether the animal's torso posture in the image meets the preset weight estimation standards. Images with abnormal postures, such as curled-up torsos, excessive sideways leaning, or stacked with other individuals, are specifically removed, along with their corresponding initial weight labels. For example, an image that has passed the basic screening, even if the torso is complete, unobstructed, and clear, but the animal's torso is curled up, and the torso's length-to-width ratio differs greatly from a normal standing posture, cannot provide the model with a correct mapping relationship between weight and visual features. Such images will not be removed in the initial basic screening but will be filtered out in this secondary verification. Even if the label values of images with abnormal postures are accurate, they cannot provide effective weight estimation features for the model. Directly including them in the training set will cause the model to learn incorrect feature associations, resulting in accuracy degradation. Secondary verification can filter out such invalid training samples at the source. For the initial weight labels that pass the secondary verification, a credibility grading process is performed.The time difference between the historical image acquisition timestamp and the slaughter time is considered; the shorter the time difference, the higher the credibility level. The image's clarity and the percentage of visible torso quality are also considered; higher quality scores result in higher credibility levels. A pre-set credibility threshold is used to retain only initial weight labels that meet the threshold. Credibility levels are categorized based on the time difference between the corresponding historical image and the slaughter time, and the image's quality level. Only initial weight labels meeting the preset credibility requirements are retained as credible weight labels associated with the corresponding valid historical images. The preset credibility threshold is determined through pre-experiments: label samples with different time differences and quality scores are selected and compared with the true values of manual weighing at the corresponding time. The lowest level of label error within the model training allowable range is used as the benchmark, flexibly adjusted according to the model's accuracy requirements. The closer to the slaughter time, the smaller the time difference in backtracking calculations, resulting in lower label errors and higher credibility. This tiered screening ensures that the samples ultimately entering the model training set are all highly credible and highly matched valid samples, laying a solid data foundation for subsequent incremental model fine-tuning. This embodiment is used to generate highly reliable weight labels for historical valid images of captive animals throughout their entire breeding cycle, so as to achieve model self-iteration without manual intervention and without the need for manual weighing and labeling, thus providing high-quality and highly matched training samples for incremental model training.
[0033] In one embodiment, the step of constructing the training sample set for lightweight incremental fine-tuning prior to step S4 includes: The historical valid images with reliable weight labels are divided into a subset of training samples, which will be used as the main training dataset for this incremental fine-tuning. The local pre-stored benchmark sample library on the device side is retrieved. The benchmark sample library contains general weight estimation effective samples covering multiple scenarios and environments, which serve as the benchmark performance guarantee dataset for this incremental fine-tuning. The training sample subset is mixed with samples from the benchmark sample library to form the training sample set for this lightweight incremental fine-tuning. The training sample set is used for incremental training of the weight estimation model to be iterated on the edge.
[0034] Specifically, historical valid images of captive animals with reliable weight labels are divided into a subset of training samples for this incremental fine-tuning, serving as the main training dataset. The samples in this dataset are all derived from the actual farming scenarios of the farm, perfectly matching the breeds, pen environments, feeding conditions, and growth rhythms of the captive animals. This provides the model with farm-specific visual features and weight mapping relationships, resolving the scenario adaptation bias issue when the pre-deployed model is implemented on the farm. Furthermore, all samples are generated at zero manual cost, requiring no additional annotation. A pre-stored benchmark sample library is retrieved on the device side and used as the baseline performance guarantee dataset for this incremental fine-tuning. This benchmark sample library is a general sample library built during the model pre-training phase and pre-installed on the device side along with the pre-deployed model. The samples cover valid weight estimation data for different farming breeds, different lighting environments, different pen structures, and different growth stages across all scenarios. Introducing this benchmark sample library dataset is to prevent the model from only learning narrow-range scenario features during incremental fine-tuning, thus losing its original weight estimation capabilities under general scenarios, and providing a safety net for the model's basic performance. Finally, the training sample subset is mixed with samples from the benchmark sample library to construct the complete training sample set for this lightweight incremental fine-tuning. This sample set is used for incremental training of the pre-deployed weight estimation model to be iterated on the edge. By mixing the two types of samples, it is possible to ensure that the model accurately adapts to the local aquaculture scenario through the main training dataset, while leveraging the benchmark performance to ensure that the dataset maintains the model's original generalization performance. This avoids the problem that the model performs well only on the local data after incremental training, but its accuracy drops significantly after scene switching. This embodiment constructs a training sample set with both adaptability and stability through edge-side lightweight incremental fine-tuning, balancing the model's local scenario adaptability and generalization performance, effectively avoiding the common problems of insufficient model scenario adaptation and loss of original estimation capabilities in incremental fine-tuning.
[0035] In one embodiment, step S4, which involves performing lightweight incremental fine-tuning on the pre-deployed weight estimation model on the edge, freezing the weights of the model's backbone network, and only fine-tuning the parameters of the low-rank adaptation branches of the network, includes: Lock all weight parameters of the backbone network of the pre-deployed weight estimation model on the edge, and fix all weight parameters of the backbone network without updating them during fine-tuning; Only the trainable parameters of the low-rank adaptation branch in the weight estimation model are made available. The low-rank adaptation branch is a parameterized low-rank adaptation module connected in parallel or in series in the backbone network of the model, and it is the only iterative update object for this incremental fine-tuning. Based on the completed training sample set, incremental training of the model is performed locally on the device, and the parameters of the low-rank adaptation branch are iteratively updated to complete the adaptation of the model to the local captive animal weight estimation scenario. After completing the set training iteration process, a fine-tuned weight estimation model is generated and stored locally on the device for verification.
[0036] Specifically, all weight parameters of the backbone network of the pre-deployed weight estimation model on the edge are locked, and all parameters of the backbone network are fixed and not updated during the entire fine-tuning process. This backbone network is the core network trained during the model pre-training stage, and has fully learned the general basic visual features required for weight estimation of captive animals, including the basic mapping relationship between animal body contour, length-width ratio and weight. Freezing the backbone network can significantly compress the number of trainable parameters in this fine-tuning, reduce the computing power and storage overhead of the training process, and enable it to adapt to the limited hardware resources of edge devices. At the same time, the general generalization estimation ability formed during the model pre-training stage is fully preserved, avoiding the problem that the model can only adapt to the narrow range of scenes after incremental training and the accuracy drops significantly after switching scenes. It can also prevent the model from overfitting due to the scene limitations of the incremental samples in the current scene, and ensure the robustness of the model after iteration. After locking the weights of the backbone network, only the trainable parameters of the low-rank adaptation branch in the weight estimation model are made available, and this branch is used as the sole iterative update target for this incremental fine-tuning. The low-rank adaptation branch is a parameterized low-rank adaptation module connected in parallel or in series in the backbone network of the model. The low-rank adaptation branch only learns the differential features between the current aquaculture scenario and the general pre-training scenario, and does not need to relearn the basic visual features of weight estimation. Therefore, the number of trainable parameters is much lower than that of the backbone network, enabling fast and low-power training iterations on edge devices. At the same time, the design of updating only the parameters of this branch ensures that the basic estimation capability of the model is entirely provided by the locked backbone network, while the incremental adaptation capability is provided by the low-rank adaptation branch. The decoupling of the two completely avoids the impact of incremental training on the original basic performance of the model. Based on a mixed training sample set, incremental training of the model is performed locally on the device. Mean Absolute Error (MAE) is used as the training loss function, and the AdamW optimizer adapted to the device iteratively updates the parameters of the low-rank adaptation branch. During training, a fixed number of iterations and an early stopping mechanism are set. Training is terminated early when the loss function does not decrease for several consecutive iterations to avoid overfitting. The threshold for the number of iterations with no continuous decrease in the early stopping mechanism is determined through pre-experimentation based on the small sample characteristics of incremental training on the device and the upper limit of computing power. The minimum number of iterations required to ensure model convergence without overfitting is used as a benchmark, balancing training efficiency and model performance. Simultaneously, the training task is executed during the device's idle time, such as nighttime when animals are resting and there are no daily weight estimation tasks, without consuming computing resources from normal daytime farming operations and without affecting the continuous and stable operation of the original system. After completing the preset training iteration process, the fine-tuned weight estimation model is generated and stored locally on the device for subsequent accuracy verification. The fine-tuned new model will not directly replace the currently running online model. It must pass the accuracy verification of subsequent independent samples before it can be launched online to avoid the risk of an unqualified model being launched directly and affecting normal weight estimation business.
[0037] In one embodiment, step S5, the step of constructing a validation sample set based on the true weight of the target captive animals at the time of slaughter, includes: From the valid samples with true weight values obtained at the slaughter stage, we screened out independent samples that did not participate in this incremental fine-tuning training. The selected independent samples were uniformly sampled, and the sampled independent samples covered different collection time periods, different animal individuals, and different lighting environments. The independent samples that have been sampled are combined to form a verification sample set, which is used to perform accuracy verification on the fine-tuned weight estimation model.
[0038] Specifically, from the valid samples of true weight values collected by weighing equipment at the slaughter stage, independent samples that were not involved in this incremental fine-tuning training were selected. The training samples for this incremental fine-tuning were historical valid images tagged with time-series backtracking, while the independent samples selected in this step were brand-new samples collected in real time at the slaughter stage that were not included in the training set. The true weight values of these samples were reliable data directly collected by the weighing equipment and were completely independent of the backtracking labels used for training. Selecting independent samples was to avoid the model self-validation problem caused by the training samples and validation samples being from the same source, and to prevent false high scores and distorted validation results due to model overfitting to the training samples. This ensured that the results of subsequent accuracy validation could truly reflect the model's actual generalization ability on new data. Uniform sampling was performed on the selected independent samples to ensure that the sampled independent samples could cover actual farming scenarios with different collection times, different animal individuals, and different lighting environments. Uniform sampling avoids the problem of the validation sample set containing only high-quality samples under ideal conditions, which would prevent the validation results from reflecting the model's actual performance in complex farming scenarios. Uniform sampling ensures that the samples cover different lighting environments, such as backlighting in the early morning and evening, low light at night, and strong light at noon; it also covers animals in different growth stages and body conditions within each batch; and it covers the collection time at different walking stages during animal weighing. This allows the validation sample set to fully reproduce the entire daily operation of the end-side equipment, ensuring the comprehensiveness and authenticity of subsequent accuracy validation. The independently sampled data are combined to form a dedicated validation sample set for this iteration, used to perform accuracy validation on the fine-tuned weight estimation model. The completed validation sample set is stored locally on the end-side, physically isolated from the training sample set, and will not be used in the model training process, ensuring the objectivity and uniqueness of the validation benchmark. Simultaneously, the validation sample set is dynamically updated with each batch of animals slaughtered, and each model self-iteration uses the latest slaughtered samples to ensure that the validation benchmark is completely synchronized with the actual farming environment, animal breeds, and growth stages of the current farm.
[0039] In one embodiment, for step S5, the accuracy of the fine-tuned weight estimation model is checked. If the check passes, the pre-deployed weight estimation model on the client side is automatically replaced, completing the single online self-iteration step of the model, including: Based on the completed verification sample set, the weight estimation accuracy test was performed on the weight estimation model generated in this fine-tuning and the weight estimation model currently pre-deployed and running on the edge. By comparing the estimation errors of the two models on the same validation sample set, it is determined whether the accuracy of the weight estimation model generated in this fine-tuning meets the preset validation pass standard. If the verification passes, the weight estimation model generated in this fine-tuning will automatically replace the pre-deployed weight estimation model on the device side, completing the iterative update of the model parameters. If the verification fails, the model parameters generated in this fine-tuning will be discarded, the weight estimation model that has been pre-deployed and run on the edge before the accuracy test will be retained, and the online self-iterative process will be terminated.
[0040] Specifically, based on the validation sample set, the weight estimation accuracy test was performed on both the weight estimation model generated in this fine-tuning and the weight estimation model currently pre-deployed and continuously running online on the edge, under completely identical operating environments. The dual-model parallel testing with the same benchmark was adopted to eliminate test errors caused by differences in validation samples and operating environments, ensuring that the accuracy test results of the two models are directly comparable. Unlike the method of absolute accuracy verification of a single model, this method can more realistically reflect whether the new model has an actual optimization effect relative to the currently used model, and avoid the distortion of validation results caused by the bias of validation samples. After completing the accuracy tests of the two models, the weight estimation errors of the two models under the same validation sample set are compared to determine whether the accuracy of the weight estimation model generated in this fine-tuning meets the preset validation pass standard. The preset validation pass standard is flexibly set according to the actual accuracy requirements of the farm. The core validation dimension is that the average estimation error of the new model is lower than that of the currently running online model, and the error reduction rate meets the preset threshold. The preset threshold for the error reduction rate is determined based on the accuracy requirements of the farm's refined management of weight estimation and the benchmark error of the currently used model. The minimum error reduction rate is used as the benchmark to meet the needs of breeding grouping, feeding adjustment, and slaughter planning management. This ensures that the new model has actual optimization effect and avoids frequent invalid iterations caused by small data fluctuations, reducing unnecessary computing power and storage resource consumption of the end-side equipment. If the verification result meets the preset pass criteria, the new model generated by this fine-tuning is deemed to have better adaptability to the current scenario and higher estimation accuracy. The weight estimation model generated by this fine-tuning will automatically replace the currently pre-deployed weight estimation model on the device during idle periods, completing the iterative update of the model parameters. After replacement, the new model will serve as the running model for daily weight estimation on the device and as the foundational pre-deployed model for the next self-iteration process, forming a complete closed loop of continuous autonomous optimization of model accuracy, requiring no manual intervention or operation. If the verification result does not meet the preset pass criteria, the model iteration is deemed to have failed to meet expectations. The model parameters generated by this fine-tuning will be discarded, releasing local storage resources on the device. Simultaneously, the weight estimation model pre-deployed on the device before the accuracy test will be fully retained, terminating the online self-iteration process. The entire verification and testing process will not modify the parameters or running status of the currently running online model. Even if the new model fails verification, the daily weight estimation business on the device will not be affected, avoiding the risk of decreased estimation accuracy and business anomalies due to model iteration failure.
[0041] In summary, this invention uses an end-side visual acquisition device to extract recognizable trunk visual features of target captive animals throughout their breeding cycle, generating unique individual feature IDs. The acquired animal images, corresponding acquisition timestamps, and individual feature IDs are then bound together. When the target captive animals are weighed at market, the trunk visual features of the weighed animals are acquired in real-time and matched with the stable feature vectors corresponding to the pre-stored individual feature IDs to obtain the unique individual feature IDs for each animal. Simultaneously, the true weight value from the weighing device is acquired, establishing a one-to-one correspondence between individual feature IDs and true weight values. Based on the bound true weight values and a pre-built growth pattern model for the corresponding breed of target captive animals, each individual feature ID is associated with a specific animal. The entire historical valid images are backtested in time to generate a reliable weight label for each historical valid image. Using the historical valid images with reliable weight labels as incremental training samples, a lightweight incremental fine-tuning is performed on the pre-deployed weight estimation model on the edge, freezing the weights of the model's backbone network and only fine-tuning the parameters of the low-rank adaptation branches of the network. A verification sample set is constructed based on the true weight of the target captive animals at the time of slaughter, and the accuracy of the fine-tuned weight estimation model is verified. After the verification is passed, the pre-deployed weight estimation model on the edge is automatically replaced, completing a single online self-iteration of the model. This achieves the goal of no human intervention, fully closed-loop online self-iteration of the captive animal weight estimation model on the edge, reducing iteration costs and improving the model's scene adaptation accuracy.
[0042] The above description is only a preferred embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent structural or procedural transformations made based on the content of the present invention specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of the present invention.
Claims
1. An online self-iterative method for modeling the weight of captive animals using end-side devices, characterized in that, Includes the following steps: Using edge vision acquisition devices, extract the trunk visual features of the target captive animals that can be stably distinguished during the breeding cycle, generate a unique individual feature ID, and bind the collected valid animal images, corresponding acquisition timestamps, and individual feature IDs. When the target captive animals are weighed at the time of slaughter, the visual features of the animal’s trunk are collected in real time and matched with the stable feature vector corresponding to the pre-stored individual feature ID to obtain the unique individual feature ID of the corresponding animal. At the same time, the true weight value of the weighing equipment is obtained, and a one-to-one correspondence between the individual feature ID and the true weight value is established. Based on the bound weight true value, combined with the pre-built growth pattern model of the target captive animal corresponding to the breed, the time-series backtracking of the full-cycle historical valid images corresponding to each individual feature ID is performed to generate a reliable weight label corresponding to each historical valid image. Using historical valid images with reliable weight labels as incremental training samples, lightweight incremental fine-tuning is performed on the pre-deployed weight estimation model on the edge, freezing the weights of the model backbone network and only fine-tuning the parameters of the low-rank adaptation branch of the network. A validation sample set is constructed based on the true weight of the target captive animals at the time of slaughter. The accuracy of the fine-tuned weight estimation model is validated. After the validation is passed, the pre-deployed weight estimation model on the end side is automatically replaced, completing a single online self-iteration of the model.
2. The online self-iterative method for modeling the weight of captive animals oriented towards end-side devices according to claim 1, characterized in that, The steps for screening valid animal images include: By using a visual detection model deployed on the edge, target detection is performed on the raw images acquired in real time by the visual acquisition device, and the torso region of captive animals in the images is identified. The integrity of the identified torso region is checked to determine whether the entire torso of the captive animal is within the image acquisition range, and original images with truncated torso regions are discarded. The occlusion degree of the image that has completed the integrity check is checked to determine the proportion of the torso region that is occluded, and the original image with the occlusion ratio exceeding the preset threshold is removed. Images that pass the occlusion level check are then checked for sharpness. Original images with image sharpness below a preset threshold or inability to identify the torso outline are discarded to obtain valid animal images.
3. The online self-iterative method for modeling the weight of captive animals oriented towards end-side devices according to claim 1, characterized in that, The step of generating a unique individual feature ID and binding the collected valid animal image, the corresponding collection timestamp, and the individual feature ID includes: For the selected valid animal images, a lightweight feature extraction network is used to extract the visual features of the torso region of the captive animals in the images; For the trunk visual features extracted from multiple effective images of the same captive animal within a continuous time period, mean fusion and feature normalization are performed to unify the dimension and distribution benchmark of the feature vector and generate a stable feature vector for the corresponding captive animal. Based on the generated stable feature vector, a unique individual feature ID is assigned to the corresponding captive animal, and a pre-stored mapping relationship between the individual feature ID and the corresponding stable feature vector is established. Each valid animal image and its collection timestamp are associated and bound with the individual feature ID of the captive animal in the corresponding image to complete the identification tagging of a single valid image.
4. The online self-iterative method for modeling the weight of captive animals oriented towards end-side devices according to claim 1, characterized in that, The step of establishing a one-to-one correspondence between individual feature IDs and true weight values includes: When captive animals pass through the weighing channel to be sold, continuous images of the weighed animals are acquired in real time through the visual acquisition device in the channel, and the visual features of the animal's torso are extracted from each frame of the image. The extracted visual features of the torso are matched with the stable feature vectors corresponding to the pre-stored individual feature IDs to determine the unique individual feature IDs of the weighed animals. The system synchronously acquires the true weight value output by the weighing device, which is synchronized with the time of the weighing image acquisition, and records the corresponding acquisition timestamp. Based on the unidirectional movement sequence of captive animals passing through the weighing channel in the exit channel, and combined with the matching time sequence of individual feature IDs and the collection time sequence of true weight values, a one-to-one binding of individual feature IDs with the corresponding true weight values of animals is completed, generating real weight samples with identity tags.
5. The online self-iterative method for modeling the weight of captive animals oriented towards end-side devices according to claim 1, characterized in that, Before the step of performing time-series backtracking of the full-cycle historical valid images corresponding to each individual feature ID, the method further includes a step of adapting and correcting the pre-built growth pattern model of the target captive animal species, including: Retrieve the historical slaughter weight of the same breed of captive animals in this farm, as well as the corresponding breeding cycle and feeding conditions data; Based on the retrieved historical data, the pre-built general breed growth pattern model is fitted and corrected, and the growth rhythm parameters of the model are adjusted so that the corrected growth pattern model matches the animal weight gain pattern in the local breeding environment. The revised growth pattern model is stored locally on the edge and used as a baseline model for time-series backtracking calculation of the weight labels corresponding to historical images.
6. The online self-iterative method for modeling the weight of captive animals oriented towards end-side devices according to claim 5, characterized in that, The step of generating a reliable weight label for each historical valid image includes: Based on the true weight value bound to the slaughter stage, determine the benchmark weight of the corresponding captive animal at the slaughter time point; Based on the baseline weight at slaughter and the corrected growth pattern model, combined with the time difference between the acquisition timestamp of historical valid images and the slaughter time, the theoretical weight value of captive animals corresponding to the acquisition time of historical valid images is calculated back, and the theoretical weight value is used as the initial weight label. The pose and quality of the historical valid images used to generate the initial weight labels are checked twice to determine whether the trunk pose of the animal in the corresponding image meets the preset weight estimation requirements. If it does not meet the preset weight estimation requirements, the corresponding image and the associated initial weight label are removed. The initial weight labels that pass the secondary verification are classified into trust levels, and the initial weight labels that meet the trust requirements are retained as trustworthy weight labels for association with historical valid images.
7. The online self-iterative method for modeling the weight of captive animals oriented towards end-side devices according to claim 1, characterized in that, The steps for constructing the training sample set for lightweight incremental fine-tuning include: The historical valid images with reliable weight labels are divided into a subset of training samples, which will be used as the main training dataset for this incremental fine-tuning. The local pre-stored benchmark sample library on the device side is retrieved. The benchmark sample library contains general weight estimation effective samples covering multiple scenarios and environments, which serve as the benchmark performance guarantee dataset for this incremental fine-tuning. The training sample subset is mixed with samples from the benchmark sample library to form the training sample set for this lightweight incremental fine-tuning. The training sample set is used for incremental training of the weight estimation model to be iterated on the edge.
8. The online self-iterative method for modeling the weight of captive animals oriented towards end-side devices according to claim 7, characterized in that, The steps of performing lightweight incremental fine-tuning on the pre-deployed weight estimation model on the peer side, freezing the weights of the model backbone network, and only fine-tuning the parameters of the low-rank adaptation branches of the network, include: Lock all weight parameters of the backbone network of the pre-deployed weight estimation model on the edge, and fix all weight parameters of the backbone network without updating them during fine-tuning; Only the trainable parameters of the low-rank adaptation branch in the weight estimation model are made available. The low-rank adaptation branch is a parameterized low-rank adaptation module connected in parallel or in series in the backbone network of the model, and it is the only iterative update object for this incremental fine-tuning. Based on the completed training sample set, incremental training of the model is performed locally on the device, and the parameters of the low-rank adaptation branch are iteratively updated to complete the adaptation of the model to the local captive animal weight estimation scenario. After completing the set training iteration process, a fine-tuned weight estimation model is generated and stored locally on the device for verification.
9. The online self-iterative method for modeling the weight of captive animals oriented towards end-side devices according to claim 1, characterized in that, The step of constructing a validation sample set based on the true weight of the target captive animals at the time of slaughter includes: From the valid samples with true weight values obtained at the slaughter stage, we screened out independent samples that did not participate in this incremental fine-tuning training. The selected independent samples were uniformly sampled, and the sampled independent samples covered different collection time periods, different animal individuals, and different lighting environments. The independent samples that have been sampled are combined to form a verification sample set, which is used to perform accuracy verification on the fine-tuned weight estimation model.
10. The online self-iterative method for modeling the weight of captive animals oriented towards end-side devices according to claim 9, characterized in that, The steps of performing accuracy verification on the fine-tuned weight estimation model, and automatically replacing the pre-deployed weight estimation model on the client side after passing the verification, to complete a single online self-iteration of the model, include: Based on the completed verification sample set, the weight estimation accuracy test was performed on the weight estimation model generated in this fine-tuning and the weight estimation model currently pre-deployed and running on the edge. By comparing the estimation errors of the two models on the same validation sample set, it is determined whether the accuracy of the weight estimation model generated in this fine-tuning meets the preset validation pass standard. If the verification passes, the weight estimation model generated in this fine-tuning will automatically replace the pre-deployed weight estimation model on the device side, completing the iterative update of the model parameters. If the verification fails, the model parameters generated in this fine-tuning will be discarded, the weight estimation model that has been pre-deployed and run on the edge before the accuracy test will be retained, and the online self-iterative process will be terminated.
Citation Information
Patent Citations
Captive animal weight prediction method based on environment and visual feature fusion
CN121502694A
Generating image object segmentations utilizing graph-cut partitioning in self-supervised object discovery
US20250111520A1