Image recognition based method and system for identifying working status of knife switch

The knife gate working status identification method optimized through the image correction model and particle swarm optimization algorithm solves the problems of low efficiency and environmental factors of the traditional method, and achieves higher identification accuracy and reliability. Through image correction and prior knowledge The combination improves the recognition effect.

CN118570565BActive Publication Date: 2024-10-22NANCHANG POWER SUPPLY BRANCH OF STATE GRID JIANGXI ELECTRIC POWER CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411049356.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-01
Publication Date
2024-10-22
Estimated Expiration
2044-08-01

AI Technical Summary

Technical Problem

The traditional method of identifying the working status of the knife gate is inefficient and susceptible to human factors. Environmental factors such as changes in lighting affect the accuracy and reliability of the identification, resulting in insufficient accuracy and real-time performance of the identification results.

Method used

The image correction model is used to correct the knife gate image. Combining the environmental data and the image adjustment parameter vector, through image feature extraction, feature splicing and weight matrix generation and other levels of processing, the knife gate corrected image is generated and input into the working status recognition model. For recognition, BP neural network and particle swarm optimization algorithm are used to optimize image adjustment parameters to improve recognition accuracy.

Benefits of technology

It effectively reduces the impact of the environment on the recognition of the working status of the knife gate, improves the accuracy and reliability of recognition, improves the image correction effect by introducing prior knowledge and cooperation mechanisms, and enhances the stability and efficiency of the recognition model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118570565B_ABST
    Figure CN118570565B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of image processing, and in particular to a method and system for identifying the working state of a knife switch based on image recognition. A system for identifying the working state of a knife switch based on image recognition comprises: a knife switch image acquisition module, an environmental data acquisition module, an environmental impact analysis module, an image correction module and a knife switch working state recognition module. The present invention corrects the knife switch image affected by the environment through an image correction model, and identifies the working state of the knife switch based on the corrected knife switch correction image, which can effectively reduce the impact of the environment on the identification of the working state of the knife switch, and inputs an image adjustment parameter vector during the use of the image correction model, which can realize the introduction of prior knowledge to achieve a better image correction effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the field of image processing, and in particular to a method and system for identifying the working state of a knife switch based on image recognition. Background Art

[0002] As an important switching device in the power system, the knife switch is widely used in the power transmission and distribution network, and undertakes the key function of cutting off or connecting the current. The working state of the knife switch directly affects the safety and stability of the power system. Therefore, it is particularly important to identify the working state of the knife switch in a timely and accurate manner. Traditional methods for identifying the working state of the knife switch mainly rely on manual inspections and mechanical sensors. These methods are not only inefficient, but also easily affected by human factors, resulting in insufficient accuracy and real-time performance of the identification results.

[0003] With the development of computer vision and image recognition technology, the recognition method of the working state of the knife switch based on image recognition has gradually become a hot topic. However, environmental factors have a significant impact on the recognition accuracy and reliability of the working state of the knife switch. For example, changes in lighting conditions (such as strong light, shadows, insufficient lighting at night, etc.) may cause image quality to deteriorate, thereby affecting the performance of the recognition algorithm. Summary of the invention

[0004] The present invention corrects the knife switch image affected by the environment through an image correction model, and identifies the knife switch working state based on the corrected knife switch correction image, which can effectively reduce the influence of the environment on the identification of the knife switch working state. In addition, an image adjustment parameter vector is input during the use of the image correction model, which can introduce prior knowledge to achieve better image correction effect.

[0005] A method for identifying a knife switch working state based on image recognition, comprising:

[0006] Get the knife switch image;

[0007] Obtain environmental data;

[0008] The environmental data is sent to the environmental impact analysis model for processing, and an image adjustment parameter vector is output, where the image adjustment parameter vector includes various image adjustment parameters;

[0009] The knife gate image, environmental data and image adjustment parameter vector are sent to the image correction model for processing, and the knife gate correction image is output;

[0010] The image correction model includes an image feature extraction layer, a first feature splicing layer, a feature map construction layer, a second feature splicing layer, a weight matrix map generation layer, a feature enhancement layer and an output layer, wherein the image feature extraction layer is used to receive a knife switch image and perform feature extraction, and output an image feature vector; the first feature splicing layer is used to splice the image feature vector and the environmental data to construct a first fused feature vector; the feature map construction layer is used to perform a deconvolution operation on the first fused feature vector to construct a knife switch feature map; the second feature splicing layer is used to splice the image adjustment parameter vector and the image feature vector to construct a second fused feature vector; the weight matrix map generation layer is used to perform a deconvolution operation on the second fused feature vector to construct a weight matrix map; the feature enhancement layer is used to perform feature enhancement on the knife switch feature map based on the weight matrix map to construct a knife switch correction image; the output layer is used to output the knife switch correction image;

[0011] The knife switch corrected image is sent to the knife switch working state recognition model for processing, and the knife switch working state is output.

[0012] Preferably, the environmental impact analysis model is established based on the BP neural network, and the specific training steps are as follows:

[0013] A plurality of environmental impact analysis training samples are obtained, the environmental impact analysis training samples include environmental data and corresponding optimal image adjustment parameter vectors, and the optimal image adjustment parameter vectors corresponding to the environmental data are simulated by a particle swarm optimization algorithm; all environmental impact analysis training samples are combined into an environmental impact analysis training set, and then the environmental impact analysis training set is sent to a parameter-initialized environmental impact analysis model for training, and the optimal image adjustment parameter vector is used as a target to obtain the accuracy of the environmental impact analysis model. If the accuracy of the environmental impact analysis model is higher than a first preset value, the trained environmental impact analysis model is output; otherwise, the environmental impact analysis model is continuously trained through the environmental impact analysis training set.

[0014] Preferably, for each type of environmental data, the optimal image adjustment parameter vector corresponding to the environmental data is obtained by simulating using a particle swarm optimization algorithm, including the following steps:

[0015] Step S1: Generate a number of simulated particles, including {x1, x2, x3, ..., x i , …, x I}, where i=1,2,3,…,I;x i is the image adjustment parameter, I is the total number of image adjustment parameters, and then all simulated particles are grouped into a population set, and the maximum number of iterations T is set;

[0016] Step S2: Let t = 1, where t is used to record the number of iterations;

[0017] Step S3: Calculate the fitness of each simulated particle, select the simulated particle with the largest fitness and store it in the optimal simulated particle library, retain the simulated particle with the largest fitness in the current optimal simulated particle library, delete the remaining simulated particles in the optimal simulated particle library, and then record the simulated particle in the current optimal simulated particle library as gbest;

[0018] Step S4: For each simulated particle, select the simulated particle with the largest fitness in the historical iteration as pbest, and adjust the simulated particle using the following formula:

[0019] ;

[0020] ;

[0021] Among them, v i (t) is the image adjustment parameter x i The speed corresponding to the current iteration; w is the inertia weight; pbest i To simulate the parameters of the i-th image in the particle pbest, c1 is the individual learning factor, r1 is a random number in (0,1); gbest i is the i-th image adjustment parameter in the simulated particle gbest, c2 is the social learning factor, r2 is a random number in (0,1); δ is the cooperation coefficient, which is determined by the fitness change of the simulated particle and the distance from the simulated particle gbest; N is the neighbor set of the simulated particle, which refers to the set of other simulated particles whose distance from the simulated particle is within the preset range, and Y j Adjust parameters for the i-th image of the j-th simulated particle in the neighbor set N;

[0022] Step S5: Determine whether t<T holds. If so, assign t+1 to t and return to step S3. If not, proceed to step S6.

[0023] Step S6: taking the simulated particle with the largest fitness in the optimal simulated particle library as the optimal image adjustment parameter vector corresponding to the environmental data.

[0024] Preferably, calculating the fitness corresponding to each simulated particle specifically includes the following steps:

[0025] Under the environment corresponding to the environmental data, several knife switch images are collected, and all the collected knife switch images are adjusted by the image adjustment parameters corresponding to the simulated particles. Then all the adjusted knife switch images are processed by the knife switch working state recognition model, and the ratio between the number of knife switch images with accurate knife switch working state judgment and the number of all knife switch images is used as the fitness corresponding to the simulated particles.

[0026] Preferably, the cooperation coefficient δ=(1 / (k1ΔF+k2ΔL)), ΔF is x i The fitness difference between the corresponding simulated particle and the current simulated particle, ΔL is x i The distance difference between the corresponding simulated particle and the simulated particle gbest, k1 and k2 are weight coefficients, and k1+k2=1 is satisfied.

[0027] Preferably, the feature enhancement layer is used to enhance the features of the knife switch feature map based on the weight matrix map to construct a knife switch correction image, which specifically includes the following steps:

[0028] In the feature enhancement layer, the key matrix K and the value matrix V are constructed based on the knife switch feature map. The specific operation is to multiply the knife switch feature map with the key weight matrix and the value weight matrix respectively; the query matrix Q is constructed based on the weight matrix map. The specific operation is to multiply the weight matrix map with the query weight matrix; calculate the attention weight matrix ATT=softmax(QKT / (D) 0.5 ), where D is the dimension of the knife switch feature map, the attention weight matrix ATT is multiplied by the value matrix V and then a convolution operation is performed to construct the knife switch correction image.

[0029] Preferably, training the image correction model and the switch working state recognition model includes the following steps:

[0030] Acquire a number of knife switch working state recognition training samples, the knife switch working state recognition training samples include knife switch images obtained under a standard environment; annotate the knife switch working state recognition training samples according to the knife switch working state, and then form a knife switch working state recognition training set with all the annotated knife switch working state recognition training samples, send the knife switch working state recognition training set to a parameter-initialized knife switch working state recognition model for training, take the knife switch working state as a target, obtain the accuracy of the knife switch working state recognition model, if the accuracy of the knife switch working state recognition model is higher than a second preset value, output the trained knife switch working state recognition model; otherwise, continue to train the knife switch working state recognition model according to the knife switch working state recognition training set;

[0031] Select the feature extraction layer in the trained knife switch working state recognition model to initialize the parameters of the image feature extraction layer in the image correction model, and obtain several image correction training samples, the image correction training samples include real knife switch images and processed knife switch images, the real knife switch images refer to the knife switch images obtained under the standard environment, and the processed knife switch images refer to the knife switch images obtained again under the modified environment conditions; all image correction training samples are combined into an image correction training set, and then the image correction training set is sent to the parameter-initialized image correction model for training, with the processed knife switch image as input and the real knife switch image as the target, to obtain the accuracy of the image correction model, if the accuracy of the image correction model is higher than the third preset value, then output the trained image correction model; otherwise, continue to train the image correction model through the image correction training set.

[0032] The present invention also provides a knife switch working state recognition system based on image recognition, comprising:

[0033] A knife switch image acquisition module, used for acquiring a knife switch image;

[0034] An environmental data acquisition module, used to acquire environmental data;

[0035] An environmental impact analysis module is used to send environmental data to an environmental impact analysis model for processing and output an image adjustment parameter vector, wherein the image adjustment parameter vector includes various image adjustment parameters;

[0036] An image correction module is used to send the knife switch image, environmental data and image adjustment parameter vector into the image correction model for processing and output a knife switch correction image;

[0037] The knife switch working state recognition module is used to send the knife switch correction image to the knife switch working state recognition model for processing and output the knife switch working state.

[0038] The present invention has the following advantages:

[0039] 1. The present invention corrects the knife switch image affected by the environment through an image correction model, and identifies the knife switch working state based on the corrected knife switch correction image, which can effectively reduce the influence of the environment on the identification of the knife switch working state. In addition, an image adjustment parameter vector is input during the use of the image correction model, which can introduce prior knowledge to achieve better image correction effects.

[0040] 2. The present invention simulates and calculates the optimal image adjustment parameter vectors corresponding to different environmental data through the particle swarm optimization algorithm, and then trains the environmental impact analysis model based on the environmental data and the corresponding optimal image adjustment parameter vectors. It can integrate the effective image adjustment parameters into the image correction model as prior knowledge, thereby achieving better image correction effect; and improves the particle swarm optimization algorithm, introduces a cooperation mechanism, and can flexibly adjust the behavior between particles in different search stages, thereby improving the ability to explore solutions. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 It is a structural schematic diagram of a knife switch working state recognition system based on image recognition adopted in an embodiment of the present invention. DETAILED DESCRIPTION

[0042] In order to enable persons skilled in the art to better understand the technical solutions in the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention.

[0043] Embodiment 1, a method for identifying the working state of a knife switch based on image recognition, comprising:

[0044] Obtain the knife switch image. The knife switch image is obtained by a camera installed near the knife switch. Since the working status recognition of the knife switch will be affected by the shooting angle, the position of the camera is set by the user according to the installation situation of the knife switch, which can avoid the influence of the camera shooting angle;

[0045] Environmental data is obtained through sensors installed near the knife switch. Environmental data includes data that may affect image recognition, such as light intensity, visibility, and temperature near the knife switch. Under the influence of these environmental data, the working status of the knife switch may be misjudged, leading to safety accidents. Therefore, the influence of these environmental data needs to be eliminated.

[0046] The environmental data is sent to the environmental impact analysis model for processing, and an image adjustment parameter vector is output. The image adjustment parameter vector includes various image adjustment parameters, such as image brightness adjustment parameters, contrast adjustment parameters and color correction parameters, among which the image brightness adjustment parameters can adjust the brightness of the image according to the real-time weather conditions (such as cloudy, sunny, rainy), such as increasing the brightness under dim light conditions; the contrast adjustment parameters can increase the contrast of the image under uneven lighting conditions to highlight the difference between the target object and the background; the color correction parameters can adjust the color balance of the image under lighting conditions that cause color deviation to ensure the naturalness of the color; the image adjustment parameters can assist subsequent image correction operations;

[0047] The knife gate image, environmental data and image adjustment parameter vector are sent to the image correction model for processing, and the knife gate correction image is output. In the image correction model, the influence of environmental data on the knife gate image can be learned based on deep learning, and this influence can be weakened by image correction.

[0048] The image correction model includes an image feature extraction layer, a first feature splicing layer, a feature map construction layer, a second feature splicing layer, a weight matrix map generation layer, a feature enhancement layer and an output layer, wherein the image feature extraction layer is established based on a CNN network, and is used to receive a knife switch image and perform feature extraction, and output an image feature vector; the first feature splicing layer is used to splice the image feature vector and the environmental data to construct a first fused feature vector; the feature map construction layer is established based on a decoder in a U-net network, and is used to perform a deconvolution operation on the first fused feature vector to construct a knife switch feature map. In the process of the deconvolution operation, a knife switch feature map with the same size as the knife switch image can be constructed based on the first fused feature vector. The feature map is used to realize the preliminary image correction operation on the knife switch image; the second feature splicing layer is used to splice the image adjustment parameter vector and the image feature vector to construct the second fused feature vector; the weight matrix map generation layer is also established based on the decoder in the U-net network, and is used to perform a deconvolution operation on the second fused feature vector to construct a weight matrix map. The weight matrix map can reflect the image adjustment strategy for different areas in the knife switch image; the feature enhancement layer is used to enhance the features of the knife switch feature map based on the weight matrix map to construct a knife switch correction image. The feature enhancement operation can learn the image adjustment strategy in the weight matrix map, thereby realizing further image correction operations; the output layer is used to output the knife switch correction image;

[0049] It should be added that the construction of the knife gate feature map through the first feature splicing layer and the feature map construction layer reflects the first environmental data fusion, and the construction of the knife gate correction image through the second feature splicing layer, the weight matrix map generation layer and the feature enhancement layer reflects the second environmental data fusion. The difference is that the first environmental data fusion directly fuses the environmental data through feature learning, while the second environmental data fusion is based on the image adjustment parameter vector as prior knowledge. The image adjustment parameter vector can reflect the image adjustment strategy in different environments and provide a priori reference for image correction. The coordination of the two environmental data fusions can improve the effect of image correction.

[0050] The knife switch corrected image is sent to the knife switch working state recognition model for processing, and the knife switch working state is output. The knife switch working state includes closing and opening, so as to realize the recognition of the knife switch working state. The knife switch working state recognition model is established based on the YoLov7 model.

[0051] The present application uses an image correction model to correct the knife switch image affected by the environment, and identifies the knife switch working status based on the corrected knife switch correction image, which can effectively reduce the impact of the environment on the identification of the knife switch working status. In addition, an image adjustment parameter vector is input during the use of the image correction model, which can introduce prior knowledge to achieve better image correction effects.

[0052] The environmental impact analysis model is established based on the BP neural network. The specific training steps are as follows:

[0053] A number of environmental impact analysis training samples are obtained. The environmental impact analysis training samples include environmental data and corresponding optimal image adjustment parameter vectors. The optimal image adjustment parameter vectors corresponding to the environmental data are simulated by a particle swarm optimization algorithm. In the preparation stage of the environmental impact analysis training samples, the developers will collect data for the environment in which the knife switch is located, and then simulate the optimal image adjustment parameter vectors corresponding to each type of environmental data by a particle swarm optimization algorithm based on the actually collected environmental data. All environmental impact analysis training samples are combined into an environmental impact analysis training set, and then the environmental impact analysis training set is sent to a parameter-initialized environmental impact analysis model for training. The optimal image adjustment parameter vector is used as a target to obtain the accuracy of the environmental impact analysis model. If the accuracy of the environmental impact analysis model is higher than a first preset value, which is set by the developer, the trained environmental impact analysis model is output; otherwise, the environmental impact analysis model is continuously trained by the environmental impact analysis training set.

[0054] For each type of environmental data, the optimal image adjustment parameter vector corresponding to the environmental data is simulated by the particle swarm optimization algorithm, including the following steps:

[0055] Step S1: Generate a number of simulated particles, including {x1, x2, x3, ..., x i , …, x I}, where i=1,2,3,…,I;x i is the image adjustment parameter, I is the total number of image adjustment parameters, and then all simulated particles are grouped into a population set, and the maximum number of iterations T is set;

[0056] Step S2: Let t = 1, where t is used to record the number of iterations;

[0057] Step S3: Calculate the fitness of each simulated particle, select the simulated particle with the largest fitness and store it in the optimal simulated particle library, retain the simulated particle with the largest fitness in the current optimal simulated particle library, delete the remaining simulated particles in the optimal simulated particle library, and then record the simulated particle in the current optimal simulated particle library as gbest;

[0058] Calculate the fitness corresponding to each simulated particle, including the following steps:

[0059] Under the environment corresponding to the environmental data, several knife gate images are collected, and all the collected knife gate images are adjusted by the image adjustment parameters corresponding to the simulated particles, and then all the adjusted knife gate images are processed by the knife gate working state recognition model, and the ratio between the number of knife gate images with accurate knife gate working state judgment and the number of all knife gate images is used as the fitness corresponding to the simulated particles. The ratio between the number of knife gate images with accurate knife gate working state judgment and the number of all knife gate images can reflect the confidence of the image adjustment parameters corresponding to the simulated particles for the image adjustment of the knife gate images. The higher the fitness, the more suitable the image adjustment parameters corresponding to the simulated particles are for the knife gate image adjustment.

[0060] Step S4: For each simulated particle, select the simulated particle with the largest fitness in the historical iteration as pbest, and adjust the simulated particle using the following formula:

[0061] ;

[0062] ;

[0063] Among them, v i (t) is the image adjustment parameter x i The speed corresponding to the current iteration; w is the inertia weight, which is used to control the degree to which the simulated particles maintain their original speed during the search process and is set by the developer; pbest i To simulate the parameters of the i-th image in the particle pbest, c1 is the individual learning factor, which is determined by the developer and is generally between 0 and 2. r1 is a random number in (0,1); gbest i is the adjustment parameter of the i-th image in the simulated particle gbest, c2 is the social learning factor, which is determined by the developer and is generally between 0 and 2, r2 is a random number in (0,1); δ is the cooperation coefficient, which is determined by the fitness change of the simulated particle and the distance from the simulated particle gbest; N is the neighbor set of the simulated particle, which refers to the set of other simulated particles whose distance from the simulated particle is within the preset range, and the preset range is determined by the developer, Y j Adjust parameters for the i-th image of the j-th simulated particle in the neighbor set N;

[0064] The cooperation coefficient δ = (1 / (k1ΔF+k2ΔL)), ΔF is x i The fitness difference between the corresponding simulated particle and the current simulated particle, ΔL is x iThe distance difference between the corresponding simulated particle and the simulated particle gbest. The distance calculation can be based on the Euclidean distance. k1 and k2 are weight coefficients, and k1+k2=1 is satisfied.

[0065] By pbest i The combination of c1 and r1 can encourage the simulated particles to move toward their historical best positions, thereby using existing experience to improve the current solution; i The combination of , c2 and r2 can encourage the simulated particles to move toward the global optimal position so as to use the knowledge of the entire particle group to find a better solution; through δ and Y j The combination of terms can affect the speed of particles by simulating the neighbor set of particles, promote information sharing and cooperation between particles, and when near the global optimal solution, the fitness changes little, and the distance between the simulated particle gbest also changes little. Correspondingly, the cooperation coefficient δ will be larger, and the simulated particles will rely more on the performance of their neighbors. On the contrary, when far away from the global optimal solution, the cooperation coefficient may decrease, and particles will be more inclined to explore independently, thus achieving the effect of wide search in the early stage and fast convergence in the later stage.

[0066] Step S5: Determine whether t<T holds. If so, it means that the iteration has not been completed, assign t+1 to t, and return to step S3; if t<T does not hold, it means that the iteration is completed, and go to step S6;

[0067] Step S6: taking the simulated particle with the largest fitness in the optimal simulated particle library as the optimal image adjustment parameter vector corresponding to the environmental data.

[0068] This application uses a particle swarm optimization algorithm to simulate and calculate the optimal image adjustment parameter vectors corresponding to different environmental data, and then trains the environmental impact analysis model based on the environmental data and the corresponding optimal image adjustment parameter vectors. It is possible to integrate effective image adjustment parameters as prior knowledge into the image correction model, thereby achieving better image correction effects; and the particle swarm optimization algorithm is improved by introducing a cooperation mechanism, which can flexibly adjust the behavior between particles in different search stages, thereby improving the ability to explore solutions.

[0069] The feature enhancement layer is used to enhance the features of the knife switch feature map based on the weight matrix map to construct a knife switch correction image, which specifically includes the following steps:

[0070] In the feature enhancement layer, the key matrix K and the value matrix V are constructed based on the knife switch feature map. The specific operation is to multiply the knife switch feature map with the key weight matrix and the value weight matrix respectively; the query matrix Q is constructed based on the weight matrix map. The specific operation is to multiply the weight matrix map with the query weight matrix; calculate the attention weight matrix ATT=softmax(QKT / (D) 0.5 ), where D is the dimension of the knife switch feature map, the attention weight matrix ATT is multiplied by the value matrix V and then a convolution operation is performed to construct the knife switch correction image; the key weight matrix, value weight matrix and query weight matrix are set with reference to the Transformer model.

[0071] Training the image correction model and the switch working state recognition model includes the following steps:

[0072] Obtain a number of knife switch working state recognition training samples, the knife switch working state recognition training samples include knife switch images obtained under a standard environment, and the standard environment refers to an environment that will not affect the quality of the knife switch image; annotate the knife switch working state recognition training samples according to the knife switch working state, and then form a knife switch working state recognition training set with all the annotated knife switch working state recognition training samples, send the knife switch working state recognition training set to a parameter-initialized knife switch working state recognition model for training, take the knife switch working state as a target, obtain the accuracy of the knife switch working state recognition model, if the accuracy of the knife switch working state recognition model is higher than a second preset value, the second preset value is set by the developer, then output the trained knife switch working state recognition model; otherwise, continue to train the knife switch working state recognition model through the knife switch working state recognition training set;

[0073] The feature extraction layer in the trained knife switch working state recognition model is selected to initialize the parameters of the image feature extraction layer in the image correction model. It should be noted that the knife switch working state recognition model is established based on the YoLov7 model, and the Backbone in the YoLov7 model is the feature extraction layer. Several image correction training samples are obtained, and the image correction training samples include real knife switch images and processed knife switch images. The real knife switch image refers to the knife switch image obtained under the standard environment, and the processed knife switch image refers to the knife switch image obtained again under the modified environmental conditions. The modified environmental conditions refer to the environmental adjustments made under the standard environmental conditions, such as modifying the lighting. All image correction training samples are combined into an image correction training set, and then the image correction training set is sent to the parameter-initialized image correction model for training, with the processed knife switch image as input and the real knife switch image as the target, to obtain the accuracy of the image correction model. If the accuracy of the image correction model is higher than the third preset value, which is set by the developer, the trained image correction model is output; otherwise, the image correction model is continuously trained through the image correction training set.

[0074] Embodiment 2, a knife switch working state recognition system based on image recognition, such as Figure 1 As shown, including:

[0075] The knife switch image acquisition module is used to acquire the knife switch image. The knife switch image is acquired by a camera installed near the knife switch. Since the working state recognition of the knife switch is affected by the shooting angle, the position of the camera is set by the user according to the installation situation of the knife switch, which can avoid the influence of the camera shooting angle.

[0076] The environmental data acquisition module is used to acquire environmental data through sensors arranged near the knife switch. The environmental data includes data that may affect image recognition, such as light intensity, visibility and temperature near the knife switch. Under the influence of these environmental data, the working status recognition of the knife switch may be misjudged, leading to the occurrence of safety accidents. Therefore, it is necessary to eliminate the influence of these environmental data;

[0077] The environmental impact analysis module is used to send environmental data to the environmental impact analysis model for processing and output an image adjustment parameter vector. The image adjustment parameter vector includes various image adjustment parameters, such as image brightness adjustment parameters, contrast adjustment parameters and color correction parameters, among which the image brightness adjustment parameters can adjust the brightness of the image according to real-time weather conditions (such as cloudy, sunny, and rainy days), such as increasing the brightness under dim light conditions; the contrast adjustment parameters can increase the contrast of the image under uneven lighting conditions to highlight the difference between the target object and the background; the color correction parameters can adjust the color balance of the image under lighting conditions that cause color deviation to ensure the naturalness of the color; the image adjustment parameters can assist subsequent image correction operations;

[0078] The image correction module is used to send the knife switch image, environmental data and image adjustment parameter vector into the image correction model for processing and output the knife switch correction image. In the image correction model, the influence of environmental data on the knife switch image can be learned based on deep learning, and this influence can be weakened by image correction.

[0079] The knife switch working state recognition module is used to send the knife switch correction image into the knife switch working state recognition model for processing and output the knife switch working state. The knife switch working state includes closing and opening, so as to realize the recognition of the knife switch working state. The knife switch working state recognition model is established based on the YoLov7 model.

[0080] It should be understood that those skilled in the art can make improvements or changes based on the above description, and all such improvements and changes should fall within the scope of protection of the appended claims of the present invention. Parts not described in detail in this specification belong to the prior art known to those skilled in the art.

Claims

1. A method for identifying the working status of a knife switch based on image recognition. It is characterized in that include: Get the knife switch image; Obtain environmental data; The environmental data is sent to the environmental impact analysis model for processing, and an image adjustment parameter vector is output, where the image adjustment parameter vector includes various image adjustment parameters; The knife gate image, environmental data and image adjustment parameter vector are sent to the image correction model for processing, and the knife gate correction image is output; The image correction model includes an image feature extraction layer, a first feature splicing layer, a feature map construction layer, a second feature splicing layer, a weight matrix map generation layer, a feature enhancement layer and an output layer, wherein the image feature extraction layer is used to receive the knife gate image and perform feature extraction, and output an image feature vector; The first feature concatenation layer is used to concatenate the image feature vector and the environmental data to construct a first fused feature vector; the feature map construction layer is used to perform a deconvolution operation on the first fused feature vector to construct a knife switch feature map; The second feature concatenation layer is used to concatenate the image adjustment parameter vector and the image feature vector to construct a second fused feature vector; the weight matrix map generation layer is used to perform a deconvolution operation on the second fused feature vector to construct a weight matrix map; the feature enhancement layer is used to perform feature enhancement on the knife switch feature map based on the weight matrix map to construct a knife switch correction image; The output layer is used to output the knife gate correction image; The knife switch correction image is sent to the knife switch working state recognition model for processing, and the knife switch working state is output; The environmental impact analysis model is established based on the BP neural network. The specific training steps are as follows: Acquire a number of environmental impact analysis training samples, the environmental impact analysis training samples include environmental data and corresponding optimal image adjustment parameter vectors, the optimal image adjustment parameter vectors corresponding to the environmental data are simulated by a particle swarm optimization algorithm; all environmental impact analysis training samples form an environmental impact analysis training set, and then send the environmental impact analysis training set to a parameter-initialized environmental impact analysis model for training, taking the optimal image adjustment parameter vector as a target, and obtaining the accuracy of the environmental impact analysis model; if the accuracy of the environmental impact analysis model is higher than a first preset value, output the trained environmental impact analysis model; otherwise, continue to train the environmental impact analysis model through the environmental impact analysis training set; For each type of environmental data, the optimal image adjustment parameter vector corresponding to the environmental data is simulated by the particle swarm optimization algorithm, including the following steps: Step S1: Generate a number of simulated particles, including {x 1 , x 2 , x 3 , …, x i , …, x I }, where i=1,2,3,…,I,x i is the image adjustment parameter, I is the total number of image adjustment parameters, and then all simulated particles are grouped into a population set, and the maximum number of iterations T is set; Step S2: Let t = 1, where t is used to record the number of iterations; Step S3: Calculate the fitness of each simulated particle, select the simulated particle with the largest fitness and store it in the optimal simulated particle library, retain the simulated particle with the largest fitness in the current optimal simulated particle library, delete the remaining simulated particles in the optimal simulated particle library, and then record the simulated particle in the current optimal simulated particle library as gbest; Step S4: For each simulated particle, select the simulated particle with the largest fitness in the historical iteration as pbest, and adjust the simulated particle using the following formula: ; ; Among them, v i (t) is the image adjustment parameter x i The speed corresponding to the current iteration; w is the inertia weight; pbest i To adjust the parameters of the i-th image in the simulated particle pbest, c 1 is the individual learning factor, r 1 A random number in (0,1); gbest i To adjust the parameters of the i-th image in the simulated particle gbest, c 2 is the social learning factor, r 2 is a random number in (0,1); δ is the cooperation coefficient, which is determined by the fitness change of the simulated particle and the distance from the simulated particle gbest; N is the neighbor set of the simulated particle, which refers to the set of other simulated particles whose distance from the simulated particle is within the preset range, and Y j Adjust parameters for the i-th image of the j-th simulated particle in the neighbor set N; Step S5: Determine whether t<T holds. If so, assign t+1 to t and return to step S3. If not, proceed to step S6. Step S6: taking the simulated particle with the largest fitness in the optimal simulated particle library as the optimal image adjustment parameter vector corresponding to the environmental data.

2. According to the method for identifying the working state of a knife switch based on image recognition according to claim 1, It is characterized in that Calculate the fitness corresponding to each simulated particle, including the following steps: Under the environment corresponding to the environmental data, several knife switch images are collected, and all the collected knife switch images are adjusted by the image adjustment parameters corresponding to the simulation particles. Then all the adjusted knife switch images are processed by the knife switch working state recognition model, and the ratio between the number of knife switch images with accurate knife switch working state judgment and the number of all knife switch images is used as the fitness corresponding to the simulation particles.

3. The method for identifying the working state of a knife switch based on image recognition according to claim 2, It is characterized in that Cooperation coefficient δ = (1 / (k 1 ΔF+k 2 ΔL)), ΔF is x i The fitness difference between the corresponding simulated particle and the current simulated particle, ΔL is x i The distance difference between the corresponding simulated particle and the simulated particle gbest, k 1 and k 2 is the weight coefficient and satisfies k 1 +k 2 =1.

4. The method for identifying the working state of a knife switch based on image recognition according to claim 3, It is characterized in that The feature enhancement layer is used to enhance the features of the knife switch feature map based on the weight matrix map to construct a knife switch correction image, which specifically includes the following steps: In the feature enhancement layer, the key matrix K and the value matrix V are constructed based on the knife switch feature map. The specific operation is to multiply the knife switch feature map with the key weight matrix and the value weight matrix respectively; the query matrix Q is constructed based on the weight matrix map. The specific operation is to multiply the weight matrix map with the query weight matrix; Calculate the attention weight matrix ATT=softmax(QKT / (D)) 0.5 ), where D is the dimension of the knife switch feature map, the attention weight matrix ATT is multiplied by the value matrix V and then a convolution operation is performed to construct the knife switch correction image.

5. The method for identifying the working state of a knife switch based on image recognition according to claim 4, It is characterized in that Training the image correction model and the switch working state recognition model includes the following steps: Acquire a number of knife switch working state recognition training samples, the knife switch working state recognition training samples include knife switch images obtained under a standard environment; annotate the knife switch working state recognition training samples according to the knife switch working state, and then form a knife switch working state recognition training set with all the annotated knife switch working state recognition training samples, send the knife switch working state recognition training set to a parameter-initialized knife switch working state recognition model for training, take the knife switch working state as a target, obtain the accuracy of the knife switch working state recognition model, if the accuracy of the knife switch working state recognition model is higher than a second preset value, output the trained knife switch working state recognition model; otherwise, continue to train the knife switch working state recognition model according to the knife switch working state recognition training set; Select the feature extraction layer in the trained knife switch working state recognition model to initialize the parameters of the image feature extraction layer in the image correction model, and obtain several image correction training samples, the image correction training samples include real knife switch images and processed knife switch images, the real knife switch images refer to the knife switch images obtained under the standard environment, and the processed knife switch images refer to the knife switch images obtained again under the modified environment conditions; all image correction training samples are combined into an image correction training set, and then the image correction training set is sent to the parameter-initialized image correction model for training, with the processed knife switch image as input and the real knife switch image as the target, to obtain the accuracy of the image correction model, if the accuracy of the image correction model is higher than the third preset value, then output the trained image correction model; otherwise, continue to train the image correction model through the image correction training set.

6. A knife switch working status recognition system based on image recognition, It is characterized in that The system applies the knife switch working state recognition method based on image recognition as described in any one of claims 1 to 5, comprising: A knife switch image acquisition module, used for acquiring a knife switch image; An environmental data acquisition module, used to acquire environmental data; An environmental impact analysis module is used to send environmental data to an environmental impact analysis model for processing and output an image adjustment parameter vector, wherein the image adjustment parameter vector includes various image adjustment parameters; An image correction module is used to send the knife switch image, environmental data and image adjustment parameter vector into the image correction model for processing and output a knife switch correction image; The knife switch working state recognition module is used to send the knife switch correction image to the knife switch working state recognition model for processing and output the knife switch working state.