Disclosure of Invention
The invention aims to overcome the defects of the prior art and provides a method and a device for detecting a drowning-preventing human target of a swimming pool, computer equipment and a storage medium.
In order to achieve the purpose, the invention adopts the following technical scheme: a method for detecting a drowning-preventing human target in a swimming pool comprises the following steps:
acquiring images shot by a plurality of cameras above the water surface of the swimming pool to obtain an original image;
inputting the original image into a target detection model to perform anti-drowning human target detection of the swimming pool so as to obtain a detection result;
outputting the detection result;
the target detection model is obtained by training a convolutional neural network by using a plurality of images with position labels of human body targets as sample sets.
The further technical scheme is as follows: the target detection model is obtained by training a convolutional neural network by using a plurality of images with position labels of human body targets as a sample set, and comprises the following steps:
constructing an image with a position label of a human body target as a sample set;
dividing the sample set to obtain a training set, a verification set and a test set;
performing enhancement processing on the training set, the verification set and the test set to obtain a processing result;
constructing a Yolov5 network, and adding a DLA-34 network, a Semantic Self-authorization mechanism and an Anchor-free network in the Yolov5 network to obtain an initial network;
training and verifying the initial network by using a training set and a verification set in the processing result, and calculating a loss value in the training process;
and when the loss value is kept unchanged, testing the initial network by using the test set in the processing result so as to take the trained initial network as a target detection model.
The further technical scheme is as follows: the method comprises the steps of constructing a Yolov5 network, and adding a DLA-34 network, a Semantic Self-authorization mechanism and an Anchor-free network in the Yolov5 network to obtain an initial network, wherein the steps comprise:
constructing a Yolov5 network;
adding a DLA-34 network as a backbone network in the Yolov5 network, and extracting features to obtain a first network;
adding a Semantic Self-authorization mechanism to the first network to obtain a second network;
an Anchor-free network is used in the target regression box network of the second network to obtain the initial network.
The further technical scheme is as follows: the detection result comprises the position of the human target of the swimming pool.
The invention also provides a drowning-preventing human target detection device for the swimming pool, which comprises:
the swimming pool water surface monitoring system comprises an image acquisition unit, a control unit and a control unit, wherein the image acquisition unit is used for acquiring images shot by a plurality of cameras positioned above the water surface of a swimming pool so as to obtain an original image;
the target detection unit is used for inputting the original image into a target detection model to perform drowning-preventing human target detection of the swimming pool so as to obtain a detection result;
and the output unit is used for outputting the detection result.
The further technical scheme is as follows: the device also comprises a model generation unit;
the model generation unit is used for training the convolutional neural network by using a plurality of images with position labels of human body targets as a sample set so as to obtain a target detection model.
The further technical scheme is as follows: the model generation unit includes:
the sample set constructing subunit is used for constructing an image with a position label of a human body target as a sample set;
the dividing subunit is used for dividing the sample set to obtain a training set, a verification set and a test set;
the enhancement processing subunit is used for carrying out enhancement processing on the training set, the verification set and the test set to obtain a processing result;
the initial network generation subunit is used for constructing a Yolov5 network, and adding a DLA-34 network, a Semantic Self-authorization mechanism and an Anchor-free network in the Yolov5 network to obtain an initial network;
the training subunit is used for training and verifying the initial network by using a training set and a verification set in the processing result, and calculating a loss value in the training process;
and the testing subunit is used for testing the initial network by using the test set in the processing result when the loss value is kept unchanged, so as to take the trained initial network as a target detection model.
The further technical scheme is as follows: the initial network generation subunit includes:
the basic network construction module is used for constructing a Yolov5 network;
the first network generation module is used for adding a DLA-34 network in the Yolov5 network as a backbone network, and extracting features to obtain a first network;
the second network generation module is used for adding a Semantic Self-authorization mechanism in the first network to obtain a second network;
and the network processing module is used for constructing an Anchor-free network in the target regression frame network of the second network so as to obtain an initial network.
The invention also provides computer equipment which comprises a memory and a processor, wherein the memory is stored with a computer program, and the processor realizes the method when executing the computer program.
The invention also provides a storage medium storing a computer program which, when executed by a processor, implements the method described above.
Compared with the prior art, the invention has the beneficial effects that: the invention obtains images shot by a plurality of cameras positioned above the water surface of the swimming pool, and carries out the drowning prevention human body target detection of the swimming pool by means of the target detection model, wherein the target detection model is formed by adding a DLA-34 network, a Semantic Self-orientation mechanism and an Anchor-free network to a Yolov5 network, and the drowning prevention human body target detection method can obtain more effective information through training, has high accuracy, realizes the rapid and accurate detection of the swimming pool human body target, and improves the accuracy of drowning supervision.
The invention is further described below with reference to the accompanying drawings and specific embodiments.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It will be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It is also to be understood that the terminology used in the description of the invention herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in the specification of the present invention and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be further understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
Referring to fig. 1 and fig. 2, fig. 1 is a schematic view of an application scenario of a method for detecting a human target in a swimming pool for drowning prevention according to an embodiment of the present invention. Fig. 2 is a schematic flow chart of a method for detecting a human target in a swimming pool for preventing drowning according to an embodiment of the present invention. The method for detecting the drowning-preventing human body target of the swimming pool is applied to a server. The server performs data interaction with the plurality of cameras and the terminal, performs target detection through images acquired by the plurality of cameras, and outputs a detection result.
Fig. 2 is a schematic flow chart of a method for detecting a human target in drowning prevention of a swimming pool according to an embodiment of the present invention. As shown in fig. 2, the method includes the following steps S110 to S150.
And S110, acquiring images shot by a plurality of cameras above the water surface of the swimming pool to obtain an original image.
In this embodiment, a plurality of cameras are deployed above the surface of the pool, and are used to capture an omnidirectional image of the pool, thereby forming an original image.
And S120, inputting the original image into a target detection model to perform anti-drowning human target detection of the swimming pool so as to obtain a detection result.
In this embodiment, the detection result includes the position of the human target in the swimming pool, and also includes the result that no human target exists in the swimming pool.
The target detection model is obtained by training a convolutional neural network by using a plurality of images with position labels of human body targets as sample sets.
In an embodiment, referring to fig. 3, the step S120 may include steps S121 to S126.
And S121, constructing an image with a position label of the human body target as a sample set.
In this embodiment, the sample set refers to a plurality of images of the swimming pool, and the images formed by manually labeling the positions of the human targets.
And S122, dividing the sample set to obtain a training set, a verification set and a test set.
In the embodiment, the sample set is divided, and the division can be used for training, verifying and testing the model.
And S123, performing enhancement processing on the training set, the verification set and the test set to obtain a processing result.
In this embodiment, the processing result refers to a result obtained by processing the training set, the verification set, and the test set by an enhancement operation means such as rotation and inversion.
The training set, the verification set and the test set are subjected to enhancement processing, so that the stability of the model can be improved.
S124, constructing a Yolov5 network, and adding a DLA-34 network, a Semantic Self-extension mechanism and an Anchor-free network in the Yolov5 network to obtain an initial network.
In this embodiment, the initial network refers to a convolutional neural network formed by adding a DLA-34 network, a Semantic Self-anchoring mechanism and an Anchor-free network to a Yolov5 network.
In an embodiment, referring to fig. 4, the step S124 may include steps S1241 to S1244.
S1241, constructing a Yolov5 network;
s1242, adding a DLA-34 network as a backbone network in the Yolov5 network, and extracting features to obtain a first network.
In this embodiment, the first network refers to a network structure formed after the Yolov5 network adds the DLA-34 network as a backbone network.
DLA-34 in CenterNet is added as a Backbone for extracting characteristics on the basis of a used Yolov5 target detection model. DLA (Deep Layer Aggregation) is an image classification network with multi-level jump connection, and information of different layers can be better aggregated through deeper fusion. And the DLA-34 uses Deformable Convolution, namely DCN (Deformable Convolutional), so that the DLA-34 serving as a network structure of multi-target tracking can fuse the characteristic information in an iterative mode, and more effective information is obtained.
S1243, adding a Semantic Self-authorization mechanism in the first network to obtain a second network.
In this embodiment, the second network refers to a Yolov5 network, which adds a DLA-34 network as a backbone network as a foundation and adds a network formed by a Semantic Self-authorization mechanism.
In the target detection model, SSA (Self-Attention mechanism) is also added. Firstly, the Self-Attention mechanism of Self-Attention is to process global information, and the Self-Attention mechanism of Self-Attention takes a target detection frame as a segmented manually labeled frame ground route, and learns the segmented characteristics by using the target detection frame ground route, and fuses the characteristics and the detection characteristics, namely an Attention focused information range Attention map as the detection characteristics is detected. The process is as follows: the detection frame of the truth value is used as a divided mask, the mask is learned on the original characteristic diagram through convolution, and the characteristic diagram obtained through learning is used as an information range focused by attention and is fused on the original characteristic diagram.
S1244, using an Anchor-free network in the target regression box network of the second network to obtain an initial network.
In this embodiment, in the final target regression frame network, the Anchor-free algorithm is used, and the boundary frame where the final target is located is obtained according to the feature maps with the category information and the location information and then according to the feature maps.
Specifically, the target box, i.e. the bounding box prediction program where the target is located, implements: as shown in fig. 5, three scale feature maps are formed, in which the number below the convolutional layer is the number of channels, the number above is the two-dimensional image size value, and the input image is 736 × 1280, 3 channels. The different scale characteristic graphs deepen along with the convolution layer, the receptive fields on the input images are different, namely the sizes of the input image grids corresponding to the characteristic graphs are different
When the target detection model is used for reasoning, multiplying the class information of each grid prediction and the confidence coefficient of the target frame prediction to obtain a class-specific confidence score of each target frame:
the first term on the left of the equation is the class probability of each mesh prediction, and the second third term is the confidence of each target box prediction. The product is the probability that the predicted target frame belongs to a certain category and also the probability of the accuracy of the target frame. After the class-confidence score of each target frame is obtained, setting a threshold value, filtering out target frames with low scores, and carrying out NMS (non-maximum suppression) treatment on the reserved target frames to obtain a final detection result; i.e. the location of the human target in the pool.
And S125, training and verifying the initial network by utilizing the training set and the verification set in the processing result, and calculating a loss value in the training process.
In this embodiment, the loss value refers to the variance between the result obtained by the training process and the actually labeled label.
And S126, when the loss value is kept unchanged, testing the initial network by using the test set in the processing result so as to take the trained initial network as a target detection model.
When the loss value is maintained unchanged, that is, the current network is already converged, that is, the loss value is basically unchanged and very small, it is also indicated that the current network can be used as a candidate target detection model, generally, the loss value is relatively large when training is started, the loss value is smaller after training, and if the loss value is not maintained unchanged, it is indicated that the current network cannot be used as the candidate target detection model, that is, the detected result is not accurate, which may cause the classification of the interference signal in the later period to be inaccurate; if the loss value is not maintained, adjusting parameters of each layer of the network, and executing the sequence as an input value to be input into the network for training the network.
And S130, outputting the detection result.
In this embodiment, the detection result is output to the terminal for the terminal to check.
The swimming pool drowning prevention human body target detection method comprises the steps of obtaining images shot by a plurality of cameras located above the water surface of a swimming pool, and carrying out swimming pool drowning prevention human body target detection in a target detection model, wherein the target detection model is formed by adding a DLA-34 network, a Semantic Self-orientation mechanism and an Anchor-free network into a Yolov5 network and is obtained through training, more effective information can be obtained, the accuracy rate is high, the swimming pool human body target can be quickly and accurately detected, and the accuracy rate of drowning supervision is improved.
Fig. 6 is a schematic block diagram of a swimming pool drowning prevention humantarget detection apparatus 300 according to an embodiment of the present invention. As shown in fig. 6, the present invention also provides a humantarget detection device 300 for detecting drowning of swimming pool, corresponding to the above method for detecting drowning human target of swimming pool. The swimming pool drowning prevention humantarget detection apparatus 300 includes a unit for performing the above-described swimming pool drowning prevention human target detection method, and the apparatus may be configured in a server. Specifically, referring to fig. 6, the swimming pool drowning prevention humantarget detection apparatus 300 includes animage acquisition unit 301, atarget detection unit 302, and anoutput unit 303.
Animage acquisition unit 301, configured to acquire images captured by a plurality of cameras above the water surface of the swimming pool to obtain an original image; atarget detection unit 302, configured to input the original image into a target detection model for detecting a human target in the swimming pool for drowning prevention, so as to obtain a detection result; anoutput unit 303, configured to output the detection result.
In one embodiment, the swimming pool drowning prevention humantarget detection apparatus 300 further comprises a model generation unit;
the model generation unit is used for training the convolutional neural network by using a plurality of images with position labels of human body targets as a sample set so as to obtain a target detection model.
In an embodiment, the model generation unit includes a sample set construction subunit, a division subunit, an enhancement processing subunit, an initial network generation subunit, a training subunit, and a testing subunit.
The sample set constructing subunit is used for constructing an image with a position label of a human body target as a sample set; the dividing subunit is used for dividing the sample set to obtain a training set, a verification set and a test set; the enhancement processing subunit is used for carrying out enhancement processing on the training set, the verification set and the test set to obtain a processing result; the initial network generation subunit is used for constructing a Yolov5 network, and adding a DLA-34 network, a Semantic Self-authorization mechanism and an Anchor-free network in the Yolov5 network to obtain an initial network; the training subunit is used for training and verifying the initial network by using a training set and a verification set in the processing result, and calculating a loss value in the training process; and the testing subunit is used for testing the initial network by using the test set in the processing result when the loss value is kept unchanged, so as to take the trained initial network as a target detection model.
In an embodiment, the initial network generation subunit includes a basic network construction module, a first network generation module, a second network generation module, and a network processing module.
The basic network construction module is used for constructing a Yolov5 network; the first network generation module is used for adding a DLA-34 network in the Yolov5 network as a backbone network, and extracting features to obtain a first network; the second network generation module is used for adding a Semantic Self-authorization mechanism in the first network to obtain a second network; and the network processing module is used for constructing an Anchor-free network in the target regression frame network of the second network so as to obtain an initial network.
It should be noted that, as will be clear to those skilled in the art, the concrete implementation processes of the above-mentioned drowning humantarget detection apparatus 300 and each unit of the swimming pool can refer to the corresponding descriptions in the foregoing method embodiments, and for the convenience and brevity of description, no further description is provided herein.
The above-described swimming pool drowning prevention humantarget detection apparatus 300 can be implemented in the form of a computer program that can be run on a computer device as shown in fig. 7.
Referring to fig. 7, fig. 7 is a schematic block diagram of a computer device according to an embodiment of the present application. Thecomputer device 500 may be a server, wherein the server may be an independent server or a server cluster composed of a plurality of servers.
Referring to fig. 7, thecomputer device 500 includes aprocessor 502, memory, and anetwork interface 505 connected by asystem bus 501, where the memory may include anon-volatile storage medium 503 and aninternal memory 504.
Thenon-volatile storage medium 503 may store anoperating system 5031 and acomputer program 5032. Thecomputer programs 5032 include program instructions that, when executed, cause theprocessor 502 to perform a method of detecting a human target in drowning prevention in a pool.
Theprocessor 502 is used to provide computing and control capabilities to support the operation of theoverall computer device 500.
Theinternal memory 504 provides an environment for the operation of thecomputer program 5032 in thenon-volatile storage medium 503, and when thecomputer program 5032 is executed by theprocessor 502, theprocessor 502 can be enabled to perform a method for detecting a drowning human target in a swimming pool.
Thenetwork interface 505 is used for network communication with other devices. Those skilled in the art will appreciate that the configuration shown in fig. 7 is a block diagram of only a portion of the configuration associated with the present application and does not constitute a limitation of thecomputer device 500 to which the present application may be applied, and that aparticular computer device 500 may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
Wherein theprocessor 502 is configured to run thecomputer program 5032 stored in the memory to implement the following steps:
acquiring images shot by a plurality of cameras above the water surface of the swimming pool to obtain an original image; inputting the original image into a target detection model to perform anti-drowning human target detection of the swimming pool so as to obtain a detection result; outputting the detection result;
the target detection model is obtained by training a convolutional neural network by using a plurality of images with position labels of human body targets as sample sets.
The detection result comprises the position of the human target of the swimming pool.
In an embodiment, when implementing the target detection model is a step of training a convolutional neural network by using a plurality of images with position labels of human targets as sample sets, theprocessor 502 specifically implements the following steps:
constructing an image with a position label of a human body target as a sample set; dividing the sample set to obtain a training set, a verification set and a test set; performing enhancement processing on the training set, the verification set and the test set to obtain a processing result; constructing a Yolov5 network, and adding a DLA-34 network, a Semantic Self-authorization mechanism and an Anchor-free network in the Yolov5 network to obtain an initial network; training and verifying the initial network by using a training set and a verification set in the processing result, and calculating a loss value in the training process; and when the loss value is kept unchanged, testing the initial network by using the test set in the processing result so as to take the trained initial network as a target detection model.
In an embodiment, when theprocessor 502 implements the above-mentioned building of the Yolov5 network and adds the DLA-34 network, the Semantic Self-authorization mechanism, and the Anchor-free network to the Yolov5 network to obtain the initial network step, the following steps are specifically implemented:
constructing a Yolov5 network; adding a DLA-34 network as a backbone network in the Yolov5 network, and extracting features to obtain a first network; adding a Semantic Self-authorization mechanism to the first network to obtain a second network; an Anchor-free network is used in the target regression box network of the second network to obtain the initial network.
It should be understood that in the embodiment of the present Application, theProcessor 502 may be a Central Processing Unit (CPU), and theProcessor 502 may also be 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, and the like. Wherein a general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
It will be understood by those skilled in the art that all or part of the flow of the method implementing the above embodiments may be implemented by a computer program instructing associated hardware. The computer program includes program instructions, and the computer program may be stored in a storage medium, which is a computer-readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the flow steps of the embodiments of the method described above.
Accordingly, the present invention also provides a storage medium. The storage medium may be a computer-readable storage medium. The storage medium stores a computer program, wherein the computer program, when executed by a processor, causes the processor to perform the steps of:
acquiring images shot by a plurality of cameras above the water surface of the swimming pool to obtain an original image; inputting the original image into a target detection model to perform anti-drowning human target detection of the swimming pool so as to obtain a detection result; outputting the detection result;
the target detection model is obtained by training a convolutional neural network by using a plurality of images with position labels of human body targets as sample sets.
The detection result comprises the position of the human target of the swimming pool.
In an embodiment, when the processor executes the computer program to implement the step of training the convolutional neural network by using a plurality of images with position labels of the human body targets as a sample set, the processor implements the following steps:
constructing an image with a position label of a human body target as a sample set; dividing the sample set to obtain a training set, a verification set and a test set; performing enhancement processing on the training set, the verification set and the test set to obtain a processing result; constructing a Yolov5 network, and adding a DLA-34 network, a Semantic Self-authorization mechanism and an Anchor-free network in the Yolov5 network to obtain an initial network; training and verifying the initial network by using a training set and a verification set in the processing result, and calculating a loss value in the training process; and when the loss value is kept unchanged, testing the initial network by using the test set in the processing result so as to take the trained initial network as a target detection model.
In an embodiment, when the processor executes the computer program to implement the building of the Yolov5 network and adds the DLA-34 network, the Semantic Self-authorization mechanism, and the Anchor-free network to the Yolov5 network to obtain the initial network step, the following steps are specifically implemented:
constructing a Yolov5 network; adding a DLA-34 network as a backbone network in the Yolov5 network, and extracting features to obtain a first network; adding a Semantic Self-authorization mechanism to the first network to obtain a second network; an Anchor-free network is used in the target regression box network of the second network to obtain the initial network.
The storage medium may be a usb disk, a removable hard disk, a Read-Only Memory (ROM), a magnetic disk, or an optical disk, which can store various computer readable storage media.
Those of ordinary skill in the art will appreciate that the elements and algorithm steps of the examples described in connection with the embodiments disclosed herein may be embodied in electronic hardware, computer software, or combinations of both, and that the components and steps of the examples have been described in a functional general in the foregoing description for the purpose of illustrating clearly the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative. For example, the division of each unit is only one logic function division, and there may be another division manner in actual implementation. For example, various elements or components may be combined or may be integrated into another system, or some features may be omitted, or not implemented.
The steps in the method of the embodiment of the invention can be sequentially adjusted, combined and deleted according to actual needs. The units in the device of the embodiment of the invention can be merged, divided and deleted according to actual needs. In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a storage medium. Based on such understanding, the technical solution of the present invention essentially or partially contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a terminal, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention.
While the invention has been described with reference to specific embodiments, the invention is not limited thereto, and various equivalent modifications and substitutions can be easily made by those skilled in the art within the technical scope of the invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.