Public area pet identification method, device and equipment and storage medium
By conducting self-supervised training on the label-free data set, the feature extraction capability of the pet detection network is improved, and combined with supervision training, the problems of difficulty in pet identification and high data acquisition cost in the existing technology are solved, and efficient and accurate pet identification effect is achieved.
Patent Information
- Application Number
- CN202510300069.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-14
- Publication Date
- 2025-04-11
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the existing technology, supervised training methods are difficult to train, which makes it difficult to identify pets, and the cost of data acquisition is high, making training difficult.
The self-supervised training method is used to train the backbone network of the pet detection network on the label-free data set, and improve the network's feature extraction ability through self-supervised training, and then further train using the supervised training pet detection data set to improve the recognition ability of pet detection.
It reduces the training cost and difficulty of pet detection network, improves the accuracy and efficiency of pet identification in cameras, and enhances the management capabilities and service level of the community.
Smart Images

Figure CN119810758A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence and public area pet identification technology, and in particular to a public area pet identification method, device, equipment and storage medium. Background Art
[0002] The management of stray pets has always been a major problem in urban community governance, especially the management of common pets such as stray cats and dogs in public areas, including streets, squares, around garbage cans, swimming pools, green areas, etc. The traditional way to manage stray pets is usually to arrange security personnel to patrol regularly, or rely on existing surveillance cameras for regular inspections and dispatch staff to handle them as needed, but these methods usually require more manpower or require a long time to check the feedback images from the surveillance cameras, resulting in low efficiency.
[0003] With the development of artificial intelligence technology, target detection algorithms have gradually matured. Some communities and property management companies will choose to use commonly used target detection algorithms (such as yolov8) to perform frame detection on surveillance videos. By using visual algorithms to perform long-term, automatic target recognition, once a preset alarm target (such as stray pets) is identified, the staff will be notified to conduct a secondary screening before deciding whether to take action. This technology significantly reduces manpower requirements and improves work efficiency.
[0004] However, since the commonly used target detection algorithms require a large amount of labeled data for training (i.e. supervised training, which requires a large amount of labeled data), and since pets appear less frequently in security monitoring and are relatively sparse and irregular in time and space, this has brought great limitations to data collection and labeling. If the commonly used target detection algorithms are used for training, it is necessary to bear a high data acquisition cost and the training is difficult. In addition, the target size of pets in the monitoring screen is usually small, and the fixed nature of the security monitoring background further increases the difficulty of recognition. Summary of the invention
[0005] The embodiments of the present invention provide a method, device, equipment and storage medium for identifying pets in public areas, aiming to solve the problem in the prior art that supervised training methods are difficult to train, resulting in great difficulty in identifying pets.
[0006] In a first aspect, an embodiment of the present invention provides a method for identifying pets in public areas based on self-supervised training, comprising: Collect image data from online cameras and preprocess the image data to obtain an unlabeled data set; Collect and annotate image data from the security monitoring database to obtain a pet detection dataset; Constructing a pet detection network, wherein the pet detection network includes a backbone network, a pyramid network and a target detection head; Performing self-supervisory training on the backbone network using the unlabeled dataset; Performing supervised training on the pet detection network using the pet detection data set to obtain a trained pet detection network; The trained pet detection network is used to identify the image to be detected, and it is determined based on the recognition result whether there is a situation where the pet acts alone. If so, an alarm is issued.
[0007] In a second aspect, an embodiment of the present invention provides a public area pet identification device based on self-supervised training, comprising: A preprocessing unit, used to collect image data from online cameras and preprocess the image data to obtain an unlabeled data set; A data collection unit is used to collect and annotate image data in a security monitoring database to obtain a pet detection data set; A construction unit, used to construct a pet detection network, wherein the pet detection network includes a backbone network, a pyramid network and a target detection head; A self-supervised training unit, used to perform self-supervised training on the backbone network using the unlabeled data set; A supervised training unit, used to perform supervised training on the pet detection network using the pet detection data set to obtain a trained pet detection network; The recognition and alarm unit is used to use the trained pet detection network to recognize the image to be detected, and determine whether there is a situation where the pet acts alone according to the recognition result. If so, an alarm is issued.
[0008] In a third aspect, an embodiment of the present invention provides a computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method for identifying pets in public areas based on self-supervised training as described in the first aspect is implemented.
[0009] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium storing a computer program, which, when executed by a processor, enables the processor to perform the public area pet identification method based on self-supervised training as described in the first aspect.
[0010] The embodiment of the present invention provides a method, device, equipment and storage medium for identifying pets in public areas. The method includes: collecting image data from online cameras and preprocessing the image data to obtain an unlabeled data set; collecting and labeling image data in a security monitoring database to obtain a pet detection data set; constructing a pet detection network; using the unlabeled data set to perform self-supervised training on the backbone network; using the pet detection data set to perform supervised training on the pet detection network to obtain a trained pet detection network; using the trained pet detection network to identify the image to be detected, and judging whether there is a situation where the pet acts alone according to the recognition result, and if so, an alarm is issued. The present invention trains the feature extraction capability of the pet detection network encoder on the unlabeled data set through a self-supervised training method, and then uses the pet detection data set to train the pet detection network to perform recognition capabilities of specific categories of objects, thereby achieving the goal of using unlabeled data with low acquisition cost to enhance the performance of the pet detection network, effectively solving the problem of identifying pets in cameras, not only reducing costs and improving efficiency, but also further improving the management capabilities and service levels of the community. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.
[0012] Figure 1 A flowchart of a method for identifying pets in public areas based on self-supervised training provided by an embodiment of the present invention; Figure 2 A schematic diagram of the collection process of an unlabeled dataset and a pet detection dataset provided by an embodiment of the present invention; Figure 3 A schematic diagram of a pet detection network framework provided by an embodiment of the present invention; Figure 4 A schematic diagram of a sub-process of a method for identifying pets in public areas based on self-supervised training provided by an embodiment of the present invention; Figure 5 A schematic diagram of another sub-process of a method for identifying pets in public areas based on self-supervised training provided by an embodiment of the present invention; Figure 6 A schematic diagram of another sub-process of a method for identifying pets in public areas based on self-supervised training provided by an embodiment of the present invention; Figure 7 An algorithm design flow chart of a public area pet recognition method based on self-supervised training provided in an embodiment of the present invention; Figure 8 A schematic diagram of a public area pet identification device based on self-supervised training provided by an embodiment of the present invention; Fig. 9 A schematic diagram of a computer device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0013] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0014] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0015] It should also be understood that the terms used in the present specification are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the present specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0016] It should be further understood that the term "and / or" used in the present description and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0017] See also Figure 1 , Figure 1 A flowchart of a method for identifying pets in public areas based on self-supervised training is provided in an embodiment of the present invention. The method includes steps S101 to S106: S101, collecting image data from online cameras and preprocessing the image data to obtain an unlabeled data set; In this embodiment, it is necessary to first determine the list of online cameras, and then collect image data mainly from the security monitoring data generated by these cameras, and ensure the adaptability and extensiveness of the data through methods such as deduplication and data visualization. Specifically, for the pictures obtained from the same camera on the same day, hash deduplication will be used to eliminate data redundancy. At the same time, for the collected pictures, the shooting position, acquisition time, shooting angle, weather conditions and other information of all pictures will be counted to ensure that the pictures in the data set evenly cover all cameras that need to be online, and include different lighting conditions in all time periods from day to night, as well as different weather conditions such as sunny, cloudy, rainy and snowy. Finally, a diverse unlabeled data set covering a wide range of scenes is obtained. The unlabeled data set contains 200,000 pictures, and the resolution of each picture is between 1920*1080 and 640*480.
[0018] It should be noted that the construction of unlabeled datasets does not require manual labeling, but the distribution of training data should be as consistent as possible with the actual application scenarios, and the diversity of data should be as rich as possible to ensure the practicality and effectiveness of the dataset.
[0019] S102, collecting and labeling image data in a security monitoring database to obtain a pet detection data set; In this embodiment, the pet detection data set is mainly used for model training to detect three categories of objects: cats, dogs, and people. First, all pictures containing cats and dogs are screened out from a security monitoring database covering most communities. These pictures are labeled pictures. Then use these pictures to train a YOLOv11_x model for identifying cats and dogs. The model then pre-labels (neck reasoning) all pictures generated by all cameras, and at the same time, all pictures with a confidence level greater than 0.02 and a category prediction of cats or dogs are filtered out. Finally, use manual labeling to delete the pre-labeled wrong pictures or correct the position and size of the target rectangular boxes of the three categories of cats, dogs, and people.
[0020] like Figure 2 As shown, it is a schematic diagram of the collection process of the unlabeled data set and the pet detection data set. The specific collection steps are described as described in the above steps S101 and S102, which will not be described in detail here.
[0021] S103, constructing a pet detection network, wherein the pet detection network includes a backbone network, a pyramid network and a target detection head; In this embodiment, if Figure 3The figure shows a schematic diagram of the framework structure of the pet detection network. The input of the pet detection network is a 512*512 image, and the output is the category, position and confidence of the target object predicted by the pet detection network on the image. The pet detection network mainly includes three parts: a backbone network, a pyramid network, and a target detection head. The backbone network includes a plurality of stacked Transformer modules, wherein the feature map scale of each Transformer module is 16 times the input image size, the pyramid network includes a plurality of sampling modules, and the plurality of sampling modules in the pyramid network are connected to the output of the backbone network, and the target detection head is a YOLOV11 detection head.
[0022] Specifically, the backbone network takes a 512*512 three-channel RGB image as input, extracts features from the image through 12 stacked Transformer modules, and outputs a feature map of size 32*32 and number of channels 768 after 16-fold downsampling. Specifically, the input image is first cut into 256 non-overlapping 32*32 image blocks, then each image block is flattened and converted into a fixed-dimensional vector through a fully connected layer, and then features are extracted through stacked Transformers, and finally the feature map is output.
[0023] Furthermore, the pet detection network generally uses a complex pyramid network (FPN) after the backbone network to extract multi-scale features of the image to achieve better multi-scale target detection performance. However, the backbone network used in this network is ViT, which has better global feature extraction capabilities than CNN, and ViT can achieve good multi-scale target detection without complex FPN. Therefore, this embodiment uses the Simple FPN proposed in ViTDet to directly obtain 4 scale features of the final output of the backbone network by upsampling (deconvolution with stride=2) or downsampling (convolution with stride=2), and no longer uses FPN to further fuse features. The input of the pyramid network is a feature map of 768*32*32, and the output feature map sizes are (256*16*16), (256*32*32), (256*64*64), and (256*128*128).
[0024] Furthermore, the function of the target detection head is to output the location and category of the target based on the input image features. In terms of methods, it is mainly divided into two categories: one is the Anchor-based scheme based on the anchor frame, and the other is the Anchor-free scheme that does not use the anchor frame. Among them, the Anchor-free scheme does not require a preset anchor frame size and parameter amount, has fewer hyperparameters, and has a faster inference speed. Therefore, this embodiment uses the target detection head of the Anchor-free scheme. Specifically, the decoupled target detection head proposed in YOLOv11 is used to predict the position and category of the target object in the image. The YOLOV11 target detection head separates the bounding box regression and classification tasks into two branches for processing. Its classification branch introduces deep separable convolution, which significantly reduces the amount of calculation while ensuring performance. The input of the YOLOV11 target detection head is the feature map at four scales output by the pyramid network, and the output is the location, category and confidence of the target.
[0025] S104, using the unlabeled data set to perform self-supervised training on the backbone network; In this embodiment, the labeled dataset is used for self-supervised training of the backbone network of the pet detection network. MAE (Masked Autoencoder) is a visual self-supervised pre-training method that learns features by masking part of the input image. The core idea is to randomly select a part of the image for masking and train the model to reconstruct the masked area. MAE uses an encoder-decoder architecture, where the encoder extracts the contextual information of the image and the decoder is responsible for reconstructing the masked part. This method can efficiently utilize unlabeled data to learn powerful visual features and reduce dependence on labeled data. Encoders trained by the MAE method can be used on multiple downstream visual tasks (such as image classification, object detection, etc.) and perform well, showing its potential in learning general image representations.
[0026] In one embodiment, if Figure 4 As shown, the step S104 includes steps S201 to S205: S201, cutting the initial image in the unlabeled data set into blocks to obtain a plurality of image blocks; S202, randomly cover some of the image blocks in the plurality of image blocks according to the following formula: , where I represents a set of several image blocks, represents the i-th image block, and E represents the expectation; S203, using an encoder to encode the uncovered image blocks; S204, combining the encoded image block and the covered image block and inputting the combined blocks into a decoder, and using the decoder to reconstruct the encoded image block to obtain a restored image; S205, using the following formula to calculate the reconstruction loss, and training the encoder according to the reconstruction loss to obtain the encoder weight: ,in, represents the reconstruction loss, and Respectively represent the mean and variance of the image block to be reconstructed, is the minimum value, H and W are the height and width of the image block to be reconstructed respectively. represents the calculated value of the image block in the initial image, Represents the calculated value of the image block in the restored image.
[0027] In this embodiment, the framework of self-supervised training includes image segmentation, random mask, encoder, decoder, and loss calculation. The main purpose is to train the feature extraction ability of the pet detection network encoder.
[0028] In step S201, the Transformer model is used. The Transformer model is mainly used to process sequence data. For image data, the usual practice is to divide the image into several image blocks, and then convert each image block into a one-dimensional vector and input it into the Transformer. This embodiment also uses this method to divide the input image into multiple image blocks of size 32*32, and all subsequent operations are performed in units of image blocks.
[0029] Furthermore, in step S202, the random mask is to randomly select a portion of the pixels of the input image to cover. A 75% random mask is used. Specifically, after the input image is cut into small blocks, 75% of the image blocks are randomly selected for covering, and then the remaining 25% of the uncovered image blocks are input to the encoder. These randomly selected image blocks are evenly and randomly distributed in all areas of the image. This strategy can improve network performance while reducing the number of training rounds required for network convergence.
[0030] In step S203, the encoder encodes the uncovered image blocks to learn their features. The structure of the encoder is consistent with the backbone network of the pet detection network, which is a ViT-base network with 12 layers of transformers stacked. The encoded image block features are then combined with the mask of the covered area and input into the decoder to restore the covered area.
[0031] In step S204, the decoder is only used in the pre-training task. Its role is to perform image reconstruction tasks to supervise the feature extraction work of the encoder. Specifically, this embodiment stacks 8 layers of transformers to form a decoder, and after standardizing each image block to be reconstructed, uses the mean square error loss (MSE loss) to train the network for image reconstruction.
[0032] In one embodiment, if Figure 5 As shown, the step S104 includes steps S301 to S303: S301, using a prediction strategy to set a learning rate to a specified value within a predetermined number of training rounds at an early stage of training; S302, using the cosine annealing strategy to adjust the learning rate in the later stage of training; S303: Use a data enhancement method to reduce overfitting in the backbone network.
[0033] In this embodiment, as in steps S201 to S205 above, 800 rounds of training are performed based on the supervised framework using an unlabeled data set. In the first 40 rounds of training, the learning rate is set to a fixed value so that the network can quickly learn the necessary features in the initial stage. Thereafter, the learning rate will be periodically adjusted using a cosine annealing strategy in order to help the network jump out of the local minimum during the training process and possibly find a better solution. In order to speed up the training while ensuring performance, this embodiment scales all the images in the data set and randomly crops them, thereby inputting a fixed size of 224*224 images to the network, and using a random flip data enhancement method to reduce the possibility of overfitting in the network.
[0034] After each round of training, the MSE loss value of the current backbone network on the validation set is calculated, and only the weight with the lowest MSE loss value is saved during the entire training process. After completing 800 rounds of self-supervised training, the saved pt model file is read, and the encoder part of the MAE training framework is separated and saved separately through the name of the network structure contained therein, so that it is easy to load into the subsequent pet detection network.
[0035] S105, using the pet detection data set to perform supervised training on the pet detection network to obtain a trained pet detection network; In this embodiment, after completing the self-supervised training of the encoder, this embodiment trains the pet detection network to detect three categories of objects: cats, dogs, and humans, using a labeled data set (a pet detection data set, also called a target detection data set).
[0036] In one embodiment, if Figure 6 As shown, the step S105 includes steps S401 to S403: S401, migrating the encoder weights obtained by self-supervised training to the backbone network of the pet detection network, wherein the backbone network has the same structure as the encoder; S402, randomly initializing the pyramid network and the target detection head; S403: Using the pet detection data set to train the pet detection network.
[0037] In this embodiment, since the input size of the pet detection network is fixed to a 512*512 image, and the images returned by different cameras (images to be detected) may have multiple resolutions, it is necessary to uniformly scale the input images to images with a resolution of 512*512.
[0038] As mentioned above, the encoder of the pet detection network is first trained using the MAE method. The structure of the encoder trained by MAE is exactly the same as that of the encoder in the pet detection network, and the output feature map size is also exactly the same. Therefore, when initializing the pet detection network, the encoder is initialized using the pre-trained weights saved by the MAE method on the unlabeled dataset, while for the rest of the pet detection network, random initialization is used.
[0039] In one embodiment, the step S105 further includes steps S501-S502: S501, using a prediction strategy at the beginning of training to increase the learning rate to a fixed value within a predetermined number of training rounds; S502: Use the cosine annealing strategy to adjust the learning rate in the later stage of training.
[0040] In this embodiment, in the pet detection task, in order to improve the training efficiency and performance of the pet detection network, a specific learning rate adjustment strategy is adopted. The entire training process is divided into two stages: the initial training stage and the later training stage, and the prediction strategy and the cosine annealing strategy are used to adjust the learning rate respectively.
[0041] In the initial stage of training, using a prediction strategy to gradually increase the learning rate to a fixed value within a predetermined number of training rounds (such as 5 rounds) can quickly converge to a better parameter space and avoid slow convergence due to too low a learning rate in the initial stage. Specifically, you can set an initial learning rate and gradually increase it to a specified fixed learning rate within the first 5 rounds according to a certain strategy (such as linear growth).
[0042] Furthermore, the learning rate is gradually reduced in the later stages of training to allow for a more detailed search in the parameter space, to avoid overfitting, and to improve the generalization of the model. That is, after a certain number of training rounds (e.g., after 5 rounds), the learning rate is dynamically adjusted using a cosine annealing strategy. Specifically, the cosine annealing strategy typically starts with a higher initial learning rate and then gradually decreases to a value close to zero according to the shape of the cosine function. In this embodiment, this means that after 5 rounds, the learning rate will be adjusted according to the cosine annealing strategy until the end of training (200 rounds).
[0043] S106, using the trained pet detection network to identify the image to be detected, and judging whether there is a situation where the pet acts alone based on the identification result, and if so, issuing an alarm.
[0044] In this embodiment, a trained pet detection network is used to identify the image to be detected. The pet detection network will output a prediction result, including whether a pet exists and the category of the pet (if the network is designed to be able to recognize multiple pets). Then, based on the recognition result, it is determined whether the pet is acting alone (this may require additional logical judgment, such as based on the location, time, and other information of the pet). If a pet is detected to be acting alone, an alarm mechanism is triggered to notify relevant personnel.
[0045] In one embodiment, the step S106 includes steps S601-S602: S601, obtaining prediction results, wherein the prediction results are expressed as follows: ,in, Represents the center coordinates of the predicted rectangular box, , Respectively represent the height and width of the predicted rectangular box, represents the predicted category, Indicates the confidence of the prediction; S602: Determine whether the pet is acting alone according to the following formula. If so, issue an alarm and output the recognized image data: , where Others represents other situations and Normal represents normal. Represents all prediction results with confidence greater than 0.5. Indicates that when the prediction results include only cats or dogs and not humans, Indicates the image to be detected returned by the k-th camera at time j.
[0046] In this embodiment, in the inference and recognition stage, the trained pet detection network is used to infer the image returned by the camera (the image to be detected). Based on the training process of the pet detection network described above, it can be seen that for the input image, the model's prediction result is a prediction set of three categories of objects: cats, dogs, and people. In the post-processing stage, this embodiment filters out all model prediction rectangles with confidence greater than 0.5 and outputs them as , then judge The camera detects whether the image contains only cats or dogs but no people. If so, it is considered that a pet is acting alone in the image. If the same camera detects a pet acting alone three times in a row in the images returned by the camera, an alarm is triggered and the image and the alarm are output.
[0047] In summary, if Figure 7 As shown in the figure, a schematic diagram of the algorithm flow of the public area pet recognition method based on self-supervised training is shown. Specifically, the algorithm framework used mainly includes two parts, namely, self-supervised training of the backbone network using an unlabeled dataset, and supervised training of the pet detection network using a pet detection dataset. The specific architecture is as described above and will not be described in detail here.
[0048] like Figure 8 As shown, the embodiment of the present invention further provides a public area pet identification device 700 based on self-supervised training, which may include: The preprocessing unit 701 is used to collect image data from online cameras and preprocess the image data to obtain an unlabeled data set; A data collection unit 702 is used to collect and annotate image data in a security monitoring database to obtain a pet detection data set; A construction unit 703 is used to construct a pet detection network, wherein the pet detection network includes a backbone network, a pyramid network and a target detection head; A self-supervised training unit 704, configured to perform self-supervised training on the backbone network using the unlabeled data set; A supervised training unit 705 is used to perform supervised training on the pet detection network using the pet detection data set to obtain a trained pet detection network; The recognition and alarm unit 706 is used to use the trained pet detection network to recognize the image to be detected, and determine whether there is a situation where the pet acts alone based on the recognition result. If so, an alarm is issued.
[0049] The public area pet identification device based on self-supervised training provided by the embodiment of the present invention trains the feature extraction capability of the pet detection network encoder on an unlabeled data set through a self-supervised training method, and then uses the pet detection data set to train the pet detection network to perform recognition capabilities for objects of specific categories, thereby achieving the goal of using low-cost unlabeled data to enhance the performance of the pet detection network, effectively solving the problem of identifying pets in the camera, which not only reduces costs and improves efficiency, but also further improves the management capabilities and service levels of the community.
[0050] The embodiment of the present invention also provides a public area pet identification device based on self-supervised training, which can be implemented in the form of a computer program. The computer program can be used in Fig. 9 Runs on the computer device shown.
[0051] See also Fig. 9 , Fig. 9 800 is a schematic block diagram of a computer device provided by an embodiment of the present invention. The computer device 800 is a server, which can be an independent server or a server cluster composed of multiple servers.
[0052] See also Fig. 9 The computer device 800 includes a processor 802 , a memory and a network interface 805 connected via a system bus 801 , wherein the memory may include a non-volatile storage medium 803 and an internal memory 804 .
[0053] The non-volatile storage medium 803 may store an operating system 8031 and a computer program 8032. When the computer program 8032 is executed, the processor 802 may execute a public area pet recognition method based on self-supervised training.
[0054] The processor 802 is used to provide computing and control capabilities and support the operation of the entire computer device 800.
[0055] The internal memory 804 provides an environment for the operation of the computer program 8032 in the non-volatile storage medium 803. When the computer program 8032 is executed by the processor 802, the processor 802 can execute the public area pet recognition method based on self-supervised training.
[0056] The network interface 805 is used for network communication, such as providing data information transmission, etc. Those skilled in the art will understand that Fig. 9 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present invention, and does not constitute a limitation on the computer device 800 to which the solution of the present invention is applied. The specific computer device 800 may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0057] The processor 802 is used to run the computer program 8032 stored in the memory to implement the following functions: Collect image data from online cameras and preprocess the image data to obtain an unlabeled data set; Collect and annotate image data from the security monitoring database to obtain a pet detection dataset; Constructing a pet detection network, wherein the pet detection network includes a backbone network, a pyramid network and a target detection head; Performing self-supervisory training on the backbone network using the unlabeled dataset; Performing supervised training on the pet detection network using the pet detection data set to obtain a trained pet detection network; The trained pet detection network is used to identify the image to be detected, and it is determined based on the recognition result whether there is a situation where the pet acts alone. If so, an alarm is issued.
[0058] Those skilled in the art will understand that Fig. 9 The embodiments of the computer device shown in the figure do not constitute a limitation on the specific composition of the computer device. In other embodiments, the computer device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. For example, in some embodiments, the computer device may only include a memory and a processor. In such embodiments, the structure and function of the memory and the processor are the same as those of the embodiment of the present invention. Figure 1 The embodiments shown are consistent and will not be described again here.
[0059] It should be understood that in the embodiment of the present invention, the processor 802 may be a central processing unit (CPU), and the processor 802 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0060] In another embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium may be a non-volatile computer-readable storage medium. The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the following steps are implemented: Collect image data from online cameras and preprocess the image data to obtain an unlabeled data set; Collect and annotate image data from the security monitoring database to obtain a pet detection dataset; Constructing a pet detection network, wherein the pet detection network includes a backbone network, a pyramid network and a target detection head; Performing self-supervisory training on the backbone network using the unlabeled dataset; Performing supervised training on the pet detection network using the pet detection data set to obtain a trained pet detection network; The trained pet detection network is used to identify the image to be detected, and it is determined based on the recognition result whether there is a situation where the pet acts alone. If so, an alarm is issued.
[0061] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the above-described equipment, devices and units can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. Those of ordinary skill in the art can appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented with electronic hardware, computer software or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to the function. Whether these functions are executed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present invention.
[0062] In the several embodiments provided by the present invention, it should be understood that the disclosed equipment, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. Units with the same function may also be combined into one unit. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interfaces, devices or units, or may be an electrical, mechanical or other form of connection.
[0063] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of the present invention.
[0064] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0065] If the integrated 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 storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), disk or optical disk and other media that can store program code.
[0066] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A method for identifying pets in public areas based on self-supervised training, characterized in that: include: Collect image data from online cameras and preprocess the image data to obtain an unlabeled data set; Collect and annotate image data from the security monitoring database to obtain a pet detection dataset; Constructing a pet detection network, wherein the pet detection network includes a backbone network, a pyramid network and a target detection head; Performing self-supervisory training on the backbone network using the unlabeled dataset; Performing supervised training on the pet detection network using the pet detection data set to obtain a trained pet detection network; The trained pet detection network is used to identify the image to be detected, and it is determined based on the recognition result whether there is a situation where the pet acts alone. If so, an alarm is issued.
2. The method for identifying pets in public areas based on self-supervised training according to claim 1, characterized in that: The using the unlabeled data set to perform self-supervisory training on the backbone network includes: Cutting the initial image in the unlabeled data set into blocks to obtain a plurality of image blocks; Randomly cover some of the image blocks in the plurality of image blocks according to the following formula: , where I represents a set of several image blocks, represents the i-th image block, and E represents the expectation; Encode the unmasked image blocks using an encoder; The encoded image block and the masked image block are combined and input into a decoder, and the encoded image block is reconstructed by the decoder to obtain a restored image; The reconstruction loss is calculated using the following formula, and the encoder is trained according to the reconstruction loss to obtain the encoder weight: ,in, represents the reconstruction loss, and Respectively represent the mean and variance of the image block to be reconstructed, is the minimum value, H and W are the height and width of the image block to be reconstructed respectively. represents the calculated value of the image block in the initial image, Represents the calculated value of the image block in the restored image.
3. The method for identifying pets in public areas based on self-supervised training according to claim 1, characterized in that: The self-supervised training of the backbone network using the unlabeled data set also includes: Use a prediction strategy to set the learning rate to a specified value for a predetermined number of training epochs at the beginning of training; Use cosine annealing strategy to adjust the learning rate in the later stages of training; Data augmentation methods are used to reduce overfitting in the backbone network.
4. The method for identifying pets in public areas based on self-supervised training according to claim 2, characterized in that: The method of using the pet detection data set to perform supervised training on the pet detection network to obtain a trained pet detection network includes: Migrating the encoder weights obtained through self-supervised training to the backbone network of the pet detection network, wherein the backbone network has the same structure as the encoder; Randomly initializing the pyramid network and the object detection head; The pet detection network is trained using the pet detection dataset.
5. The method for identifying pets in public areas based on self-supervised training according to claim 1, characterized in that: The method uses the trained pet detection network to identify the image to be detected, and determines whether there is a situation where the pet acts alone according to the identification result. If so, an alarm is issued, including: Get the prediction result, where the prediction result is expressed as follows: ,in, Represents the center coordinates of the predicted rectangular box, , Respectively represent the height and width of the predicted rectangular box, represents the predicted category, Indicates the confidence of the prediction; Use the following formula to determine whether a pet is acting alone. If so, issue an alarm and output the recognized image data: , where Others represents other situations and Normal represents normal. Represents all prediction results with confidence greater than 0.
5. Indicates that when the prediction results include only cats or dogs and not humans, Indicates the image to be detected returned by the k-th camera at time j.
6. The method for identifying pets in public areas based on self-supervised training according to claim 1, characterized in that: The backbone network includes a plurality of stacked Transformer modules, wherein the feature map scale of each Transformer module is downsampled 16 times the input image size, the pyramid network includes a plurality of sampling modules, and the plurality of sampling modules in the pyramid network are connected to the output of the backbone network, and the target detection head is a YOLOv11 detection head.
7. The method for identifying pets in public areas based on self-supervised training according to claim 1, characterized in that: The method of using the pet detection data set to perform supervised training on the pet detection network to obtain a trained pet detection network includes: Use a prediction strategy to increase the learning rate to a fixed value within a predetermined number of training rounds at the beginning of training; The learning rate is adjusted using a cosine annealing strategy in the later stages of training.
8. A public area pet identification device based on self-supervised training, characterized in that: include: A preprocessing unit, used to collect image data from online cameras and preprocess the image data to obtain an unlabeled data set; A data collection unit is used to collect and annotate image data in a security monitoring database to obtain a pet detection data set; A construction unit, used to construct a pet detection network, wherein the pet detection network includes a backbone network, a pyramid network and a target detection head; A self-supervised training unit, used to perform self-supervised training on the backbone network using the unlabeled data set; A supervised training unit, used to perform supervised training on the pet detection network using the pet detection data set to obtain a trained pet detection network; The recognition and alarm unit is used to use the trained pet detection network to recognize the image to be detected, and determine whether there is a situation where the pet acts alone according to the recognition result. If so, an alarm is issued.
9. A computer 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, the method for identifying pets in public areas based on self-supervised training as described in any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, causes the processor to perform the public area pet recognition method based on self-supervised training as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Intelligent community personalized target detection model training method and training system
CN116453057A
Underwater weak and small target detection method based on Swin Transform
CN117710801A
Visual processing and model training methods, device, storage medium and program product
WO2023159819A1