Door opening and closing state detection method and device

By using the combination of HWD downsampling layer, DySample upsampling layer and PASA attention network in the YOLO model, the gate switch state detection model is constructed, which solves the problem of low detection accuracy in the prior art and achieves higher detection accuracy.

CN120279475APending Publication Date: 2025-07-08SHENZHEN XUMI YUNTU SPACE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510188574.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-20
Publication Date
2025-07-08

AI Technical Summary

Technical Problem

In the prior art, the accuracy of door switch status detection is not high.

Method used

The HWD downsampling layer is used to replace the original downsampling layer of the YOLO model, the DySample upsampling layer replaces the original upsampling layer of the YOLO model, and a PASA attention network is added between the backbone network and the neck network of the YOLO model, a gate switch state detection model is built, and the model parameters are optimized through training images to improve detection accuracy.

Benefits of technology

The accuracy of door switch status detection is improved, and the problem of low detection accuracy in the prior art is solved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120279475A_ABST
    Figure CN120279475A_ABST
Patent Text Reader

Abstract

The invention provides a door opening and closing state detection method and device. The method comprises the steps that an original down-sampling layer of a YOLO model is replaced with an HWD down-sampling layer, an original up-sampling layer of the YOLO model is replaced with a DySample up-sampling layer, a PASA attention network is added between a backbone network and a neck network of the YOLO model, and an obtained new model serves as a door opening and closing state detection model; acquiring a training image, and detecting the opening and closing state of a door in the training image by using the door opening and closing state detection model to obtain a detection result; calculating the loss between the detection result and the label of the training image, and optimizing the model parameters of the door opening and closing state detection model according to the loss so as to complete the training of the door opening and closing state detection model; and providing a door opening and closing state detection service by using the trained door opening and closing state detection model. By adopting the technical means, the problem of low accuracy of detecting the opening and closing state of the door in the prior art is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of object detection, and particularly to a method and device for detecting the opening and closing state of a door. Background Art

[0002] Monitoring the opening and closing state of doors inside large buildings is beneficial to improving building safety, preventing illegal intrusion, ensuring the unobstructed emergency exits, enhancing fire safety, and assisting in personnel management. Currently, it is common to train existing models to detect the opening and closing state of doors. However, since the models have not been adaptively improved, the detection accuracy is not satisfactory. Summary of the Invention

[0003] In view of this, embodiments of this application provide a method, device, electronic device, and computer-readable storage medium for detecting the opening and closing state of a door to solve the problem of low accuracy in detecting the opening and closing state of a door in the prior art.

[0004] In the first aspect of the embodiments of this application, a method for detecting the opening and closing state of a door is provided, including: replacing the original downsampling layer of the YOLO model with an HWD downsampling layer, replacing the original upsampling layer of the YOLO model with a DySample upsampling layer, adding a PASA attention network between the backbone network and the neck network of the YOLO model, and using the obtained new model as a door opening and closing state detection model; obtaining training images, using the door opening and closing state detection model to detect the opening and closing state of the door in the training images to obtain detection results; calculating the loss between the detection results and the labels of the training images, and optimizing the model parameters of the door opening and closing state detection model according to the loss to complete the training of the door opening and closing state detection model; using the trained door opening and closing state detection model to provide door opening and closing state detection services.

[0005] In the second aspect of the embodiments of this application, a device for detecting the opening and closing state of a door is provided, including: a model improvement module configured to replace the original downsampling layer of the YOLO model with an HWD downsampling layer, replace the original upsampling layer of the YOLO model with a DySample upsampling layer, add a PASA attention network between the backbone network and the neck network of the YOLO model, and use the obtained new model as a door opening and closing state detection model; an acquisition module configured to obtain training images, use the door opening and closing state detection model to detect the opening and closing state of the door in the training images to obtain detection results; an optimization module configured to calculate the loss between the detection results and the labels of the training images, and optimize the model parameters of the door opening and closing state detection model according to the loss to complete the training of the door opening and closing state detection model; a detection module configured to use the trained door opening and closing state detection model to provide door opening and closing state detection services.

[0006] In a third aspect of the embodiments of the present application, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the above method are implemented.

[0007] In a fourth aspect of the embodiments of the present application, a computer-readable storage medium is provided. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.

[0008] The beneficial effects of the embodiments of the present application compared with the prior art are as follows: The original downsampling layer of the YOLO model is replaced by the HWD downsampling layer, and the original upsampling layer of the YOLO model is replaced by the DySample upsampling layer. A PASA attention network is added between the backbone network and the neck network of the YOLO model, and the obtained new model is used as the door switch state detection model; training images are obtained, and the door switch state detection model is used to detect the switch state of the door in the training images to obtain detection results; the loss between the detection results and the labels of the training images is calculated, and the model parameters of the door switch state detection model are optimized according to the loss to complete the training of the door switch state detection model; the trained door switch state detection model is used to provide door switch state detection services. By adopting the above technical means, the problem of low accuracy in detecting the door switch state in the prior art can be solved, and thus the accuracy of detecting the door switch state can be improved. Description of the Drawings

[0009] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0010] Figure 1 is a schematic flowchart of a method for detecting the door switch state provided by the embodiments of the present application;

[0011] Figure 2 is a schematic flowchart of a method for processing features by a PASA attention network provided by the embodiments of the present application;

[0012] Figure 3 is a schematic structural diagram of a device for detecting the door switch state provided by the embodiments of the present application;

[0013] Figure 4 is a schematic structural diagram of an electronic device provided by the embodiments of the present application. Detailed Embodiments

[0014] In the following description, specific details such as specific system architectures and technologies are proposed for the purpose of illustration rather than limitation, so as to thoroughly understand the embodiments of the present application. However, those skilled in the art should clearly understand that the present application can also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid unnecessary details from interfering with the description of the present application.

[0015] A method and device for detecting the door switch state according to an embodiment of the present application will be described in detail below with reference to the accompanying drawings.

[0016] Figure 1 It is a schematic flowchart of a method for detecting the door switch state provided by an embodiment of the present application. Figure 1 The method for detecting the door switch state can be executed by a computer or a server, or software on a computer or a server. As Figure 1 shown, the method for detecting the door switch state includes:

[0017] S101, replacing the original downsampling layer of the YOLO model with the HWD downsampling layer, replacing the original upsampling layer of the YOLO model with the DySample upsampling layer, and adding a PASA attention network between the backbone network and the neck network of the YOLO model, and using the obtained new model as the door switch state detection model;

[0018] S102, obtaining training images, and using the door switch state detection model to detect the switch state of the door in the training images to obtain detection results;

[0019] S103, calculating the loss between the detection results and the labels of the training images, and optimizing the model parameters of the door switch state detection model according to the loss to complete the training of the door switch state detection model;

[0020] S104, using the trained door switch state detection model to provide door switch state detection services.

[0021] The YOLO (You Only Look Once) model is a series of neural network architectures for real-time object detection. In the embodiments of this application, the YOLO model is improved to adapt to the scenario of door switch state detection and enhance the accuracy of door switch state detection. The YOLO model can be divided into three parts: the backbone network, the neck network, and the head network. The HWD (Haar Wavelent Downsampling) downsampling layer is used to reduce the spatial dimension of the input data, thereby reducing the computational complexity and accelerating the subsequent processing steps. HWD downsampling not only reduces the number of points but also improves the efficiency of feature extraction while maintaining important geometric information. DySample is a dynamic sampling method. The DySample upsampling layer aims to improve the resolution of images or other data by adaptively adjusting the sampling rate while maintaining important structural and detail information. This method can dynamically select the most suitable sampling strategy according to the characteristics of the input data, thus achieving a better balance between efficiency and effect.

[0022] The DySample upsampling has the following advantages:

[0023] 1. Adaptability: The DySample sampling can adaptively adjust the upsampling strategy according to the characteristics of the input data. This means that it can apply different upsampling methods in different regions to better capture the details and structure of the input data.

[0024] 2. Higher accuracy: Since DySample can make different processing decisions for different input data, it can usually provide higher reconstruction accuracy in complex scenarios. For regions with more details such as edges and textures, dynamic upsampling can select a more refined processing method to improve the quality of the feature map.

[0025] 3. Reducing over-smoothing: DySample avoids the loss of details or over-smoothing of the feature map and improves the accuracy of the algorithm.

[0026] In the embodiments of the present application, the original downsampling layer of the YOLO model is replaced with an HWD downsampling layer, and the original upsampling layer of the YOLO model is replaced with a DySample upsampling layer. A PASA attention network is added between the backbone network and the neck network of the YOLO model, and the obtained new model is used as a door switch state detection model. The PASA (Partial Agent Self-Attention) attention network combines the core idea of the self-attention mechanism with a localized or selective attention strategy, aiming to improve the perception, decision-making, and collaboration capabilities of agents in complex environments. Compared with traditional global self-attention models, Partial Agent Self-Attention pays more attention to focusing on specific regions or relevant objects, thus achieving more efficient information processing and better utilization of computing resources.

[0027] According to the technical solution provided by the embodiments of the present application, the original downsampling layer of the YOLO model is replaced with an HWD downsampling layer, and the original upsampling layer of the YOLO model is replaced with a DySample upsampling layer. A PASA attention network is added between the backbone network and the neck network of the YOLO model, and the obtained new model is used as a door switch state detection model; training images are obtained, and the door switch state detection model is used to detect the switch state of the door in the training images to obtain a detection result; the loss between the detection result and the label of the training images is calculated, and the model parameters of the door switch state detection model are optimized based on the loss to complete the training of the door switch state detection model; the trained door switch state detection model is used to provide a door switch state detection service. By adopting the above technical means, the problem of low accuracy in detecting the door switch state in the prior art can be solved, and thus the accuracy of detecting the door switch state can be improved.

[0028] In one embodiment, using the door switch state detection model to detect the switch state of the door in the training images to obtain a detection result includes: inputting the training images into the door switch state detection model, and inside the door switch state detection model: the training images are processed sequentially through the backbone network, the neck network, and the head network to obtain the detection result.

[0029] Further, replacing the original downsampling layer of the YOLO model with an HWD downsampling layer includes: replacing the downsampling layer of the last three layers of the backbone network of the YOLO model with an HWD downsampling layer; replacing all the downsampling layers in the neck network of the YOLO model with an HWD downsampling layer.

[0030] When replacing the downsampling layer of the last three layers of the backbone network of the YOLO model with an HWD downsampling layer, the other downsampling layers in the backbone network remain unchanged.

[0031] Furthermore, before adding the PASA attention network between the backbone network and the neck network of the YOLO model, the method further includes: constructing a basic network using a convolutional layer, a normalization layer, and an activation layer; constructing a first network using the basic network and a segmentation network; constructing a second network using a proxy attention network and an addition layer; constructing a third network using the basic network and an addition layer; constructing the PASA attention network using the first network, the second network, the third network, and a concatenation layer.

[0032] Connect the convolutional layer, the normalization layer, and the activation layer in series to obtain the basic network. Connect the basic network and the segmentation network in series to construct the first network; connect the proxy attention network and the addition layer in series to obtain the second network; connect the basic network and the addition layer in series to obtain the third network; connect the first network, the second network, the third network, and the concatenation layer in series to obtain the PASA attention network.

[0033] The segmentation network is a split network for segmenting features. The proxy attention network (AgentAttention) is a relatively new concept that combines the ideas of an agent and an attention mechanism, mainly used for reinforcement learning, multi-agent systems, and decision-making in complex environments.

[0034] Furthermore, denote the input of the PASA attention network as the target feature; process the target feature through the first network to obtain the first feature; process the first feature through the second network to obtain the second feature; process the second feature through the third network to obtain the third feature; concatenate the third feature and the first feature through the concatenation layer to obtain the fourth feature, where the fourth feature is the output of the PASA attention network.

[0035] Furthermore, processing the first feature through the second network to obtain the second feature includes: processing the first feature through the proxy attention network in the second network to obtain the proxy attention feature; adding the first feature and the proxy attention feature through the addition layer in the second network to obtain the second feature.

[0036] Furthermore, processing the second feature through the third network to obtain the third feature includes: processing the second feature through the basic network in the third network to obtain the basic feature; adding the second feature and the basic feature through the addition layer in the third network to obtain the third feature.

[0037] Furthermore, constructing the third network using the basic network and the addition layer includes: connecting two basic networks and an addition layer in series to obtain the third network; where the second basic network connected in series does not have an activation layer.

[0038] Connect a convolutional layer, a normalization layer, and an activation layer in series to obtain a basic network. Connect a basic network and a segmentation network in series to construct a first network; connect a proxy attention network and an addition layer in series to obtain a second network; connect a first network, a second network, a third network, and a splicing layer in series to obtain a PASA attention network.

[0039] Figure 2 It is a schematic flowchart of a method for processing features by a PASA attention network provided in an embodiment of the present application. As Figure 2 shown, the method includes:

[0040] Denote the input of the PASA attention network as the target feature;

[0041] S201, process the target feature through the first basic network to obtain a fifth feature;

[0042] The first basic network in the PASA attention network is the basic network in the first network.

[0043] S202, process the target feature through the segmentation network to obtain a first feature;

[0044] S203, process the first feature through the proxy attention network to obtain a sixth feature;

[0045] S204, add the first feature and the sixth feature through the first addition layer to obtain a second feature;

[0046] The first addition layer in the PASA attention network is the addition layer in the second network.

[0047] S205, process the second feature through the second basic network to obtain a seventh feature;

[0048] The second basic network in the PASA attention network is the first basic network in the third network.

[0049] S206, process the second feature through the third basic network to obtain an eighth feature;

[0050] The third basic network in the PASA attention network is the second basic network in the third network.

[0051] S207, add the seventh feature and the eighth feature through the second addition layer to obtain a third feature;

[0052] The second addition layer in the PASA attention network is the addition layer in the third network.

[0053] S208. The third feature and the first feature are spliced through a splicing layer to obtain a fourth feature.

[0054] All of the above optional technical solutions can be combined arbitrarily to form optional embodiments of the present application, which will not be elaborated one by one here.

[0055] The following is an apparatus embodiment of the present application, which can be used to execute the embodiments of the present application. For details not disclosed in the apparatus embodiments of the present application, please refer to the embodiments of the present application.

[0056] Figure 3 It is a schematic diagram of a door switch state detection device provided by an embodiment of the present application. As Figure 3 shown, the door switch state detection device includes:

[0057] A model improvement module 301, configured to replace the original downsampling layer of the YOLO model with an HWD downsampling layer, replace the original upsampling layer of the YOLO model with a DySample upsampling layer, add a PASA attention network between the backbone network and the neck network of the YOLO model, and use the obtained new model as the door switch state detection model;

[0058] An acquisition module 302, configured to acquire training images, and use the door switch state detection model to detect the switch state of the door in the training images to obtain detection results;

[0059] An optimization module 303, configured to calculate the loss between the detection results and the labels of the training images, and optimize the model parameters of the door switch state detection model according to the loss to complete the training of the door switch state detection model;

[0060] A detection module 304, configured to provide door switch state detection services using the trained door switch state detection model.

[0061] The YOLO (You Only Look Once) model is a series of neural network architectures for real-time object detection. The embodiments of the present application improve the YOLO model to adapt to the door switch state detection scenario and improve the accuracy of door switch state detection. The YOLO model can be divided into three parts: the backbone network, the neck network, and the head network. The HWD downsampling layer is used to reduce the spatial dimension of the input data, thereby reducing the computational complexity and accelerating subsequent processing steps. HWD downsampling not only reduces the number of points, but also improves the efficiency of feature extraction while maintaining important geometric information. DySample is a dynamic sampling method. The DySample upsampling layer aims to improve the resolution of images or other data by adaptively adjusting the sampling rate while maintaining important structural and detail information. This method can dynamically select the most suitable sampling strategy according to the characteristics of the input data, thereby achieving a better balance between efficiency and effect.

[0062] Dysample upsampling has the following advantages:

[0063] 1. Adaptability: Dysample sampling can adaptively adjust the upsampling strategy according to the characteristics of the input data. This means that it can apply different upsampling methods in different regions to better capture the details and structure of the input data.

[0064] 2. Higher precision: Since Dysample can make different processing decisions for different input data, it can usually provide higher reconstruction precision in complex scenarios. For regions with more details such as edges and textures, dynamic upsampling can select a more refined processing method to improve the quality of the feature map.

[0065] 3. Reducing over-smoothing: Dysample avoids the loss of feature map details or over-smoothing, improving the algorithm precision.

[0066] In the embodiments of this application, the HWD downsampling layer is used to replace the original downsampling layer of the YOLO model, the DySample upsampling layer is used to replace the original upsampling layer of the YOLO model, and the PASA attention network is added between the backbone network and the neck network of the YOLO model. The obtained new model is used as the door switch state detection model. The PASA (Partial Agent Self-Attention) attention network combines the core idea of the self-attention mechanism with a localized or selective attention strategy, aiming to improve the perception, decision-making, and collaboration capabilities of agents in complex environments. Compared with traditional global self-attention models, Partial Agent Self-Attention pays more attention to the key attention of specific regions or related objects, thus achieving more efficient information processing and better utilization of computing resources.

[0067] According to the technical solution provided by the embodiments of this application, the HWD downsampling layer is used to replace the original downsampling layer of the YOLO model, the DySample upsampling layer is used to replace the original upsampling layer of the YOLO model, and the PASA attention network is added between the backbone network and the neck network of the YOLO model. The obtained new model is used as the door switch state detection model; training images are obtained, and the door switch state detection model is used to detect the door switch state in the training images to obtain detection results; the loss between the detection results and the labels of the training images is calculated, and the model parameters of the door switch state detection model are optimized based on the loss to complete the training of the door switch state detection model; the trained door switch state detection model is used to provide door switch state detection services. By adopting the above technical means, the problem of low accuracy in detecting the door switch state in the prior art can be solved, and thus the accuracy of detecting the door switch state can be improved.

[0068] In an alternative embodiment, the acquisition module 302 is further configured to detect the open / closed state of the door in the training image by using a door open / closed state detection model, and obtain a detection result, including: inputting the training image into the door open / closed state detection model, and inside the door open / closed state detection model: sequentially processing the training image through a backbone network, a neck network, and a head network to obtain the detection result.

[0069] In an alternative embodiment, the model improvement module 301 is further configured to use an HWD downsampling layer to replace the last three downsampling layers of the backbone network of the YOLO model; use an HWD downsampling layer to replace all the downsampling layers in the neck network of the YOLO model.

[0070] Use an HWD downsampling layer to replace the last three downsampling layers of the backbone network of the YOLO model, and keep the other downsampling layers in the backbone network unchanged.

[0071] In an alternative embodiment, the model improvement module 301 is further configured to construct a basic network by using a convolutional layer, a normalization layer, and an activation layer; construct a first network by using the basic network and a segmentation network; construct a second network by using a proxy attention network and an addition layer; construct a third network by using the basic network and an addition layer; construct a PASA attention network by using the first network, the second network, the third network, and a concatenation layer.

[0072] Sequentially connect a convolutional layer, a normalization layer, and an activation layer in series to obtain a basic network. Sequentially connect the basic network and a segmentation network to construct a first network; sequentially connect a proxy attention network and an addition layer in series to obtain a second network; sequentially connect the basic network and an addition layer in series to obtain a third network; sequentially connect the first network, the second network, the third network, and a concatenation layer to obtain a PASA attention network.

[0073] The segmentation network is a split network for segmenting features. The proxy attention network (AgentAttention) is a relatively new concept that combines the ideas of an agent and an attention mechanism, and is mainly used for reinforcement learning, multi-agent systems, and decision-making in complex environments.

[0074] In an alternative embodiment, the model improvement module 301 is further configured to denote the input of the PASA attention network as a target feature; process the target feature through the first network to obtain a first feature; process the first feature through the second network to obtain a second feature; process the second feature through the third network to obtain a third feature; concatenate the third feature and the first feature through a concatenation layer to obtain a fourth feature, where the fourth feature is the output of the PASA attention network.

[0075] In an alternative embodiment, the model improvement module 301 is further configured to process the first feature through a proxy attention network in the second network to obtain proxy attention features; and add the first feature and the proxy attention features through an addition layer in the second network to obtain second features.

[0076] In an alternative embodiment, the model improvement module 301 is further configured to process the second feature through a base network in the third network to obtain base features; and add the second feature and the base features through an addition layer in the third network to obtain third features.

[0077] In an alternative embodiment, the model improvement module 301 is further configured to serially connect two base networks and an addition layer to obtain a third network; wherein, the second base network in the serial connection does not have an activation layer.

[0078] A base network is obtained by sequentially serially connecting a convolutional layer, a normalization layer, and an activation layer. A first network is constructed by sequentially serially connecting a base network and a segmentation network; a second network is obtained by sequentially serially connecting a proxy attention network and an addition layer; a PASA attention network is obtained by sequentially serially connecting a first network, a second network, a third network, and a splicing layer.

[0079] In an alternative embodiment, the model improvement module 301 is further configured to denote the input of the PASA attention network as target features; process the target features through the first base network to obtain fifth features; process the target features through the segmentation network to obtain first features; process the first features through the proxy attention network to obtain sixth features; process the sixth features through the first addition layer to obtain second features; process the second features through the second base network to obtain seventh features; process the second features through the third base network to obtain eighth features; process the sixth features through the second addition layer to obtain third features; and splice the third features and the first features through the splicing layer to obtain fourth features.

[0080] It should be understood that the magnitudes of the sequence numbers of the steps in the above embodiments do not mean the order of execution. The order of execution of each process should be determined according to its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.

[0081] Figure 4 is a schematic diagram of the electronic device 4 provided by the embodiment of the present application. As Figure 4As shown, the electronic device 4 of this embodiment includes: a processor 401, a memory 402, and a computer program 403 stored in the memory 402 and executable on the processor 401. When the processor 401 executes the computer program 403, the steps in the above method embodiments are implemented. Alternatively, when the processor 401 executes the computer program 403, the functions of the various modules / units in the above device embodiments are implemented.

[0082] The electronic device 4 may be a desktop computer, a notebook, a palm computer, a cloud server, or other electronic devices. The electronic device 4 may include, but is not limited to, the processor 401 and the memory 402. Those skilled in the art can understand that Figure 4 merely examples of the electronic device 4, which do not constitute a limitation on the electronic device 4, may include more or fewer components than shown in the figure, or different components.

[0083] The processor 401 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.

[0084] The memory 402 may be an internal storage unit of the electronic device 4, for example, the hard disk or memory of the electronic device 4. The memory 402 may also be an external storage device of the electronic device 4, for example, a plug-in hard disk equipped on the electronic device 4, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. The memory 402 may also include both an internal storage unit and an external storage device of the electronic device 4. The memory 402 is used to store computer programs and other programs and data required by the electronic device.

[0085] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above functions can be allocated to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiments can be integrated into a processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.

[0086] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, to implement all or part of the processes in the above-mentioned embodiment methods of this application, it can also be completed by instructing relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, it can implement the steps of the above-mentioned method embodiments. The computer program can include computer program code, and the computer program code can be in the form of source code, object code, executable file or some intermediate form, etc. The computer-readable medium can include: any entity or device that can carry the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disc, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal, and software distribution medium, etc. It should be noted that the content included in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electrical carrier signals and telecommunication signals.

[0087] The above embodiments are only used to illustrate the technical solutions of this application, rather than to limit it; although this application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included in the protection scope of this application.

Claims

1. A method for detecting the state of a door switch, characterized in that, Including: Replacing the original downsampling layer of the YOLO model with the HWD downsampling layer, replacing the original upsampling layer of the YOLO model with the DySample upsampling layer, adding a PASA attention network between the backbone network and the neck network of the YOLO model, and using the obtained new model as the door switch state detection model; Obtaining training images, using the door switch state detection model to detect the switch state of the door in the training images, and obtaining detection results; Calculating the loss between the detection results and the labels of the training images, and optimizing the model parameters of the door switch state detection model according to the loss to complete the training of the door switch state detection model; Providing door switch state detection services using the trained door switch state detection model.

2. The method according to claim 1, characterized in that Replacing the original downsampling layer of the YOLO model with the HWD downsampling layer includes: Replacing the downsampling layers of the last three layers of the backbone network of the YOLO model with the HWD downsampling layer; Replacing all the downsampling layers in the neck network of the YOLO model with the HWD downsampling layer.

3. The method according to claim 2, characterized in that, Before adding the PASA attention network between the backbone network and the neck network of the YOLO model, the method further includes: Constructing a basic network using a convolutional layer, a normalization layer, and an activation layer; Constructing a first network using the basic network and a segmentation network; Constructing a second network using a proxy attention network and an addition layer; Constructing a third network using the basic network and an addition layer; Constructing the PASA attention network using the first network, the second network, the third network, and a concatenation layer.

4. The method according to claim 3, characterized in that, Denoting the input of the PASA attention network as the target feature; Processing the target feature through the first network to obtain a first feature; Processing the first feature through the second network to obtain a second feature; Processing the second feature through the third network to obtain a third feature; Concatenating the third feature and the first feature through the concatenation layer to obtain a fourth feature, where the fourth feature is the output of the PASA attention network.

5. The method according to claim 4, wherein Processing the first feature through the second network to obtain a second feature, including: Processing the first feature through the proxy attention network in the second network to obtain a proxy attention feature; Adding the first feature and the proxy attention feature through the addition layer in the second network to obtain the second feature.

6. The method according to claim 4, wherein Processing the second feature through the third network to obtain a third feature, including: Processing the second feature through the basic network in the third network to obtain a basic feature; Adding the second feature and the basic feature through the addition layer in the third network to obtain the third feature.

7. The method according to claim 3, characterized in that, Constructing the third network using the basic network and an addition layer, including: Connecting two of the basic networks and an addition layer in series to obtain the third network; Wherein, the second of the basic networks connected in series does not have the activation layer.

8. A door switch state detection device, characterized in that, Including: The model improvement module is configured to replace the original downsampling layer of the YOLO model with an HWD downsampling layer, replace the original upsampling layer of the YOLO model with a DySample upsampling layer, add a PASA attention network between the backbone network and the neck network of the YOLO model, and use the resulting new model as the door switch state detection model; The acquisition module is configured to acquire training images, use the door switch state detection model to detect the switch state of the door in the training images, and obtain a detection result; The optimization module is configured to calculate the loss between the detection result and the label of the training images, and optimize the model parameters of the door switch state detection model based on the loss to complete the training of the door switch state detection model; The detection module is configured to provide door switch state detection services using the trained door switch state detection model.

9. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the method according to any one of claims 1 to 7.