A precise, rapid, and intelligent detection system for counting ribs in live pigs based on X-ray imaging.
By utilizing image acquisition and processing technology based on X-ray machine systems, combined with convolutional neural networks and machine learning algorithms, a precise, rapid, and intelligent detection system for the number of ribs in live pigs has been developed. This system solves the technical bottleneck in rib counting in pig breeding and enables efficient detection of the number of ribs in live pigs and the selection of superior individuals.
Patent Information
- Application Number
- CN202311038693.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-17
- Publication Date
- 2025-11-14
- Estimated Expiration
- 2043-08-17
AI Technical Summary
The lack of precise, rapid, and intelligent technology for measuring the number of ribs in live pigs limits the progress in breeding new breeds or strains with multiple ribs.
By employing image acquisition and processing technology based on an X-ray machine system, combined with convolutional neural networks and machine learning algorithms, a precise and rapid intelligent detection system for the number of ribs in live pigs was developed. This system integrates X-ray image acquisition, a ResNet-based classification model, and a YOLOv5 object detection model to achieve automatic identification and counting of the number of ribs in live pigs.
It enables accurate and rapid detection of the number of ribs in live pigs, with an accuracy rate of over 93% and a detection rate more than 600 times that of manual counting, supporting the selection of superior individuals in pig breeding.
Smart Images

Figure CN117152499B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of livestock genetics and breeding, and relates to the development of a precise and rapid intelligent detection system for the number of ribs in live pigs based on an X-ray machine system. Specifically, it includes the acquisition of live pig chest rib images based on an X-ray machine system, the construction of an image-based precise rib count detection model, the development of intelligent detection software, and the application of the intelligent detection system in the selection of superior breeding pigs. Background Technology
[0002] A digital X-ray machine, also known as a digital X-ray imaging system or DR (Digital Radiography), consists of a flat panel detector, a scanning controller, and an image monitor. It converts X-ray photons into digital images using a flat panel detector. X-rays are electromagnetic waves with extremely short wavelengths and high energy. Their ability to penetrate matter is related to the energy of the photons; the shorter the wavelength of the X-ray, the higher the energy of the photons, and the stronger the penetrating power. Furthermore, the penetrating power of X-rays is also related to the density of the material. Denser materials absorb more X-rays and transmit less, while less dense materials absorb less and transmit more. This differential absorption property of X-rays can distinguish between bones and soft tissues such as muscles and fat, which have different densities, and can create images with varying contrasts of light and dark or black and white on a screen or film. This is the physical basis of X-ray fluoroscopy and photography.
[0003] The pig spine includes the cervical, thoracic, lumbar, sacral, and caudal vertebrae. Variation in the number of vertebrae is significantly correlated with growth and carcass traits. Studies have shown that each additional 15mm long vertebra can increase carcass length by 80mm and carcass weight by approximately 1%. Therefore, strengthening the selection of vertebral number will mean selecting for pig growth and carcass traits. Furthermore, research indicates that vertebral number is a highly heritable trait, with a heritability of 0.74, making genetic improvement of vertebral number relatively easy in breeding pigs. In pigs, the number of cervical and sacral vertebrae is relatively fixed, at 7 and 4 respectively, but the number of thoracic and lumbar vertebrae varies greatly. Early studies reported 14-16 thoracic vertebrae and 5-7 lumbar vertebrae in commercial pig breeds; wild boars and most local Chinese pig breeds have a total of 19 thoracic and lumbar vertebrae, while European commercial pig breeds have 21-23. This demonstrates the significant variation in vertebral number among different pig herds. For groups exhibiting such high vertebral number variation, selective breeding to improve pig productivity holds great potential. The number of ribs corresponding to the number of thoracic vertebrae is one of the most important economic traits in pig breeding. Theoretically, X-rays penetrate pig skin, fat, muscle, internal organs, and bones with varying absorption rates. This difference can distinguish the ribs in the pig's chest from other tissues and organs, enabling clear imaging. Currently, digital X-ray machines are commonly used in human and veterinary medicine, frequently used for image acquisition in human and pet disease diagnosis. However, research on the application of digital X-ray machines in livestock and poultry breeding remains relatively limited. Currently, there is no technology for precise, rapid, and intelligent in vivo determination of the number of ribs in pigs. The development of this technology holds promise for solving the key technological bottleneck restricting the development of new breeds or lines with higher rib counts in my country. Summary of the Invention
[0004] This invention addresses the current technical bottleneck of not being able to accurately, rapidly, and intelligently determine the number of ribs in live pigs, aiming to provide a detection system based on an X-ray machine for this purpose. The main technical contents of this invention are as follows:
[0005] Based on the imaging principle of X-ray machines, the optimal instrument parameters affecting image quality were selected for the X-ray machine system used in this invention. Using these optimal parameters, clear X-ray images of the pig's chest in both supine and prone positions were acquired, and a pig dissection experiment was conducted to accurately determine the rib count phenotype. The X-ray images were annotated using the roLabelImg software, and corresponding datasets were created according to the needs of the subsequent classification and target detection models. Using these datasets, a ResNet classification model based on convolutional neural networks for supine and prone positions of live pig X-ray images was developed. Using these datasets, a target detection model based on the YOLOv5 algorithm in machine learning was developed. The accurate classification model and the target detection model were integrated and encapsulated to obtain a fast and intelligent algorithm for detecting the number of live pig ribs based on PySide2. This algorithm was then used to detect the number of live pig ribs.
[0006] The system includes an X-ray machine system, a detection module, a storage module, and a display module. The detection module uses a precise, rapid, and intelligent algorithm for detecting the number of ribs in live pigs to obtain the number of ribs. The construction of the precise, rapid, and intelligent algorithm for detecting the number of ribs in live pigs includes:
[0007] S1. Fix piglets from birth to nursery stage, use X-ray machine system to collect live supine and prone chest X-ray images of pigs, and conduct pig dissection experiments to accurately determine the number of pig ribs phenotype;
[0008] S2. The data volume is expanded by using single-sample data augmentation. The X-ray images are annotated and processed to create corresponding datasets according to the needs of the subsequent classification model and target detection model.
[0009] S3. Develop a ResNet classification model for pig live X-ray images in supine and prone positions based on the corresponding dataset.
[0010] S4. Develop an object detection model based on the YOLOv5 algorithm in machine learning using the relevant dataset;
[0011] S5. Integrate and encapsulate the accurate classification model and the target detection model to obtain an accurate, fast and intelligent detection algorithm for the number of ribs in live pigs.
[0012] Specifically, in S1, acquiring live supine and prone chest X-ray images of pigs also includes using piglets from birth to nursery stage, employing pig fixation devices, and adjusting the parameters of different types of X-ray machine systems to acquire supine and prone chest X-ray images.
[0013] Specifically, in S2, data enhancement processing is performed on the chest X-ray image, including random small-amplitude rotation of the original image, random adjustment of contrast, and random addition of Gaussian noise. Then, the ribs are labeled on the X-ray image using the roLabelImg software.
[0014] Specifically, in S3, the dataset is randomly divided into training, validation and test sets. A ResNet classification model based on convolutional neural network is constructed for pig live X-ray images in supine and prone positions. During model training, the input image size is uniformly converted to 224*224, the learning rate is uniformly set to 0.0002, the batch size is uniformly set to 8, the number of iterations is set to 100, and the Adam optimizer is used in model training.
[0015] Specifically, in S4, the dataset is randomly divided into training, validation, and test sets. A rib target detection model is constructed using the Yolov5 series of machine learning algorithms. During model training, the input layer performs data preprocessing on the images, including Mosaic enhancement, adaptive anchor box calculation, and adaptive image scaling. The backbone network is used for feature extraction, consisting of convolutional layers, pooling layers, activation functions, and other modules, mainly including CBS, C3, and SPPF modules. The CBS module encapsulates convolutional Conv, batch normalization (BN), and Swish activation functions. The feature fusion network Neck consists of the feature pyramid network FPN and the path enhancement network PANet. The head part includes three parts: positive and negative sample selection, loss function calculation, and non-maximum suppression (NMS) processing.
[0016] Preferably, a rib target detection model is constructed based on the ResNet classification model and the Yolov5 series algorithms. The model construction method further includes expanding the number of experimental pigs and adjusting parameters to optimize the classification and target detection models.
[0017] Specifically, the method of using a precise, rapid, and intelligent algorithm for detecting the number of ribs in live pigs involves the following steps:
[0018] 1) Acquire live X-ray images of pigs;
[0019] 2) The system uses a ResNet classification model to determine whether a live pig is in a supine or prone position; the number of ribs is detected in X-ray images of live pigs in supine or prone positions.
[0020] 3) The system uses a rib target detection model to identify rib targets in live pigs:
[0021] 4) The system identifies and counts the ribs of live pigs.
[0022] Beneficial effects of the present invention
[0023] This invention determined the optimal instrument parameters for acquiring high-quality X-ray images through the adjustment and selection of X-ray image acquisition parameters; it developed a ResNet network classification model based on convolutional neural networks, which can accurately classify supine and prone X-ray images with an accuracy approaching 100%; using live pig chest images acquired by the X-ray machine system, a precise rib detection model was constructed using the YOLOv5 series algorithms in machine learning, achieving an accuracy of over 93%, which is more than 5% higher than the 88.33% accuracy of manual counting. In terms of counting speed, the manual marking and counting speed is approximately 18.86 s / image, while the YOLOv5 model's detection speed is 0.03 s / image, more than 600 times faster than manual detection. This algorithm can accurately and quickly detect the number of ribs based on live pig X-ray images, and based on the detection results, superior individuals with a high number of ribs can be selected as breeding pigs. Attached Figure Description
[0024] Figure 1 Comparative analysis of image quality at different X-ray voltage intensities.
[0025] Figure 2 Comparative analysis of image quality at different exposure times.
[0026] Figure 3 Comparative analysis of X-ray images of the chest and ribs of live pigs in supine and prone positions.
[0027] Figure 4 : Schematic diagram of enhanced comparison of live pig X-ray images.
[0028] Figure 5 Comparison of training loss and validation accuracy of four convolutional neural network classification models.
[0029] Figure 6 Example of rib annotation in a chest X-ray image.
[0030] Figure 7 Comparative analysis of the loss functions of five models in networks of different depths.
[0031] Figure 8 Login interface of the intelligent detection system for the number of ribs in live pigs.
[0032] Figure 9 Main interface of the intelligent detection system for the number of ribs in live pigs.
[0033] Figure 10 Detection area of intelligent detection system for counting the number of ribs in live pigs.
[0034] Figure 11 Information entry area for the intelligent detection system for the number of ribs in live pigs.
[0035] Figure 12 : Phenotypic information operation area of intelligent detection system for the number of ribs in live pigs. Detailed Implementation
[0036] The present invention will be further described below with reference to embodiments, but the scope of protection of the present invention is not limited thereto:
[0037] To enable those skilled in the art to better understand the technical solutions in this application, the present invention will be further described below with reference to embodiments. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0038] Example 1: Evaluation of the rate and accuracy of live pig chest X-ray image acquisition and manual counting
[0039] 1.1 X-ray machine system parameter selection
[0040] This embodiment uses a USInnoVet X-ray system to acquire chest images of experimental pigs. First, the pigs were fixed in place. Then, two key parameters affecting image quality in the X-ray system, voltage intensity (kV) and exposure time (mAs), were tested. All other parameters used the system's default settings. The specific operation is as follows:
[0041] (1) The exposure time was set to 8 mAs, and then the voltage intensity was adjusted to 40 kV, 60 kV, 70 kV, 75 kV, 80 kV, and 95 kV for testing. The test results show that a clear image can be obtained when the voltage intensity is adjusted to the 70-75 kV range. Figure 1 ).
[0042] (2) The voltage intensity was set to 75 kV, and the exposure time was adjusted to 4 mAs, 8 mAs, 12 mAs, and 20 mAs for testing. The test results show that a clear image can be obtained in the exposure time range of 8-12 mAs. Figure 2 )
[0043] 1.2 Acquisition of X-ray images of experimental pigs and manual counting of ribs
[0044] (1) Chest X-ray images were acquired for 120 experimental pigs based on the "optimal" image parameters selected in "1.1". The experimental pigs were placed in both supine and prone positions. Figure 3 Two to three images were taken from each experimental pig, for a total of 299 images. The test results showed that ideal chest and rib X-ray images could be obtained from both supine and prone positions of the pigs.
[0045] (2) The images were manually counted on-site by designated personnel. Additionally, 10 images were randomly selected, and three people were assigned to each image to analyze the counting rate. The results showed that the average manual counting time was 18.861 s / image.
[0046] 1.3 Assessment of the accuracy of manual counting
[0047] All experimental pigs were slaughtered, and the number of ribs was accurately measured. The number of ribs per pig was confirmed by two people counting separately. The accuracy of the manual counting was evaluated by comparing the rib counts measured after slaughter with those based on X-ray images. The results showed that the manual counting based on X-ray images resulted in errors in rib counting for 14 pigs, with an accuracy rate of 88.33%.
[0048] Example 2: Construction and Performance Evaluation of a Pig Supine and Prone Posture X-ray Image Classification Model Based on Convolutional Neural Network
[0049] 1.1 Data Augmentation Processing
[0050] This embodiment uses single-sample data augmentation to expand the data volume by augmenting the original image ( Figure 4 A) Perform random small-amplitude rotations ( Figure 4 B) Randomly adjust contrast ( Figure 4 C) Randomly add Gaussian noise ( Figure 4 In method D), a total of 1192 images were obtained after enhancement processing, including 624 prone images and 568 supine images.
[0051] 1.2 Classification Model Construction and Accuracy Evaluation
[0052] Due to different shooting postures, the number of left and right ribs in prone X-ray images corresponds to the actual direction, while the opposite is true for supine X-ray images. To eliminate ambiguity in rib counting caused by different shooting postures in subsequent target detection, this embodiment, based on data augmentation, uses multiple convolutional neural network algorithms such as AlexNet, VGG, GoogLeNet, and ResNet to construct classification models for supine and prone X-ray images. In this embodiment, 1192 live pig X-ray images are classified and randomly divided into training, validation, and test sets in an approximately 8:1:1 ratio (actual number 952:120:120), ensuring that the source images are mutually exclusive.
[0053] The above training datasets were used to train AlexNet, VGG16, GoogLeNet, and ResNet34 network models respectively, and the accuracy of the models was evaluated on the validation set. The input image size was uniformly converted to 224*224, the learning rate was uniformly set to 0.0002, the batch size was uniformly set to 8, and the number of iterations was set to 100. To address the issue of long training time, the Adam optimizer was used in model training, which can adaptively adjust the learning rate of each parameter. The Adam algorithm flowchart is shown in Table 1.
[0054] Table 1 Adam Algorithm Flow
[0055]
[0056]
[0057] This invention uses the cross-entropy loss function to compare the training loss curves of live pig X-ray images, as shown in the following expression:
[0058]
[0059] Where x represents the sample; i represents the category; y i For the true labels of the sample pairs of categories; a i a represents the probability that the network model predicts a sample as class i. i It is usually obtained by processing the original network output with Softmax.
[0060] Training results show that, with the increase of the number of iterations, the training loss of the four models shows a decreasing trend to varying degrees during training. Figure 5 A). GoogLeNet had the highest initial training loss, which then decreased rapidly, eventually showing a slow downward trend along with other networks as the number of training iterations increased. Overall, ResNet34 maintained the lowest loss value for the same number of iterations, reaching 0.002 after 100 iterations, which is 1 / 136 of the initial loss. In the validation set, the accuracy of the four models increased to varying degrees with the number of training iterations, all exceeding 0.9 before the end. ResNet34 maintained the highest accuracy for the same number of iterations, approaching 1 after 100 iterations. Figure 5 B).
[0061] 1.3 Evaluation of Classification Model Performance
[0062] The above test datasets were used to evaluate the performance of AlexNet, VGG16, GoogLeNet, and ResNet34 network models. The test results show that there are significant differences in the prediction performance of the four network models. ResNet34 has a prediction accuracy of 98.30%, while the actual accuracy of the other three network models does not exceed 90% (Table 2).
[0063] Table 2. Performance comparison of four convolutional neural network classification models on the test set.
[0064]
[0065] Comparing prone and supine postures, the accuracy rate for the prone posture is generally higher than that for the supine posture. The difference in accuracy between the two postures is significant in the AlexNet and GoogLeNet network models. Comparing the average detection time per image, VGG16 is the slowest among the four network models, with an average detection time of 0.521s per image in the test set, which is 4.4 times that of AlexNet. In summary, the ResNet34 network model constructed in this implementation can accurately and quickly classify pigs in supine and prone postures.
[0066] Example 3: Construction and Performance Evaluation of a Live Porcine Rib Count Detection Model Based on YOLOv5 Algorithm
[0067] 1.1 Data Augmentation Processing
[0068] The data augmentation method is the same as in section 1.1 of Example 2. After augmentation, a total of 1192 images were obtained, including 624 prone images and 568 supine images.
[0069] 1.2 Image Tag Creation
[0070] In this embodiment, the roLabelImg software is used to annotate the ribs, generating an XML or JSON file with the same name as the image.
[0071] 1.4 Rib Target Detection Model Construction
[0072] This embodiment, based on data augmentation and rib label creation, also classifies 1192 live pig X-ray images, randomly dividing them into training, validation, and test sets in an approximately 8:1:1 ratio (actually 952:120:120). A rib target detection model is then built using the YOLOv5 algorithm from machine learning within the training set. The YOLOv5 network consists of four parts: Input, Backbone, Neck, and Head. A live pig X-ray image is input into the network. The Backbone extracts features from the X-ray image, and the resulting feature map is then fed to the Neck stage for feature fusion. The Head module calculates the loss of the feature fusion result. After iterative training, the detection of rib targets in X-ray images is achieved.
[0073] The input stage, or model input, performs image preprocessing, primarily in three parts: Mosaic enhancement, adaptive anchor box calculation, and adaptive image scaling. Mosaic enhancement uses random sampling to randomly scale, crop, and arrange X-ray images before stitching them together into a single image. The bounding boxes of each X-ray image are also cropped accordingly. Adaptive anchor box calculation is performed in two steps: first, a set of prior boxes is calculated based on the rib marker boxes in the X-ray image training set; then, the prior boxes are scaled and transformed for different X-ray image sizes to generate anchor boxes suitable for the current X-ray image. Adaptive image scaling involves inputting X-ray images of different sizes into the model for inference. The model pre-scales the input images to a uniform size for prediction, but excessive padding can slow down inference. To address this, the padding method is improved to ensure that all image sides are multiples of 32 pixels, using the fewest pixels possible to fill the image, thereby reducing computational load and improving inference speed.
[0074] The backbone network is used for feature extraction of images. It consists of modules such as convolutional layers, pooling layers, and activation functions, mainly including CBS, C3, and SPPF modules. The CBS module encapsulates convolution (Conv), batch normalization (BN), and Swish activation functions.
[0075] The Neck feature fusion network consists of Feature Pyramid Networks (FPN) and Path Aggregation Network (PANet).
[0076] The Head section is the decoding phase, comprising three parts: positive and negative sample selection, loss function calculation, and Non-Maximum Suppression (NMS) processing. During training, the YOLOv5 network model generates numerous predicted bounding boxes. To improve model learning efficiency, high-quality positive and negative samples are selected from all generated predicted boxes to calculate the loss. Positive samples are those where the Intersection over Union (IOU) between the predicted bounding box and the ground truth bounding box is greater than a certain threshold, while negative samples are those where the IOU is less than a certain threshold. The model calculates class loss, confidence loss, angle loss, and bounding box localization loss for positive samples, and only confidence loss for negative samples. The loss function consists of class loss, confidence loss, and bounding box localization loss. In the prediction phase, the NMS algorithm first classifies the generated predicted boxes according to their class. Then, it sorts all predicted boxes for a single class according to their classification confidence score from highest to lowest, selecting the predicted box A with the highest confidence score and storing it in the output list. It then iterates through all predicted boxes for a single class and performs an Intersection over Union (IoU) calculation with A, discarding predicted boxes with scores higher than the set threshold and retaining those with scores lower than the threshold. Repeat the above steps until the NMS processing for a single class is complete. When the predicted bounding boxes for all object classes are empty, output the predicted bounding boxes that meet the conditions stored in the memory, and end the NMS algorithm.
[0077] YOLOv5 has five versions, with the networks ranging from shallow to deep: YOLOv5n, YOLOv5s, YOLOv5m, YOLOv5l, and YOLOv5x. This example compares various models to ensure consistent network depth and width. Class parameters are configured via the rib.yaml file, and the training weights are provided in the official yolov5m.pt file. Training parameters are then set according to the hardware configuration of the deep learning environment: an iteration cycle of 200, an initial learning rate of 0.01, a batch size of 8, and an image input size of 800. The loss functions of the five models at different network depths are compared and analyzed. The results show that in the early stages of training, the confidence loss, classification loss, and angle loss all exhibit a fluctuating decreasing trend. As the number of iterations increases, each curve converges successively. After convergence, the curves are clearly hierarchical, from top to bottom: YOLOv5n, YOLOv5s, YOLOv5m, YOLOv5l, and YOLOv5x. Figure 7 The changes in precision, recall, and mean precision of different models in the validation set were compared and analyzed (Table 3).
[0078] Table 3 Comparative Analysis of Evaluation Indicators for Five Different Object Detection Algorithms on the Validation Set
[0079]
[0080] The results show that as the network depth increases, the precision, recall, and mean accuracy also increase, and the mean accuracy of the five target detection models all reach over 97%.
[0081] 1.5 Evaluation of Model Accuracy and Detection Rate
[0082] This embodiment compares and analyzes the target detection accuracy of different models in the test set. The test results show that R-YOLOv5n and R-YOLOv5s have lower accuracy on the test set, while the accuracy of the three network models R-YOLOv5m, R-YOLOv5l, and R-YOLOv5x is all above 90% in the test set (Table 4).
[0083] Table 4 Comparative Analysis of Target Detection Accuracy and Detection Rate of Five Different Models in the Test Set
[0084]
[0085] Furthermore, the average detection time is positively correlated with network depth, with an average detection rate of 0.01-0.07 s / frame. Considering both model accuracy and detection rate, R-YOLOv5m can be used as an accurate detection model for the number of ribs in live pigs in pig breeding practices.
[0086] Example 4: Development of Software for Detecting the Number of Ribs in Live Pigs Based on X-ray Images
[0087] Based on the development of X-ray image classification models and rib counting target detection models, this invention develops a live pig rib detection software based on PySide2. This software uses Python as the programming language, version 3.9.16; it uses Qt Designer (PySide2 version) as the interface design software; and PyCharm as the software compiler, with Qt Designer installed in the PyTorch component library. This software enables accurate and rapid rib counting.
[0088] New users can register their own accounts using the keys provided by the developer. After registration, they can access the testing interface through the login screen. Users with existing accounts and passwords can change their passwords before logging into the software. The software login screen is shown below. Figure 8 As shown, users must enter the correct username and password to access the main testing interface. If either the username or password is entered incorrectly, such as... Figure 8 A pop-up window will appear prompting "Incorrect username or password," prompting the user to check their input. Only after confirming that the input is correct can the user be redirected to the main testing interface.
[0089] Figure 9The image shown is the main interface of the software, which is divided into three parts: image detection area, information input area, and information operation area. The image detection area consists of two list controls and one scroll control. Figure 10 The list control in the upper left corner is the folder import area. Clicking the "Import Data" button allows you to select image folders in batches to import X-ray images into the software. The import is successful when all image folders are displayed in the list control. Simultaneously, the ID of the current pig will be automatically displayed in the ID input box in the information entry area on the right. The current path of the data is displayed in the lower right corner of the main detection interface. Figure 9 Clicking on a folder will display thumbnails of all live pig X-ray images in that folder in the list control at the bottom left. The total number of individuals imported into the software and the number of images imported into the current folder will be displayed at the bottom of the detection interface. Selecting a folder and clicking the "Delete Data" button will remove that folder. The scroll bar on the right is the image display area; users can drag the scroll bar to focus on the main area of the X-ray image for easier observation. Clicking on the pig ID folder will display the first image in the folder by default. Clicking on any thumbnail will switch between X-ray images in the image display area.
[0090] The procedure for determining the number of ribs in a live pig involves using "Single Image Detection" and "Multiple Image Detection" buttons in the detection area. Clicking "Single Image Detection" first determines the current image type and outputs the pig's posture. If the posture is determined to be prone, the number of "left" targets predicted by the R-YOLOv5 network model represents the number of left ribs, and the number of "rib" targets represents the number of right ribs. If the posture is determined to be supine, the predicted number of "left" targets represents the number of right ribs, and the number of "rib" targets represents the number of left ribs. The sum of the predicted "left" and "rib" target counts is the total number of ribs, and the average is the total number of rib pairs. This information is automatically displayed in the image information field of the information input area. Clicking the "Multiple Image Detection" button performs detection regardless of image posture and ultimately displays the number of ribs on one side, the total number of ribs, and the average of the total number of rib pairs for that pig ID in the image information area.
[0091] Figure 11 The area shown is the phenotypic information entry area, consisting of two tabs: "Basic Information" and "Other Information." Following the database design described earlier, each tab has two information entry combo boxes. "Basic Information" contains a combo box for "Animal Information" and a combo box for "Image Information," while "Other Information" contains a combo box for "Company Information" and a combo box for "Measurement Information." Except for ID, image type, number of ribs on one side, total number of ribs, total number of rib pairs, and measurement time, which are automatically displayed, all other information must be manually entered by the user. Users can modify the automatically detected information.
[0092] Phenotypic information operation area, such as Figure 12As shown. After the user has finished entering the information for the pig, clicking the "Add" button will add the information to the table control and the database. The number of pigs whose information has been entered is displayed at the bottom of the detection interface. Double-clicking an item in the table allows modification. Clicking the row number on the left side of the table control selects a row of data, and clicking the "Delete" button will delete that row. Clicking the "Open" button imports the previous detection data, allowing you to continue entering pig phenotypic information. Clicking the "Save" button exports the entered phenotypic information to an Excel spreadsheet.
[0093] The specific embodiments described herein are merely illustrative of the spirit of the invention. Those skilled in the art to which this invention pertains may make various modifications or additions to the described specific embodiments or use similar methods to substitute them, without departing from the spirit of the invention or exceeding the scope defined by the appended claims.
Claims
1. A precise, rapid, and intelligent detection system for the number of ribs in live pigs based on an X-ray machine system, characterized in that... It includes an X-ray machine system, a detection module, a storage module, and a display module. The detection module uses a precise, fast, and intelligent detection algorithm for counting live pig ribs to obtain the number of live pig ribs. The construction of the precise, fast, and intelligent detection algorithm for counting live pig ribs includes the following steps: S1. Fix piglets from birth to nursery stage, use X-ray machine system to collect live supine and prone chest X-ray images of pigs, and conduct pig dissection experiments to accurately determine the number of pig ribs phenotype; S2. The data volume is expanded by using single-sample data augmentation. The X-ray images are annotated and processed to create corresponding datasets according to the needs of the subsequent classification model and target detection model. S3. Develop a ResNet classification model for pig live X-ray images in supine and prone positions based on the corresponding dataset. S4. Develop an object detection model based on the YOLOv5 algorithm in machine learning using the relevant dataset; S5. Integrate and encapsulate the accurate classification model and the target detection model to obtain an accurate, fast and intelligent detection algorithm for the number of ribs in live pigs.
2. The system as described in claim 1, characterized in that, In S1, acquiring live supine and prone chest X-ray images of pigs also includes using piglets from birth to nursery stage, employing pig fixation devices, and adjusting the parameters of different types of X-ray machine systems to acquire supine and prone chest X-ray images.
3. The system as described in claim 1, characterized in that, In S2, data augmentation processing is performed on the chest X-ray image, including random small-amplitude rotation of the original image, random adjustment of contrast, and random addition of Gaussian noise. Then, the ribs are labeled on the X-ray image using the roLabelImg software.
4. The system as described in claim 1, characterized in that, in S3, the dataset is randomly divided into a training set, a validation set, and a test set, and a ResNet classification model for pig live X-ray images in supine and prone positions based on a convolutional neural network is constructed. During model training, the input image size is uniformly converted to 224*224, the learning rate is uniformly set to 0.0002, the batch size is uniformly set to 8, the number of iterations is set to 100, and the Adam optimizer is used during model training.
5. The system as described in claim 1, characterized in that, In S4, the dataset is randomly divided into training, validation, and test sets. A rib target detection model is constructed using the YOLOv5 series of machine learning algorithms. During model training, the input layer performs data preprocessing on the images, including Mosaic enhancement, adaptive anchor box calculation, and adaptive image scaling. The backbone network is used for feature extraction, consisting of convolutional layers, pooling layers, and activation function modules, mainly including CBS, C3, and SPPF modules. The CBS module encapsulates convolutional Conv, batch normalization (BN), and Swish activation functions. The feature fusion network Neck consists of the feature pyramid network FPN and the path enhancement network PANet. The head part includes three parts: positive and negative sample selection, loss function calculation, and non-maximum suppression (NMS) processing.
6. The system as described in claim 4 or 5, characterized in that, A rib target detection model is constructed based on the ResNet classification model and the YOLOv5 series algorithms. The model construction method also includes expanding the experimental pig population and adjusting parameters to optimize the classification and target detection models.
7. The system as described in claim 1, characterized in that... The method of using a precise, rapid, and intelligent algorithm for detecting the number of ribs in live pigs specifically involves: 1) Acquire live X-ray images of pigs; 2) The system uses a ResNet classification model to determine whether a live pig is in a supine or prone position; the number of ribs is detected in X-ray images of live pigs in supine or prone positions. 3) The system uses a rib target detection model to identify rib targets in live pigs: 4) The system identifies and counts the ribs of live pigs.
8. The system as described in claim 7, characterized in that, In step 2), the number of ribs is detected using X-ray images of the live pig in a prone position.
9. The system as described in claim 5, characterized in that, A rib target detection model was constructed using the R-YOLOv5m algorithm from machine learning.
10. The system as claimed in claim 1, characterized in that, The system is applied to the breeding practices of multi-ribbed livestock.