Personnel tumble detection method based on Edifficient ViT improved YOLOv8s
By introducing EfficientViT into the YOLOv8s model, the calculation process is optimized, and the problem of low computing efficiency of the YOLO algorithm is solved, and more efficient image processing and object detection is achieved, which is suitable for real-time application scenarios.
Patent Information
- Application Number
- CN202311859257.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-30
- Publication Date
- 2024-12-13
AI Technical Summary
The YOLO algorithm is less computationally efficient when processing large-scale or complex image tasks and cannot meet the needs of some real-time processing applications, especially in environments with limited computing power.
EfficientViT was introduced in the YOLOv8s model, and by designing the sandwich layout module, the Overlap PatchEmbed layer, the EfficientViTSubsample layer and the cascading group attention module, the calculation process is optimized, the computing resource needs are reduced, and the computing efficiency is improved.
It significantly improves the processing speed and accuracy of the YOLO algorithm, reduces the demand for hardware resources, and enables it to operate effectively on devices with limited resources, and is suitable for various hardware environments and complex object detection tasks.
Smart Images

Figure CN119131831A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of computer vision, and in particular relates to a method for detecting a person falling down based on YOLOv8s improved by EifficientViT. Background Art
[0002] As an important safety application, fall detection can be applied to medical health, elderly care, public safety and other scenarios. Accurate and timely detection of fall events can provide a decision-making basis for first-time rescue and treatment. Among them, falls of the elderly are a serious problem. With the continuous growth of the proportion of the elderly population, the health and safety of the elderly have received more and more attention from the society. Due to the deterioration of physical functions and the decline of balance ability, the risk of falls of the elderly is much higher than that of other age groups. Falls may not only cause physical injuries such as fractures and internal bleeding, but also bring psychological shadows to the elderly, restrict their daily activities, and even affect their quality of life. Through continuous monitoring, not only can timely warnings be issued when the elderly fall, but also potential fall risks can be predicted based on their behavior patterns. For example, if signs such as unstable walking and shaking of the elderly are detected, an early warning can be issued to remind the elderly to pay attention, or notify their family members to assist. Once the elderly fall, the YOLOv8 system can issue a warning in the first time, so that family members or medical staff can rush to the scene in time to provide help to the elderly, greatly reducing the serious consequences caused by delayed treatment due to falls.
[0003] YOLO (You Only Look Once) is a classic target detection algorithm. Although it excels in real-time performance, simplicity and efficiency, multi-scale detection, global context information utilization, and multi-task learning, it has certain deficiencies in computational efficiency. In particular, when dealing with large-scale or complex image tasks, the YOLO algorithm has a poor response speed, which becomes a limiting factor in environments with limited computing power. In addition, for applications that require real-time processing (such as fall detection), the processing speed of the YOLO algorithm sometimes still cannot fully meet the requirements. Summary of the invention
[0004] In response to the technical problem that the above-mentioned original technology is insufficient in computational efficiency, this technical solution provides a person fall detection method based on EifficientViT to improve YOLOv8s. EifficientViT is added to the YOLO model, the calculation process is optimized, and the computing resources required for processing image tasks are reduced, thereby improving the overall computing efficiency; it can effectively solve the above-mentioned problems.
[0005] The present invention is achieved through the following technical solutions:
[0006] A method for detecting a person falling down based on improving YOLOv8s with EifficientViT, comprising the following steps:
[0007] Step 1: Create a data set;
[0008] Step 2: Label the data set and randomly divide it into training set, validation set, and test set according to the ratio of 8:2:1;
[0009] Step 3: Improve the YOLOv8s model and obtain the YOLOv8s detection model based on EifficientViT:
[0010] Step 3.1: Design a sandwich layout block to build the YOLOv8s model, replace the main part of YOLOv8s with the sandwich module, and improve the main part of the YOLOv8s model; including the following steps:
[0011] Step 311: Set the first layer of the sandwich layout module to be the FFN layer. The FFN layer usually includes two linear transformations and one nonlinear activation function; its basic structure is expressed as:
[0012] FFN(x)=W2·ReLU(W1·x+b1)+b2
[0013] Where: x is the input vector; W1 and W2 are weight matrices; b1 and b2 are bias terms; ReLU is a nonlinear activation function;
[0014] Step 312: Set the second layer of the sandwich layout module to the Token Interaction layer, which is the self-attention mechanism in the sandwich layout module; its core idea is to assign a weight to each token in the sequence, and this weight is related to the information of all other tokens, so that each token can obtain the global information of the entire sequence; the calculation formula of the self-attention query, key Key and value Value is as follows:
[0015] Q=XW Q
[0016] K=XW K
[0017] V=XW V
[0018] Where: X is the input token embedding matrix; W Q , W K , W V are the weight matrices for query, key, and value, respectively;
[0019] Step 313: The sandwich layout module uses fewer memory-bound self-attention layers and more memory-efficient FFN layers for channel communication. Specifically, a single self-attention layer is applied For spatial mixing, this layer is sandwiched between the FFN layer The calculation formula is:
[0020]
[0021] Where: X i is the complete input feature of the i-th block, which converts X before and after a single self-attention layer i Convert to X with N FFN i+1 ;
[0022] Step 314: Introduce the EifficientViT module as the backbone layer of YOLOv8s;
[0023] The EifficientViT module consists of an Overlap PatchEmbed layer, two EfficientViTSubsample layers, and three sandwich modules;
[0024] Step 3.2: Add a multi-head self-attention mechanism layer between the FFN layers in the sandwich layout module, and use the cascaded group attention CGA module to improve computational efficiency;
[0025] Step 4: Train the YOLOv8s detection model based on EifficientViT based on the training set in step (2) to obtain the detection model;
[0026] Step 5: Input the test set of step (2) into the YOLOv8s detection model based on EifficientViT, output the detection results of whether the person falls or stands, and realize detection.
[0027] Furthermore, the Overlap PatchEmbed layer described in step 314 divides the input image into multiple overlapping small patches, and then converts the small patches into embedding vectors. The conversion of the small patches into the embedding vectors is achieved by a convolution operation, in which the convolution kernel size is the same as the patch size and the step size is smaller than the kernel size, thereby generating overlaps; the processed small patches can be further processed by the model.
[0028] Furthermore, the EfficientViT Subsample layer can further reduce the spatial resolution of the feature map; at the same time, downsampling can help the model more easily capture a wider range of information, rather than just local information.
[0029] Furthermore, the core idea of the cascaded group attention CGA module described in step 3.2 is to enhance the diversity of the input attention head features, reduce the computational redundancy of multi-head attention, and improve the model capacity by increasing the network depth; the cascaded group attention CGA module provides different segmentations of the complete features for each head, thereby explicitly decomposing the attention calculation between heads; it is expressed by the formula:
[0030]
[0031]
[0032] Where: X ij is the input feature X i The jth segmentation of i =[X i1 ,X i2 ,...,X ih ], 1≤j≤h; h is the total number of heads; and is a projection layer that maps the input feature segmentation into different subspaces, and It is a linear layer that projects the output features of the cascade back to the same dimension as the input.
[0033] Furthermore, the cascade mode of the cascaded group attention CGA module in step 3.2 is to calculate the attention map of each head, which is to add the output of each head to the subsequent head to gradually refine the features, which can be expressed as:
[0034] X” ij =X ij +X' i(j-1) ,1<j≤h
[0035] Where: When calculating self-attention, X” ij Replace X ij As the new input features of the j-th head.
[0036] Furthermore, the establishment of the data set described in step one is specifically operated as follows: collect images of people falling FallDetected and standing NoFallDetected, cut out and reverse the people but keep the background unchanged, expand and establish the data set; when cutting out and reverse the people, the person images need to be reversed left to right and up to down.
[0037] Furthermore, the data set is labeled as described in step 2. The specific operation method is as follows: Labelling is used to label the collected data set, and the labeling format is xml format, and then the xml is converted into txt file format; when labelling, Labelling is used to label two types of data, falling and standing; the xml is converted into txt file format, and the category, height, and width of the marking box are stored in the txt file.
[0038] Furthermore, the specific operation method of step 4 is:
[0039] Step 4.1: Set basic parameters for the YOLOv8s model improved based on EifficientViT;
[0040] Step 4.2: To ensure that the model is fully learned in the dataset, the number of training epochs is set to 1200;
[0041] Step 4.3: To prevent overfitting of the final test results, set the early stopping patience to 100;
[0042] Step 4.4: In order to better help the model understand the global information, the number of batch processing images is set to 16;
[0043] Step 4.5: The size of the input image imgsz is set to 640;
[0044] Step 4.6: Select the training device as NVIDIA GeForce RTX 3060 Laptop GPU;
[0045] Step 4.7: Set the number of workers when loading data to 0; the optimizer used in this training is SGD, an algorithm used to adjust model parameters to minimize the loss function;
[0046] Step 4.8: To print detailed output, set verbose to True.
[0047] Step 4.9: To ensure that the results of each run are certain under the same input and are not affected by randomness, set Deterministic to True;
[0048] Step 4.10: This training does not use regularization dropout and is set to 0;
[0049] Step 4.11: Set the initial learning rate lr0 for this training to 0.01.
[0050] Furthermore, the specific operation method of step five is:
[0051] Step 5.1: Input the test set data in step 2 into the improved YOLOv8s detection model based on EifficientViT that has been trained in step 4 for detection;
[0052] Step 5.2: After the detection is completed by the improved YOLOv8s detection model based on EifficientViT, the detected category information and the specific coordinates and confidence of the box are returned;
[0053] Step 5.3: Display the detection results in the test set.
[0054] Beneficial Effects
[0055] The present invention proposes a method for detecting human falls based on EifficientViT-improved YOLOv8s. Compared with the prior art, the method has the following beneficial effects:
[0056] (1) This technical solution adds EifficientViT to the YOLO model, optimizes the calculation process, reduces the computing resources required when processing image tasks, and thus improves the overall computing efficiency; while maintaining or even improving the performance of the YOLO algorithm, the demand for hardware resources (such as GPU and memory) is lower, so that the algorithm can run effectively on devices with limited resources. It not only improves the accuracy and adaptability of target detection, but also significantly reduces the model's demand for computing resources. For real-time application scenarios that require fast processing of image and video data, the addition of EifficientViT significantly improves the processing speed of the YOLO algorithm and enhances its real-time processing capabilities. At the same time, the applicability of EifficientViT is not limited to advanced GPUs, it is also applicable to ordinary consumer-grade hardware, greatly expanding the scope of application of the YOLO algorithm in various application scenarios. Integrating EifficientViT into the YOLO algorithm not only solves the shortcomings of the original technology in terms of computing efficiency, but also improves the applicability and real-time processing capabilities of the algorithm in various hardware environments. It is very suitable for application scenarios for the elderly that require fast and accurate target detection.
[0057] (2) The improved YOLOv8s detection model based on EifficientViT set up in this technical solution combines the Transformer architecture of EifficientViT and the efficient target detection mechanism of YOLOv8s, making the improved YOLOv8s more efficient in feature extraction. EifficientViT's Transformer model is known for its ability to handle long-distance dependencies, which enables the YOLOv8s model to capture the global context information of the image more quickly, and the model can understand the overall structure of the image more deeply, thereby improving the accuracy of target detection. And benefit from the flexibility of the Transformer model to the input image size and scale. The introduction of EifficientViT enables YOLOv8s to handle targets of different scales and scales more effectively, which is crucial for complex target detection tasks, especially in practical application scenarios with many changes.
[0058] (3) This technical solution benefits from the flexibility of EifficientViT. The improved YOLOv8s model can process input images of various sizes and has strong adaptability. While improving the adaptability of the model, it also enables it to maintain excellent performance in a variety of application environments.
[0059] (4) This technical solution uses EifficientViT as the backbone layer of YOLOv8s, which optimizes the model's computational process, reduces resource consumption, and reduces the demand for computing resources. This optimization is particularly important for running models on devices with limited resources, such as mobile devices or embedded systems, making object detection technology more popular and available. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Figure 1 This is the overall structure diagram of the YOLOv8s model based on EifficientViT in the present invention.
[0061] Figure 2 This is the overall structure diagram of the EifficientViT network model in the present invention.
[0062] Figure 3 This is a structural diagram of the Sandwich Layout block network model in the present invention.
[0063] Figure 4 It is a loss function diagram, precision diagram and recall rate diagram of the present invention.
[0064] Figure 5 It is a schematic diagram of the F1 curve of the present invention.
[0065] Figure 6It is a schematic diagram of the accuracy of the present invention.
[0066] Figure 7 It is a schematic diagram of accuracy regression of the present invention.
[0067] Figure 8a and Figure 8b Schematic diagram of fall detection according to the present invention.
[0068] Fig. 9 This is an example diagram for expanding the data set of the present invention. DETAILED DESCRIPTION
[0069] The following will be combined with the accompanying drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. The described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Under the premise of not departing from the design concept of the present invention, various modifications and improvements made by ordinary persons in the art to the technical solutions of the present invention should all fall within the protection scope of the present invention.
[0070] Embodiment 1:
[0071] like Figure 1 As shown, a method for detecting a person falling down based on improving YOLOv8s with EifficientViT includes the following steps:
[0072] Step 1: Establish a data set; collect images of people falling down and standing up, cut out the people and reverse them, but keep the background unchanged, expand and establish a data set; Fig. 9 shown.
[0073] In the preliminary stage of person fall detection, relevant data needs to be collected first. The first step is to collect a large number of images of people falling and standing from various sources. In order to ensure that the model can perform well in a variety of environments and perspectives, it is necessary to select a variety of images, including falling and standing scenes in different locations, times, and lighting conditions. After collecting the images, the images are further processed to completely cut out the main body of the person. The purpose of this step is to ensure that the posture and form of the person are preserved as detailed and accurately as possible during the data enhancement process. After cutting out the person image, the image is reversed so that the original image of the person falling or standing can be mirrored, so that the person's posture can be diversified without changing the background.
[0074] In this series of operations, the background remains unchanged. This design is to ensure that in the subsequent model training, the model can pay more attention to the posture and form of the person, rather than being overly affected by the background. Finally, all the processed images are integrated together to build a larger and more diverse dataset. Such a dataset not only includes the original falling and standing images, but also adds processed and enhanced images. In this way, the model is ensured to be exposed to more scenarios and changes during the learning process, thereby improving its generalization ability and detection accuracy.
[0075] Step 2: Label the data set. Use Labelling to label the collected data set in XML format, and then convert the XML into TXT file format; then randomly divide it into training set, validation set, and test set according to the ratio of 8:2:1.
[0076] In order for YOLOv8s to understand and effectively use the collected image data of people falling and standing up, these data need to be annotated in detail. Annotation is a process of inputting human knowledge into the machine to ensure that the model can accurately capture the desired information from the image.
[0077] Labelling, a specialized annotation tool, was selected to assist in this task. When using Labelling for image annotation, each person in the image is precisely circled and assigned a label, such as "falling" or "standing". In addition, the person's specific position, size, and other information are recorded so that the model can accurately locate the target in the image.
[0078] After the annotation is completed, the information will be saved as an XML file. XML is a commonly used data description and exchange format with a clear structure and easy reading for humans and machines. However, considering that some deep learning frameworks or algorithms may require a specific file format, the XML file needs to be converted to a more concise TXT file format. This can not only improve the efficiency of data processing, but also ensure data compatibility.
[0079] In order to train a robust and efficient model, the entire data set needs to be reasonably divided. The data is randomly divided into training set, validation set, and test set in a ratio of 8:2:1. The training set is used for the main learning process of the model, the validation set is used to adjust the parameters and structure of the model to ensure its performance on unknown data, and the test set is used to finally evaluate the accuracy and generalization ability of the model. Through such a division, it is ensured that the model has enough data for learning, and can effectively avoid overfitting, ensuring its performance in real scenarios.
[0080] Step 3: Improve the YOLOv8s model and obtain the YOLOv8s detection model based on EifficientViT:
[0081] Step 3.1: Design the Sandwich Layout block to build the YOLOv8s model, replace the backbone of YOLOv8s with the Sandwich Layout block, and improve the backbone of the YOLOv8s model; the model structure is as follows Figures 1 to 3 As shown. The steps include:
[0082] Step 311: Set the first layer of the sandwich layout module to be the FFN layer. The FFN layer usually includes two linear transformations and one nonlinear activation function; its basic structure is expressed as:
[0083] FFN(x)=W2·ReLU(W1·x+b1)+b2
[0084] Where: x is the input vector; W1 and W2 are weight matrices; b1 and b2 are bias terms; ReLU is the nonlinear activation function.
[0085] Step 312: Set the second layer of the sandwich layout module to the Token Interaction layer, which is the self-attention mechanism in the sandwich layout module; its core idea is to assign a weight to each token in the sequence, and this weight is related to the information of all other tokens, so that each token can obtain the global information of the entire sequence; the calculation query (Query), key (Key) and value (Value) formula of self-attention are as follows:
[0086] Q=XW Q
[0087] K=XW K
[0088] V=XW V
[0089] Where: X is the input token embedding matrix; W Q , W K , W V are the weight matrices for query, key, and value, respectively.
[0090] Step 313: The sandwich layout module uses fewer memory-bound self-attention layers and more memory-efficient FFN layers for channel communication. Specifically, a single self-attention layer is applied For spatial mixing, this layer is sandwiched between the FFN layer The calculation formula is:
[0091]
[0092] Where: X i is the complete input feature of the i-th block, which converts X before and after a single self-attention layer i Convert to X with N FFN i+1 .
[0093] Step 314: Introduce the EifficientViT module as the backbone layer of YOLOv8s;
[0094] The EifficientViT module consists of an Overlap PatchEmbed layer, two EfficientViTSubsample layers and three sandwich modules.
[0095] The Overlap PatchEmbed layer is responsible for splitting the input image into multiple overlapping patches, which are then converted into embedding vectors so that they can be further processed by the model. This embedding is achieved using a convolution operation where the kernel size is the same as the patch size and the stride is smaller than the kernel size, resulting in overlap. The EfficientViTSubsample layer is used to further reduce the spatial resolution of the feature map. Downsampling can help the model more easily capture a wider range of information, rather than just local information.
[0096] Step 3.2: Add a Multi-Head Self-Attention layer between the Feed Forward Network layers in the Sandwich Layout module, and use the Cascaded Group Attention module to improve computational efficiency.
[0097] Redundancy is a serious problem in MHSA, which leads to computational inefficiency. Inspired by group convolution in efficient CNNs, a new attention module for visual transformers, called Cascaded Group Attention (CGA), is proposed. The core idea is to enhance the diversity of features of the input attention heads. The CGA module not only reduces the computational redundancy of multi-head attention, but also improves the model capacity by increasing the network depth. It provides different splits of the complete features for each head, thereby explicitly decomposing the attention computation between heads. Formally, this attention can be formulated as:
[0098]
[0099]
[0100] Where: X ijis the input feature X i The jth segmentation of i =[X i1 ,X i2 ,...,X ih ], 1≤j≤h; h is the total number of heads; and is a projection layer that maps the input feature segmentation into different subspaces, and It is a linear layer that projects the output features of the cascade back to the same dimension as the input.
[0101] The attention map of each head is calculated in a cascaded manner, which adds the output of each head to the subsequent head to gradually refine the feature representation:
[0102] X” ij =X ij +X' i(j-1) ,1<j≤h
[0103] Where: When calculating self-attention, X” ij Replace X ij As the new input features of the j-th head.
[0104] Step 4: Train the YOLOv8s detection model based on EifficientViT based on the training set in step (2) to obtain the detection model;
[0105] Step 4.1: Basic parameter configuration of the model. In order to make full use of the characteristics of EifficientViT and the structural advantages of YOLOv8s, a series of basic parameter configurations are first performed for the model.
[0106] Step 4.2: Number of training rounds, in order to ensure that the model can fully learn in the data set, the number of training rounds (epochs) is set to 1200. Such a round number setting can ensure that the model has learned and updated a large number of samples enough times.
[0107] Step 4.3: Early stopping setting. To prevent the model from overfitting during training, an early stopping (patience) strategy was adopted, and its threshold was set to 100. Experiments showed that the performance of the model did not improve significantly between rounds 443 and 543. Therefore, according to the early stopping strategy, the model stopped training at round 543.
[0108] Step 4.4: Batch processing, in order to better help the model capture and understand global information during the learning process, the number of batch processing images (batch) is set to 16. This setting can not only increase the training speed, but also ensure that the data in each batch is sufficiently diverse.
[0109] Step 4.5: Input image size. In order to adapt to the input requirements of the model and ensure that the image information is not distorted, the size of the input image (imgsz) is uniformly set to 640.
[0110] Step 4.6: Training equipment. During the model training process, the NVIDIA GeForce RTX 3060 Laptop GPU graphics card was selected as the main computing device to ensure the speed and stability of training.
[0111] Step 4.7: Data loading and optimizer selection,During the data loading stage, set the number of workers to 0 to ensure the stability of data loading.,In addition, the optimizer used in this training is SGD, which is a classic algorithm for adjusting model parameters to minimize the loss function.
[0112] Step 4.8: Detailed output. To get more detailed information and feedback during the training process, set the verbose parameter to True.
[0113] Step 4.9: Result determinism. To ensure that the model gets stable and deterministic results each time it runs under the same input data and is not affected by random factors, set the Deterministic parameter to True.
[0114] Step 4.10: Regularization. In this training, it was decided not to adopt the regularization strategy, so the dropout value was set to 0.
[0115] Step 4.11: Initial learning rate. Based on previous experience and experimental results, in order to ensure that the model is neither too fast nor too slow during the learning process, the initial learning rate (lr0) of this training is set to 0.01.
[0116] Step 5: Input the test set of step (2) into the YOLOv8s detection model based on EifficientViT, output the detection results of whether the person falls or stands, and realize detection.
[0117] After completing the training of the YOLOv8s model based on EifficientViT, we entered the testing phase of the model. The main purpose of the testing phase is to verify the performance of the model on unknown data and provide a reliable reference for deployment in practical applications. First, the test set separated from the overall data set was used for this verification. These test set data have not been touched by the model before, so they can well simulate the working state of the model in real scenes. Each image in the test set is input into the YOLOv8s model based on EifficientViT. Considering the characteristics of EifficientViT, the model can effectively process a large amount of information in the image and extract key features from it, and then YOLOv8s performs target detection. After analyzing each image, the model will output the detection results. These results include not only the detected target category, that is, "person falling" or "standing", but also the specific location, size, and confidence of each target in the image. On the detected image, the area where the person falls or stands, as identified by the model, will be marked with a rectangular frame of a specific color, and the corresponding category and confidence level will be annotated next to it to intuitively display the detection results of the model.
[0118] Diagnosis results such as Figure 4 , Figure 5 , Figure 6 , Figure 7 , Figure 8a , Figure 8b and Fig. 9 shown. Figure 4 A total of three loss curves are given: accuracy, mAP@50, and mAP@95. Figure 5 is the F1 curve graph, Figure 6 is the accuracy diagram of the present invention, Figure 7 This is the accuracy regression diagram of the present invention.
[0119] Positioning loss (box_loss): The error between the predicted box and the calibrated box (GIoU). The smaller the error, the more accurate the positioning.
[0120]
[0121] Where: IoU represents the intersection over union of the predicted box and the calibrated box; C represents the area of the circumscribed rectangle of the predicted box and the calibrated box; U represents the area of the union of the predicted box and the calibrated box.
[0122] Confidence loss (obj_loss): Calculates the confidence of the network. The smaller the confidence, the more accurate the ability to judge as a target.
[0123] obj_loss=-(y true ·log(y pred )+(1-ytrue )·log(1-y pred ))
[0124] Where: y_true indicates whether the calibration box contains the target; y_pred indicates the confidence prediction value of the model.
[0125] Classification loss (cls_loss): Calculates whether the anchor box and the corresponding calibration classification are correct. The smaller the anchor box, the more accurate the classification.
[0126] cls_loss=-∑(y true ·log(y pred ))
[0127] Where: y_true represents the true category of the calibration box; y_pred represents the category prediction probability distribution of the model.
[0128] Precision:
[0129]
[0130] Where: TP (True Positive) is the true positive example, that is, the number of positive categories correctly predicted as positive categories; FP (False Positive) is the false positive example, that is, the number of negative categories incorrectly predicted as positive categories.
[0131] Recall: The accuracy of true positives, that is, how many positive samples were found. Recall describes how many true positive examples in the test set were picked out by the binary classifier from the perspective of real results, that is, how many true positive examples were recalled by the binary classifier.
[0132] F1 Score: It is the harmonic mean of precision and recall, and can be regarded as a balance between precision and recall. When the F1 value is high, it means that the model has achieved good results in both precision and recall.
[0133]
[0134] mAP: The area enclosed by using Precision and Recall as the two axes. m represents the average. The number behind it represents the threshold for determining IoU as a positive or negative sample. 0.5:0.95 means taking the average of the thresholds of 0.5:0.05:0.95.
[0135] The algorithm of this embodiment is compared with the traditional YOLOv8s algorithm, as shown in Table 1.
[0136] Table 1
[0137] algorithm Model size mAP@50% <![CDATA[R ecall %]]> YOLOv8s 42.9M 80.12 74.48 The algorithm of this embodiment 16.7M 87.51 80.07
[0138] It can be clearly seen from the table that the algorithm of this embodiment is significantly better than the traditional YOLOv8s in terms of model size and accuracy. Especially in terms of model size, the algorithm of this embodiment is lightweight and reduces FLOPS to a large extent, which means that they can perform forward propagation faster, thereby achieving fast target detection; lightweight models are more suitable for deployment on various edge devices, which means that the algorithm of this embodiment can be deployed in home monitoring, providing technical support for preventing falls of the elderly, which has strong practical significance.
[0139] The above embodiments are only for illustrating the technical concept and features of the present invention, and their purpose is to enable people familiar with the technology to understand the content of the present invention and implement it accordingly, and they cannot be used to limit the protection scope of the present invention. Any equivalent transformation or modification made according to the spirit of the present invention should be included in the present invention.
Claims
1. A method for detecting falling persons based on EifficientViT-improved YOLOv8s, characterized in that: The following steps are involved: Step 1: Create a data set; Step 2: Label the data set and randomly divide it into training set, validation set, and test set according to the ratio of 8:2:1; Step 3: Improve the YOLOv8s model and obtain the YOLOv8s detection model based on EifficientViT: Step 3.1: Design the SandwichLayoutblock to build the YOLOv8s model, replace the main part of YOLOv8s with the Sandwichblock, and improve the YOLOv8s model main part; including step: Step 311: Set the first layer of the sandwich layout module to be the FFN layer. The FFN layer usually includes two linear transformations and a nonlinear activation function; its basic structure is expressed as: FFN(x)=W2·ReLU(W1·x+b1)+b2 Where: x is the input vector; W1 and W2 are weight matrices; b1 and b2 are bias terms; ReLU is a nonlinear activation function; Step 312: Set the second layer of the sandwich layout module to the TokenInteraction layer, which is the self-attention mechanism in the sandwich layout module; its core idea is to assign a weight to each token in the sequence, and this weight is related to the information of all other tokens, so that each token can obtain the global information of the entire sequence; the calculation formula of self-attention query, key Key and value Value is as follows: Q=XW Q K=XW K V=XW V Where: X is the input token embedding matrix; W Q , W K , W V are the weight matrices for query, key, and value, respectively; Step 313: The sandwich layout module uses fewer memory-bound self-attention layers and more memory-efficient FFN layers for channel communication. Specifically, a single self-attention layer is applied For spatial mixing, this layer is sandwiched between the FFN layer The calculation formula is: Where: X i is the complete input feature of the i-th block, which converts X before and after a single self-attention layer i Convert to X with N FFN i+1 ; Step 314: Introduce the EifficientViT module as the backbone of YOLOv8s; The EifficientViT module consists of an OverlapPatchEmbed layer, two EfficientViTSubsample layers, and three sandwich modules; Step 3.2: Add a multi-head self-attention mechanism layer between the FFN layers in the sandwich layout module, and use the cascaded group attention CGA module to improve computational efficiency; Step 4: Train the YOLOv8s detection model based on EifficientViT based on the training set in step 2 to obtain the detection model; Step 5: Input the test set in step 2 into the YOLOv8s detection model based on EifficientViT, output the detection results of whether the person falls or stands, and realize detection.
2. According to claim 1, a method for detecting a person falling down based on EifficientViT-improved YOLOv8s is characterized in that: The OverlapPatchEmbed layer described in step 314 divides the input image into multiple overlapping small patches, and then converts the small patches into embedding vectors. The conversion of the small patches into the embedding vector is achieved by a convolution operation, in which the convolution kernel size is the same as the patch size and the step size is smaller than the kernel size, thereby generating overlaps; the processed small patches can be further processed by the model.
3. According to claim 1, a method for detecting a person falling down based on EifficientViT-improved YOLOv8s is characterized in that: The cascaded group attention CGA module described in step 3.2 provides different splits of the complete features for each head, thereby explicitly decomposing the attention calculation between heads; it is expressed as: X' i+1 =Concat[X' ij ] j=1:h W i P Where: X ij is the input feature X i The jth segmentation of i =[X i1 ,X i2 ,...,X ih ], 1≤j≤h; h is the total number of heads; and is a projection layer that maps the input feature segmentation into different subspaces, and W i P It is a linear layer that projects the output features of the cascade back to the same dimension as the input.
4. According to claim 3, a method for detecting a person falling down based on EifficientViT-improved YOLOv8s is characterized in that: The cascaded group attention CGA module described in step 3.2 is cascaded by calculating the attention map of each head and adding the output of each head to the subsequent head to gradually refine the features; The formula is: X” ij =X ij +X' i(j-1) ,1<j≤h Where: When calculating self-attention, X” ij Replace X ij As the new input features of the j-th head.
5. According to claim 1, a method for detecting a person falling down based on EifficientViT-improved YOLOv8s is characterized in that: The specific operation method of establishing the data set described in step 1 is as follows: collect images of people falling FallDetected and standing NoFallDetected, cut out and reverse the people but keep the background unchanged, expand and establish the data set; when cutting out and reverse the people, the person images need to be reversed left to right and up to down.
6. According to claim 1, a method for detecting a person falling down based on EifficientViT-improved YOLOv8s is characterized in that: The data set is labeled as described in step 2. The specific operation method is as follows: use Labelling to label the collected data set in xml format, and then convert the xml into txt file format; when labelling, use Labelling to label two types of data, fall and stand; convert the xml into txt file format, and store the category, height, and width of the marked box in the txt file.
7. According to claim 1, a method for detecting a person falling down based on EifficientViT-improved YOLOv8s, characterized in that: The specific operation method of step 4 is: Step 4.1: Set basic parameters for the YOLOv8s model improved based on EifficientViT; Step 4.2: Set the number of training epochs to 1200; Step 4.3: Set the early stopping patience to 100; Step 4.4: Set the number of batch processed images to 16; Step 4.5: Set the size of the input image imgsz to 640; Step 4.6: Select the training device as NVIDIA GeForce RTX 3060 Laptop GPU; Step 4.7: Set the number of workers when loading data to 0; the optimizer used for training is SGD, an algorithm used to adjust model parameters to minimize the loss function; Step 4.8: To print detailed output, set verbose to True. Step 4.9: To ensure that the results of each run are certain under the same input and are not affected by randomness, set Deterministic to True; Step 4.10: This training does not use regularization dropout and is set to 0; Step 4.11: Set the initial learning rate lr0 for this training to 0.
01.
8. According to claim 1, a method for detecting a person falling down based on EifficientViT-improved YOLOv8s is characterized in that: The specific operation method of step five is: Step 5.1: Input the test set data in step 2 into the improved YOLOv8s detection model based on EifficientViT that has been trained in step 4 for detection; Step 5.2: After the detection is completed by the improved YOLOv8s detection model based on EifficientViT, the detected category information and the specific coordinates and confidence of the box are returned; Step 5.3: Display the detection results in the test set.
