Development of a Low-Cost Livestock Sorting Information Management System Leveraging Deep Learning, AI, and IoT Technologies

. The implementation of effective livestock management methods is crucial to optimize agricultural operations. However, conventional livestock sorting and data management approaches encounter several obstacles regarding precision, labor requirements, and financial implications. The process exhibits inefficiency, increased labor costs, and an elevated risk of zoonotic infections. Housing livestock in extensive groups might intensify the transmission of diseases and complicate the surveillance and management of diseased animals. This study attempted to develop a Low-Cost Livestock Sorting Information Management System (LC-LSIMS) using a dataset enriched with crucial metrics and curated images collected over 24 months with the Internet of Things (IoT) and Artificial Intelligence (AI). The design of edge-cloud computing facilitates the redistribution of computational resources, leading to enhanced computational speed. The LC-LSIMS would have a predictive module to assist agricultural practitioners in safeguarding their crops during flood occurrences. This module will empower farmers to proactively anticipate natural phenomena, including floods, during intense rainfall. LC-LSIMS presents a multi-level design plan that facilitates attaining the specified goals. The findings obtained from the execution of the implemented system demonstrate a sorting accuracy of 91.47%, computational speed of 27.42 frames per second (fps), labor cost reduction of 50.84%, production efficiency improvement of 29.59%, and an average reduction in data input errors of 37.59%.


Introduction to Livestock and livestock sorting
Livestock farming, an integral component of worldwide agriculture, is a principal supplier of vital commodities like meat, milk, and wool [1].Given the rising global population trend, animal product demand is growing, emphasizing the crucial significance of effective livestock management.Livestock farming plays a vital role in the agricultural economy by contributing significantly [2].It supports livelihoods and poses issues related to accuracy, labor efficiency, and addressing rising concerns such as disease transmission.
The need for efficient Livestock Sorting becomes evident in light of these increasing requirements [3].The process of livestock sorting entails the systematic classification of animals according to several criteria, including weight, health condition, and productivity effectiveness.Accurate sorting techniques are of utmost importance to enhance agricultural operations, reduce labor expenses, and maintain the well-being of animals [4].Precisely categorizing animals is crucial in effectively controlling and containing diseases and mitigating infection transmission throughout livestock populations.The current sorting methods face significant obstacles [5].Conventional methodologies often provide inefficiencies, leading to elevated labor expenditures and an augmented susceptibility to zoonotic illnesses.Housing livestock in broad groups has been shown to increase the spread of diseases and create challenges in monitoring and controlling the health of affected animals.This results in financial losses and compromises the overall well-being of cattle.
To tackle these issues, advanced technologies such as Deep Learning [6], Artificial Intelligence (AI) [7], and the Internet of Things (IoT) [8] are being used to transform the field of Livestock Sorting.Deep Learning algorithms are capable of extracting significant insights from large datasets.AI plays a crucial role in enabling intelligent decision-making.The IoT allows continuous and real-time data collection, increasing livestock monitoring and management.The primary contributions are given below: • Deep Learning and AI Integration: The study skillfully combines AI and deep learning algorithms with the cattle sorting procedure.• Using IoT for Real-time Monitoring: The suggested approach overcomes the shortcomings of traditional techniques by using IoT for ongoing data collecting.• Functional Flood Prediction Module: The study presents a predictive module beyond conventional sorting procedures to anticipate natural events like floods proactively.The following sections are arranged in the given manner: The literature review in Section 2 addresses the state of research and understanding about cattle sorting, emphasizing gaps and difficulties in present approaches.The system architecture and design strategy using deep learning, AI, and IoT are introduced in Section 3 of the proposed Low-Cost Livestock Sorting Information Management System (LC-LSIMS).The findings from LC-LSIMS are presented in Section 4. The main conclusions, ramifications, and prospective directions for further study and advancements in inexpensive livestock sorting are outlined in section 5.

Literature Survey and Outcomes
This section encompasses a thorough analysis of prevailing scholarly investigations and methodology about the classification of cattle while also outlining the obstacles and deficiencies present in contemporary sorting systems.The information provides valuable insights into the current advancements in technology and methods.This serves as a foundation for the proposed plan by identifying areas that need improvement and showcasing innovative approaches.
Guo et al. ( 2023) compared bovine sex-sorted and non-sorted frozen-thawed semen for quality and antioxidant enzyme activity [9].The Sex-Sorted Frozen Semen (SSFS) approach used sophisticated sorting methods to differentiate sex-sorted from non-sorted semen.The SSFS approach accurately identified and sorted sexes.Sex-sorted semen had 15% higher anti-oxidative enzyme activity than non-sorted semen, suggesting oxidative stress resistance.The eastern Pyrenees Late Iron Age site of Baltarga was studied using an integrated biogeoarchaeological method for livestock management by Colominas et al. (2023) [11].Integrated Bio-Archaeological Livestock Management (IBA-LM) used bioarchaeological and geoarchaeological techniques to recreate livestock management methods.The approach included faunal, stable isotope, and soil analysis.Si et al. (2022) utilized IoT to monitor farms and manage cattle [12].Farmland Monitoring with IoT (FMIoT) collected and managed real-time data using IoT technology.Continuous environmental and livestock monitoring was part of the technique.FMIoT increased agricultural output, reduced water consumption by 25%, and improved animal health by 30%, proving its efficiency and sustainability.Szulc et al. (2022) assessed microbiological and toxicological hazards in a waste sorting factory, stressing respiratory protection [13].Microbiological and Toxicological Hazard Assessment (MTHA) assessed waste sorting environment microbiological and toxicological concerns.The MTHA quantified microbial burden and identified hazardous chemicals.The trial results showed a 15% decrease in workers' respiratory difficulties once respiratory protection was implemented.Cheng et al. (2022) enhanced Fuzzy Sorting and Bi-level Programming (FSBP) for synergetic agricultural water resource optimization in Fujian Province, China [18].They optimized agricultural water resources using fuzzy sorting and bi-level programming in their FSBP approach.Water allocation and resource use were more precise using the technique.Synergetic optimization using the FSBP algorithm resulted in a 20% improvement in water usage efficiency and a 15% decrease in water waste.Westgate et al. (2022) examined enhanced farm dam management on plant cover, water quality, and macroinvertebrate biodiversity [15].Improved Management of Farm Dams (IMDM) stressed strategic dam management.Targeted vegetation restoration and water quality monitoring were IMDM elements.Plant cover increased by 30%, water quality improved by 25%, and macroinvertebrate biodiversity increased by 20%.
Horvath et al. (2021) examined dairy calf dietary selection and feed sorting of mixed diets with forage presentation and molasses-based liquid feed.The Forage and Molasses-based Diet Sorting Study (FMDSS) evaluated dairy calves' food preferences and sorting habits.FMDSS uses controlled forage presentation and liquid feed augmentation.Feed sorting decreased by 10%, improving dairy calves' diet choices and palatability [14].
The literature review identified many difficulties associated with current cattle sorting approaches, such as inaccurate classification, inefficiencies in labor use, and increased risks of disease transmission.The problems highlight the imperative need for creative strategies to tackle deficiencies and improve the overall efficiency of livestock management [17].

Proposed Low-Cost Livestock Sorting Information Management System
LC-LSIMS incorporates cutting-edge technologies such as Deep Learning, AI, and the IoT.The research provides an overview of the system's architecture, including data enrichment, edge-cloud computing, and a predictive module designed for flood prediction.The primary objective of LC-LSIMS is to get a high level of accuracy in sorting while also optimizing labor management costs and improving overall production effectiveness.This is supported by substantial enhancements seen in trial results.This section highlights the significant potential of LC-LSIMS in bringing about dramatic changes in cattle sorting techniques.

System model
The system under consideration has two distinct components, namely hardware and software.The hardware parts involve weight, image-detecting devices, and the requisite physical pieces, such as flexible constraints and sorting doors.The program incorporates the processes of picture capture, recognition, and sorting, which are executed via deep-learning techniques.Figure 1 displays a schematic representation of the system's structure.

Fig. 1. Workflow of the proposed livestock sorting system
The livestock are introduced into the sorting process in the porcine animals after their presence in the mixing pens.The animals are discerned and categorized inside the appropriate pens using the entrance, verification, and sorting components integrated into the sorter.This research describes the procedures involved in sorting, modular gadgets, and hardware design.Modular pathways have been developed to foster innovation in the context of conventional sorting systems.Combined with a sorter, these channels provide a sealed sorting environment that enables automated sorting processes.The method has three distinct parts: detection and entrance, collecting data, and filtering and leaving.Every component is created using a modular approach.During the first stages of detection and access, the system employs an infrared transmitter positioned in front of the gate that opens to identify the presence of pigs.The entrance is automatically extended to allow them admission.Once the weighing system determines the presence of a pig inside the system, it proceeds to shut the gate.The dataacquiring system includes collecting several types of data, including but not limited to the weight of pigs and visual photographs.The experiment included creating a modular assembly mechanism and constructing a short-distance star communicating system.A centralized control module governs the system, whereas each submodule has an autonomous control unit for circuit management inside its module.The combination of many submodules results in the formation of a sorting section, which comprises a minimum of one intake component, one detection component, and multiple outlet components.Connectors composed of pliable materials are utilized for building pig conduits equipped with acoustic and visual apparatuses, facilitating the deterrence of pigs and minimizing human involvement.These elements are integrated into the pigsty via malleable and rigid materials.Pigs possess the innate ability to autonomously process classifying when prompted by auditory and visual stimuli while navigating via designated pathways.
The sorting procedure is partitioned into two distinct components.Initially, health monitoring was conducted using the gathered pig images.The process involves using a preexisting binary categorization system and decision-level fusing to integrate weight and visual data.This enables determining whether a pig is exhibiting abnormal or ill behavior.The identified sick pigs are segregated into isolation cages, where professionals thoroughly examine and provide appropriate treatment.
The accuracy of the test is enhanced, and the final target categorization and identification results are obtained by decision fusion by combining the image neural network analysis and weight-based categorization outcomes.The pig's identification (ID) and categorization are determined by image analysis, while its weight is assessed using a weighing apparatus.The sorting process involves integrating the pig's past data with the newly acquired data based on its unique ID and evaluating its development state and relative growth level within the grouping.The process of recognition of images is used to determine the presence of any potential diseases in the pig phenotype.If a pig is identified as potentially sick or exhibiting irregular weight, it is assigned to the designated pen for diseased animals.

Identification and Classification System
This study employs object identification and clustering techniques for livestock surveillance.Many cow photos must be gathered to create comprehensive image collections.Approximately 1000 photos of cows were acquired from the agricultural facilities in East Malaysia.The aerial photographs were obtained using an Unmanned Aerial Vehicle (UAV) positioned at an approximate altitude of 60 meters above ground level.Each photo exhibits many bovine subjects, as seen from an aerial perspective.Using an object identification model is limited to detecting and identifying cows alone.A significant quantity of bovine imagery is necessary.

Data extraction
During this step, the output data obtained from identifying objects is retrieved before being inputted into the clustering procedure.For grouping, every box with boundaries is transformed into a dot.Getting the center coordinates for every package with borders is necessary to change the bounding box onto a bubble.Initially, the central dimensions of the resultant data obtained from the identification of objects are retrieved and then saved in a Comma-Separated Values (CSV) file.The procedure for recording the center values of the boundaries into a CSV file is implemented using the Python programming language.Column A indicates the values of the x-axis locations, whereas column B reflects the y-axis values.Each row inside the dataset represents the central coordinate of a box with boundaries.

Data clustering
Data clustering is a fundamental procedure involving dividing data collection into smaller, more manageable groupings.Pattern identification, data mining, and recognizing outliers are frequent applications in which it is often used.There are several clustering techniques, such as partitioned grouping, density-based grouping, model-based grouping, and clustering based on hierarchy.In this study, two grouping methods, namely a partitioned clustering approach and a density-based grouping technique, have been chosen.The popularity of partitioning and density-based grouping is attributed to their straightforward and fast data processing methods, which effectively identify cluster structures and exceptions.The observed trends of the findings are compared and analyzed in the context of partitioned and density-based grouping.There are several forms of partitioning grouping methods, as well as density-based grouping methods.This study has opted to use the K-means grouping strategy for partitioned grouping and the technique for density-based collection.The data grouping procedure consists of three distinct processes.i.
The input information from a text file should be used to generate a scatter diagram.ii.
Selecting an appropriate grouping method.iii.
Choosing an appropriate separation measure for the selected grouping procedure.The calculation in grouping is contingent upon the specific distance measurement used.Two distance indicators are employed to evaluate the impact of various distance measures on detecting herds and anomalies.The two distance measures used in this study are Euclidean and Manhattan lengths.The method for determining Euclidean size is presented in Equation (1).
Let  1 and  2 be the location of point A and point B along the X-axis.The variables  1 and  2 denote the Y-axis positions of point A and point B. Equation ( 2) is used for Manhattan length, which is considered more straightforward than Euclidean length due to its reliance on the total differences among the two locations on a Cartesian plane.
The variables  1 ,  2 ,  1 , and  2 have been previously specified in Equation ( 1).The adoption of Manhattan length in the Cartesian plane is attributed to its ability to establish a grid system that facilitates human calculation.The execution of a semantic system involves the sequential integration of modules, as seen by the blue line in Figure 3. LC-LSIMS is the workflow-control center for coordinating deep learning components and loT gadgets.The process of deep-net assembly is achieved via the transmission of messages.The operational procedure of the intelligent cattle semantic monitoring system is delineated as follows.
Step 1: The data collection performs regular intervals of swine picture collection and, after that, transfers these to the component.
Step 2: The Image Inspection Framework (IIF) is used to selectively exclude photographs that do not meet the specific semantic requirements of an application.Photos of pigs in a nonstanding position would be filtered out.
Step 3: The data transmitter sends pictures that meet the requirements of application semantics to the LC-LSIMS system in the cloud over the Internet.This transmission allows additional semantic extract to be performed.
Step 4: The pig segmentation component utilizes the pixel set  = �  ,   � to segment the form of a pig.This segmentation process enables the gathering of coarse-level terminology, allowing for the separation of the pig from its backdrop.
Step 5: The fine-level semantics separation assesses the picture regarding standing and positioning interpretations.The module for feature recognition is designed to identify the reference point, namely the anus of pigs, which is indicated as (  ,   ).
Step 6: The rump breadth estimator quantifies the pixel count inside the rump area and converts this to a physical measurement in centimeters, employing the camera specifications.
Step 7: The depiction of the pigs and all derived semantic information is securely saved inside a cloud-based database, enabling convenient and remote access to animal health data at any given time and location.
This section presents an overview of the LC-LSIMS, which integrates Deep Learning, AI, and IoT technology.LC-LSIMS is a system that improves overall production efficiency by prioritizing accurate sorting and cost-effective labor management.The novel technology substantially improves testing results, underscoring its capacity to transform and streamline animal categorization methodologies.

Simulation Analysis and Outcomes
The experimental configuration for the proposed study entails incorporating Deep Learning and AI into the LC-LSIMS design using the programming languages Python and TensorFlow.The minimal system requirements for this task include a computer with a RAM capacity of at least 8GB, a contemporary Graphics Processing Unit (GPU) to facilitate practical model training and a Python environment equipped with the necessary libraries.The dataset consists of a collection of enhanced data over 24 months.This data includes essential metrics and carefully selected photos gathered from cattle agricultural situations using IoT devices.The dataset has been subjected to preprocessing techniques to ensure its compatibility with the methods suggested.80% of the dataset has been allocated for training, while the remaining 20% has been reserved for testing throughout the simulations.The LC-LSIMS approach demonstrates favorable outcomes across several criteria.The achieved sorting accuracy during training is 92.39%, and during testing is 90.55%.The computational speed during training is 27.68 fps, and during testing is 27.15 fps.The labor cost reduction during training is 51.75%, and during testing is 49.92%.The improvement in production efficiency during training is 30.33%, and during testing is 28.84%.There is a reduction in data input errors of 38.06% during training and 37.12% during testing.

Conclusion and Future Scope
Managing livestock is paramount in optimizing agricultural activities, substantially contributing to food production and the broader economy.Efficient livestock sorting is essential for successful management, as it is critical in safeguarding animal welfare, controlling disease spread, and optimizing agricultural operations.The Low-Cost Livestock Sorting Information Management System (LC-LSIMS) is a suggested solution that aims to overcome the limitations of conventional sorting techniques by using advanced technologies such as Deep Learning, AI, and the IoT.The LC-LSIMS system has been developed to improve the precision of sorting, increase computational efficiency, manage labor costs, enhance production effectiveness, and ensure the dependability of data input.The outcomes of the implemented system exhibit significant enhancements, as evidenced by the average Sorting Accuracy of 92.39% (training) and 90.55% (testing), Computational Speed of 27.68 frames per second (training) and 27.15 frames per second (testing), Labor Cost Reduction of 51.75% (training) and 49.92% (testing), Production Efficiency Improvement of 30.33% (training) and 28.84% (testing), and Reduction in Data Input Errors of 38.06% (training) and 37.12% (testing).The results of LC-LSIMS highlight its capacity to change cattle sorting methodologies significantly.These advantages lead to implementation of more sustainable and efficient livestock management strategies.
Obstacles still need to be overcome in this field.These issues include the ongoing need for the improvement and fine-tuning of algorithms, the resolution of possible technical constraints, and the assurance of the system's capacity to adapt to various livestock habitats.This study's future trajectory includes further enhancing LC-LSIMS, investigating other AI and IoT breakthroughs, and undertaking comprehensive field experiments to validate its applicability in real-world scenarios.Incorporating interfaces that are easy for users to navigate and possess the potential to scale effectively will play a crucial role in achieving universal acceptance across diverse agricultural environments.

,Fig. 2 .
Fig. 2. System overflow Figure 2 illustrates that among the dataset of 1000 cow photos utilized for object recognition, 800 pictures underwent pre-processing procedures before the training phase, while the remaining 200 pictures were reserved only for testing purposes.

3. 2 . 1
Data preprocessing Data pre-processing is crucial in preparing image datasets before their use in building Deep Convolutional Neural Network (DCNN) models.It is necessary to do picture scaling or cropping before inputting them into the DCNN model.The RGB pathways, namely Red, Green, and Blue, are consolidated into a single monochrome channel to expedite the training process of DCNN.The first pictures include an RGB color model and exhibit dimensions of 8688 × 5792 pixels.During the pre-processing step, the photographs undergo decolorization, resulting in a single grayscale stream.The pictures are shrunk to dimensions of 105 × 105 pixels.

,Fig. 4 .
Fig. 4. Sorting accuracy analysis of livestock managementThe results of sorting accuracy over iterations are shown in Figure4.The concept of Sorting Accuracy refers to the proportion of cattle that have been appropriately classified, expressed as a percentage.The computation involves dividing the count of accurately sorted instances by the overall count of cases and multiplying the result by 100.The mean outcomes for the training and testing phases show a progressive improvement in accuracy, culminating in values of 92.39% and 90.55%, respectively.The LC-LSIMS approach demonstrates enhanced accuracy in sorting, particularly during the testing phase, achieving a significant 91.86% accuracy at iteration 100.

Fig. 5 .
Fig. 5. Computational speed analysis of livestock managementFigure5presents the findings about the computational speed, measured in frames per second (fps), as a function of iterations.Computational speed refers to the rate at which

Fig. 6 .
Fig. 6. Labor cost reduction analysis of livestock managementThe results of labor cost reduction throughout iterations are shown in Figure6.Labor cost reduction refers to the proportional decrease in expenditures related to labor.The computation involves subtracting the lowered labor cost from the beginning cost, dividing the result by the initial price, and multiplying the quotient by 100.The mean training and testing data values exhibit a rising pattern, averaging 51.75% and 49.92%, respectively.The LC-LSIMS approach demonstrates a significant decrease in labor costs, accompanied by noteworthy enhancements, particularly during the training phase.

Fig. 8 .
Fig. 8. Reduction in data input error analysis of livestock managementThe outcomes of the reduction in data input errors throughout iterations are shown in Figure8.Reduction in Data entry mistakes refers to the proportional decrease of errors attributed to the data entry process.The computation involves subtracting the reduced mistakes from the starting errors, followed by division by the initial errors, and multiplication by 100.The observed data indicates a consistent upward trajectory in the average outcomes of training and testing, with mean values of 38.06% and 37.12%, respectively.The LC-LSIMS technique substantially decreases data input errors, resulting in noteworthy improvements, particularly during the training phase.The LC-LSIMS approach demonstrates favorable outcomes across several criteria.The achieved sorting accuracy during training is 92.39%, and during testing is 90.55%.The computational speed during training is 27.68 fps, and during testing is 27.15 fps.The labor cost reduction during training is 51.75%, and during testing is 49.92%.The improvement in production efficiency during training is 30.33%, and during testing is 28.84%.There is a reduction in data input errors of 38.06% during training and 37.12% during testing.