# Real-Time Farm Surveillance Using IoT and YOLOv8 for Animal Intrusion Detection
## 2 Methodology and Implementation
### Intrusion Detection
#### 2.1.1 Data Collection  
The data gathering procedure within the proposed system is critical because it serves as the basic bedrock for the construction and assessment of the deep learning models. A diverse approach to data collecting was employed in order to ensure the system's reliability.  
The value of leveraging varied datasets cannot be overemphasized, especially in the context of applications with a broad scope and complexity. It is critical to evaluate the deep learning models' performance over a range of situations in order to appropriately estimate their capabilities. As a result, three separate datasets were painstakingly built.  
The first dataset, which contains 580 photos, is critical to the model training process. This dataset combines images from two Kaggle datasets, one with animals and the other with people. This consolidation results in a full dataset suitable for training, testing, and assessment. This fusion employs 30 separate sets of animals, with 60 photos of each. A total of 60 photographs of people and 60 images of clear fields were also included to give a well-rounded training environment. Figure 4 presents sample images from the primary dataset.  
Figure 3: Architectural diagram of intrusion detection using an SFSS.  
To make deep learning model training easier, the first dataset was carefully divided into three unique categories: animals, people, and no_intrusion (indicating clean fields). This three-tiered separation enabled the supervised learning of the models, with 70% of the dataset designated for training and the remaining 30% for testing. A further segmentation of the training subset into a 3:1 ratio guarantees that 75% is used for training and 25% for validation, boosting the resilience of the models' training.  
The second dataset, which includes 62 photos, maintains the three-class paradigm while synthesizing a new dataset from several Kaggle sources. By combining multiple sources, this dataset adds another layer to the training and assessment process, widening the models' exposure to different data. Figure 5 presents sample images from the secondary dataset. Besides, Figure 6 shows sample images from real farm dataset.  
The third dataset features 100 precisely taken real-world agricultural photos sourced directly from local farm locations. These photographs were captured to intentionally  
Figure 4: Sample images from primary dataset.  
Figure 5: Sample images from secondary dataset.  
recreate authentic agricultural conditions, providing a key validation ground for testing the proposed Smart Farm Surveillance System (SFSS). By selecting photos that perfectly match the actual operational contexts in which the system will be deployed, we ensured a full assessment of the model's performance under genuine field conditions. This dataset marks a critical step in confirming the model's practical application, allowing researchers to examine the YOLOv8 model's detection skills in genuine agricultural settings with different terrain, illumination, and probable animal intrusion scenarios.  
These three rigorously managed datasets give complete insight into the performance of the deep learning models. They allow for thorough model testing, training, and assessment, enabling them to deal with a broad range of probable circumstances in the field.