A Visual Recognition and Anomaly Detection Method for PLC Cabinet Equipment Status Based on Improved YOLOv12n

By improving the YOLOv12n model and combining the lightweight feature extraction network StarNet and DCGAN data augmentation, the efficiency and accuracy issues of PLC cabinet equipment status detection on resource-constrained devices are solved, achieving efficient and accurate anomaly detection and real-time identification, which is suitable for embedded devices and edge computing platforms.

CN122135109APending Publication Date: 2026-06-02МААНЬШАНЬ АЙРОН ЭНД СТИЛ КО ЛТД
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
МААНЬШАНЬ АЙРОН ЭНД СТИЛ КО ЛТД
Filing Date
2026-03-17
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

Existing deep learning-based PLC cabinet equipment status detection methods have limited computing power and memory on embedded devices and edge computing platforms, making it difficult to run complex large models, resulting in low detection efficiency and insufficient accuracy.

Method used

An improved lightweight YOLOv12n model is adopted, combined with the lightweight feature extraction network StarNet and the deep convolutional generative adversarial network DCGAN, for data augmentation and model optimization, including the use of the Star_Block structure and the lightweight detection head Detect_LSCD, to improve feature representation and bounding box localization accuracy, and the detection results are pushed through the mini-program platform.

Benefits of technology

While ensuring detection accuracy, it significantly improves the model's operating efficiency and detection performance, making it suitable for resource-constrained embedded devices. It achieves efficient, accurate, and real-time identification and anomaly detection of PLC cabinet equipment status, simplifying equipment management operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122135109A_ABST
    Figure CN122135109A_ABST
Patent Text Reader

Abstract

This invention discloses a visual recognition and anomaly detection method for PLC cabinet equipment status based on an improved YOLOv12n, belonging to the field of computer vision and anomaly detection technology. The invention includes the following steps: S1: Constructing an abnormal status dataset of equipment within the PLC cabinet; S2: Preprocessing the dataset and performing data augmentation using a DCGAN network; S3: Constructing an improved lightweight YOLOv12n equipment anomaly detection model; S4: Using the improved lightweight YOLOv12n model to perform feature extraction, target detection, and status recognition of equipment status within the PLC cabinet; S5: Pushing the anomaly detection results using a mini-program. This invention can improve deployment efficiency on edge computing devices, achieving efficient, accurate, and real-time recognition and anomaly detection of the operating status of PLC cabinet equipment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer vision and anomaly detection technology, specifically to a visual recognition and anomaly detection method for PLC cabinet equipment status based on an improved YOLOv12n. Background Technology

[0002] In the field of industrial automation, PLC cabinets, as core control units, house a large number of electrical devices, and their stable operation directly affects the safety and efficiency of the production line. Therefore, real-time monitoring of the equipment within the PLC cabinet and timely detection of anomalies are crucial for ensuring the reliable operation of industrial systems. Traditional PLC cabinet equipment status monitoring mainly relies on manual inspection, which is inefficient and prone to missed detections and misjudgments. Therefore, employing deep learning-based detection methods for real-time visual recognition and anomaly detection of PLC cabinet equipment status has become an inevitable choice.

[0003] Currently, among deep learning-based detection methods, single-stage object detection algorithms, represented by the YOLO series, have attracted considerable attention due to their high real-time performance. These algorithms can predict both the object's category and location in a single forward pass, exhibiting low inference latency, making them more suitable for the needs of industrial automation. However, while these methods can achieve accurate object detection on object surfaces using advanced deep learning networks, many scenarios in practical industrial applications face resource constraints. Embedded devices and edge computing platforms, due to limited computing power and memory, struggle to run complex, large models. Therefore, how to improve algorithm efficiency and reduce model size while maintaining detection accuracy has become a critical issue that urgently needs to be addressed. Summary of the Invention

[0004] The purpose of this invention is to provide a visual recognition and anomaly detection method for PLC cabinet equipment status based on the improved YOLOv12n, which can improve the deployment efficiency on edge computing devices and achieve efficient, accurate and real-time recognition and anomaly detection of the operating status of PLC cabinet equipment, thereby solving the problems mentioned in the background art.

[0005] To achieve the above objectives, the present invention provides the following technical solution:

[0006] The method for visual recognition and anomaly detection of PLC cabinet equipment status based on the improved YOLOv12n includes the following steps:

[0007] S1: Construct a dataset of abnormal states of equipment inside the PLC cabinet;

[0008] S2: Preprocess the dataset and perform data augmentation using the DCGAN network;

[0009] S3: Construct an improved lightweight YOLOv12n device anomaly detection model;

[0010] S4: Use the improved lightweight YOLOv12n model to perform feature extraction, target detection and status recognition of equipment status in the PLC cabinet;

[0011] S5: Use a mini-program to push anomaly detection results.

[0012] Furthermore, S2 preprocesses the dataset and uses the DCGAN network for data augmentation, namely:

[0013] S201: Construct a DCGAN network, which includes a generator G and a discriminator D;

[0014] S202: The generator G is computed through a series of transposed convolutional layers ConvTranspose2d, batch normalization layers BN, and activation function σ; assuming the generator has a total of L... G If the layer is defined, then the final output data sample G(z) of the generator is:

[0015] (1)

[0016] S203: Discriminator D extracts features through multiple convolutional layers (Conv2d), batch normalization layers (BN), and activation function σ; assuming the discriminator has L... D If the generator is layered, then the final output data sample G(x) is:

[0017] (2)

[0018] In equation (2) above, the output is a scalar value representing the probability that the input data sample is real data, and the value range is between [0,1].

[0019] S204: Train the DCGAN, alternately optimizing the generator and discriminator; the discriminator first processes real data and generated data separately, calculates the loss with the corresponding labels and updates the parameters through backpropagation; the generator generates samples with noise, inputs them into the discriminator and updates the parameters based on its judgment result and the loss with the real labels; training continues until the generator can generate samples that the discriminator cannot distinguish between real and fake;

[0020] S205: Merge the new samples generated by the DCGAN network with the old samples to form an enhanced dataset.

[0021] Furthermore, an improved lightweight YOLOv12n device anomaly detection model is built in S3, namely:

[0022] S301: Improve the original backbone network using the lightweight network model StarNet;

[0023] S302: The original neck network's A2C2f module is changed to C3k2_Star, which combines Star_Block and enhances feature representation through a dual-branch MLP structure.

[0024] S303: The Detect head of the head network is changed to the lightweight Detect_LSCD head, which achieves a lightweight design through shared convolutional layers, while improving the accuracy of bounding box localization by using DFL technology.

[0025] Furthermore, the lightweight network model StarNet uses its smallest variant—StarNet_s050—to analyze its structural design and key mechanisms; its specific network components are as follows:

[0026] S3011: First, extract primary features from the input image:

[0027] (3)

[0028] In equation (3) above, where The output is ;

[0029] S3012: Feature inputs are processed layer by layer through Stage1, Stage2 and Stage3 modules to achieve feature extraction and enhancement, and output multi-level feature representations.

[0030] Furthermore, each Stage contains a Conv convolution and six Star Blocks as described in this paper; the Conv convolution is a downsampling module responsible for reducing spatial resolution and expanding the receptive field; the Star Blocks include a dual-path MLP structure and element-wise multiplication, and their main formulas are as follows:

[0031] (4)

[0032] In equation (4) above, where .

[0033] Furthermore, the C3k2_Star module includes an input convolutional layer, a split function layer, multiple C3k2_Star modules, a second-dimensional stacking layer, and an output convolutional layer; the C3k2_Star module first adopts a 7×7 depthwise separable convolution and a dual-branch MLP structure to allow the model to learn more complex feature interactions and reduce the number of parameters.

[0034] Furthermore, the lightweight detection head Detect_LSCD first processes the output three-layer feature maps P3, P4, and P5 by inputting them into a shared set of convolutional layers and two 3×3 convolutions. Then, it performs scale adaptation and employs Distributed Free Localization (DFL) to improve the localization accuracy of the bounding boxes. DFL converts the distribution predicted by the network into bounding box coordinates.

[0035] (5)

[0036] In equation (5) above, where P reg This is bounding box regression prediction, where 'a' is the anchor coordinate, and DFL(x) is the DFL operation, which converts the reg_max predictions at each location into a single scalar value.

[0037] (6)

[0038] Furthermore, in S4, an improved lightweight YOLOv12n model is used for feature extraction, target detection, and status recognition of equipment within the PLC cabinet, namely:

[0039] The model first extracts features, including geometric features (such as shape, size, and location) and state features (such as indicator light color and switch on / off status). Next, it performs target detection to accurately locate various devices within the PLC cabinet (such as PLC modules, relays, and indicator lights), outputting the bounding box coordinates and category information of each device. Finally, based on the extracted state features, it performs state recognition, determining the operating status of each device through preset state judgment rules (such as red for abnormal and green for normal), distinguishing between normal and abnormal states (such as indicator light malfunction or switch malfunction), and outputting the recognition result including device ID, location information, state category, and confidence level.

[0040] Furthermore, S5 uses a mini-program to push anomaly detection results. Specifically, the data interaction interface between the mini-program and the anomaly detection system uses HTTP / HTTPS protocol to achieve data transmission, ensuring the security and stability of data transmission. After the anomaly detection result is generated, the anomaly detection system encapsulates the anomaly information according to a preset data format, including key information such as the time of anomaly occurrence, PLC cabinet number, equipment name and model, anomaly type (e.g., red indicator light alarm, unexpected switch disconnection), anomaly status description, anomaly area image screenshot, and anomaly confidence level, and sends it to the mini-program backend server through the interface.

[0041] Compared with the prior art, the beneficial effects of the present invention are:

[0042] 1. This invention introduces a lightweight feature extraction network, StarNet, on the basis of the YOLOv12n backbone network, effectively reducing model complexity and improving running efficiency. In the neck structure of the network, the original A2C2f module is replaced with a C3k2_Star module that integrates the Star_Block structure to enhance feature fusion and expression capabilities. In the detection head, the original Detect detection head is replaced with a lightweight Detect_LSCD detection head. This detection head achieves parameter sharing through shared convolutional layers, thereby realizing a lightweight design. Combined with distributed focus learning (DFL) technology, it effectively improves bounding box localization accuracy and overall detection performance.

[0043] 2. The StarNet network proposed in this invention effectively enhances the interactivity of features between channels by introducing an element-wise multiplication mechanism, replacing the complex feature fusion methods in traditional MLP or attention mechanisms, thereby achieving superior expressive power while maintaining efficient model operation. This network is particularly suitable for scenarios with limited computing resources and can be widely applied to tasks such as image recognition, object detection, and feature extraction. It also has good deployment adaptability and scalability in mobile and edge devices.

[0044] 3. This invention proposes a data augmentation method based on deep convolutional generative adversarial networks (DCGAN). By constructing a dedicated dataset containing abnormal states of PLC cabinet equipment and using DCGAN for data augmentation, the scale and sample diversity of the original dataset are effectively expanded, and the generalization ability of the model in complex environments and the accuracy of anomaly detection are significantly improved.

[0045] 4. This invention proposes using a mini-program platform to push equipment anomaly detection results, which has the advantages of being easy to obtain and simple to operate. It does not require the installation of additional complex software, making it convenient for equipment managers to view anomaly information anytime and anywhere. The mini-program system supports functions such as anomaly information push based on user permissions and region, historical anomaly record query, and statistical analysis, meeting the needs of multi-role collaborative management in industrial scenarios and improving anomaly response efficiency and operation and maintenance management level. Attached Figure Description

[0046] Figure 1 This is a flowchart of the method of the present invention;

[0047] Figure 2 Diagram of the existing YOLOv12n network structure;

[0048] Figure 3 This is a diagram of the improved YOLOv12n lightweight network structure of the present invention;

[0049] Figure 4 This is a structural diagram of the Starnet model of the present invention;

[0050] Figure 5 This is a structural diagram of the C3k2_Star module of the present invention;

[0051] Figure 6 This is a structural diagram of the Detect_LSCD module of the present invention;

[0052] Figure 7 This is a graph showing the evaluation metrics of the improved YOLOv12n model of the present invention.

[0053] Figure 8 The diagram shows the detection effect of the improved YOLOv12n of this invention;

[0054] Figure 9 This is a screenshot showing the effect of the mini-program push notification in this invention. Detailed Implementation

[0055] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0056] Please see Figure 1-9 This invention provides a lightweight PLC cabinet equipment status real-time visual recognition and anomaly detection system based on an improved YOLOv12n. It mainly comprises five parts: a data acquisition module, a data augmentation module, a model building and training module, an inference and status recognition module, and a mini-program push module. The specific implementation steps are as follows:

[0057] Step S1: Data Acquisition of Abnormal Status of Equipment Inside PLC Cabinet

[0058] An industrial camera is fixedly installed in a suitable location within the PLC cabinet to ensure that the field of view covers all critical components, including PLC modules, relays, fans, indicator lights, terminal blocks, etc. The captured images include equipment scenes under different operating conditions, and anomalies are marked on a manual annotation platform. The system uses a Basler acA1920-40gc industrial camera with a resolution of 1920×1200, a frame rate of no less than 40 frames per second, a 12mm focal length lens with an f / 1.8 aperture, and a ring LED fill light with a color temperature of 5500 K. It is installed on the top or side wall of the PLC cabinet to ensure that the camera's field of view covers all critical components, including PLC modules, relays, fans, indicator lights, terminal blocks, etc. The control unit consists of a Siemens S7-1500 series PLC and an industrial computer equipped with an Intel i7-9700 processor, 16 GB of memory, and a 512 GB SSD, connected via Ethernet for real-time data transmission. The collected images include the equipment's operation under normal conditions (indicator lights are normal, fans are running normally, terminals are not loose, and the equipment surface is clean) and abnormal conditions (indicator lights are abnormal, fans stop or rotate abnormally, terminals are loose or corroded, dust accumulates on the equipment surface, condensation or rust). At least 300 samples are collected for each type of abnormality, with a total dataset of approximately 15,000 images.

[0059] Step S2: Data Preprocessing and DCGAN-based Data Augmentation

[0060] The acquired images first underwent preprocessing operations such as size normalization, brightness and contrast adjustment, and noise filtering. Then, a data augmentation method based on Deep Convolutional Generative Adversarial Network (DCGAN) was used to expand the sample set. The DCGAN generator consists of four layers of transposed convolutions, batch normalization, and LeakyReLU activation functions, while the discriminator consists of four layers of ordinary convolutions, batch normalization, and LeakyReLU activation functions. The loss function is binary cross-entropy, and the optimizer is Adam (learning rate 0.0002, β1=0.5, β2=0.999). The training epochs are 200, and the input noise dimension is 100. During training, the generator and discriminator parameters are alternately updated until the generated samples are indistinguishable from real samples. Finally, abnormal state images of PLC cabinets with the same resolution as the real images (1920×1200) are generated. The dataset is further augmented using rotation, brightness perturbation, and noise addition, expanding the sample size to 30,000 images.

[0061] Step S3: Improve the lightweight YOLOv12n model construction

[0062] In terms of model building, such as Figure 2 and 3As shown, three optimizations were made to the original YOLOv12n architecture: First, the backbone network was replaced with the lightweight StarNet_s050, which improves feature interaction capabilities and reduces computational complexity through a dual-path MLP structure and element-wise multiplication mechanism; second, a C3k2_Star module was introduced into the neck structure, employing a 7×7 depthwise separable convolution and a dual-branch MLP structure to enhance feature representation capabilities in multi-scale feature fusion; finally, the detection head was replaced with a lightweight Detect_LSCD structure, reducing the number of parameters through convolutional weight sharing and combining distributed free localization (DFL) technology to improve bounding box regression accuracy. During model training, the input size was set to 640×640, the batch size was 32, the initial learning rate was 0.01 with a cosine decay strategy, the optimizer was SGD (momentum 0.937, weight decay 0.0005), the loss function was a combination of CIoU Loss and BCE Loss, and data augmentation methods included Mosaic, MixUp, random cropping, and color perturbation. Figure 7 As shown, after training for 300 epochs, the model size is 8.6 MB, and the inference speed can reach 120 FPS on an NVIDIA RTX 3080 graphics card and about 43 FPS on a Jetson Xavier NX.

[0063] Step S4: Equipment Status Identification and Anomaly Detection

[0064] The improved model extracts features from the input image and outputs device categories, bounding box coordinates, and confidence scores. It then determines the status based on device-specific state features (such as indicator light color and fan motion blur features) combined with a rule base. For example, a red indicator light is identified as an "alarm state," and a stationary fan with an ON command is identified as a "fan malfunction." The output includes: device ID, category, location information, status label, and confidence score.

[0065] Step S5: Mini Program Abnormal Push and Recording

[0066] like Figure 9 As shown, detected anomalies are sent to the mini-program backend via an HTTP / HTTPS interface. The encapsulated information includes the anomaly time, PLC cabinet number, device name, anomaly type, status description, screenshot, and confidence level. The mini-program frontend can implement: real-time pop-up alarms; historical anomaly query and statistical analysis; and tiered push notifications based on user permissions (maintenance personnel, management personnel, etc.).

[0067] like Figure 8As shown, the system ran continuously for 7 days in a PLC cabinet on a production line, detecting approximately 120,000 images. Test results show that the improved model, while maintaining high real-time performance, reduced model size by 38.4%, increased inference speed by 42.1%, improved mAP@0.5 by 3.5%, achieved an anomaly detection accuracy of 97.3%, and had an average alarm delay of less than 1.2 seconds, significantly outperforming the detection performance of the original YOLOv12n model.

[0068] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.

Claims

1. A visual recognition and anomaly detection method for PLC cabinet equipment status based on improved YOLOv12n, characterized in that: Includes the following steps: S1: Construct a dataset of abnormal states of equipment inside the PLC cabinet; S2: Preprocess the dataset and perform data augmentation using the DCGAN network; S3: Construct an improved lightweight YOLOv12n device anomaly detection model; S4: Use the improved lightweight YOLOv12n model to perform feature extraction, target detection and status recognition of equipment status in the PLC cabinet; S5: Use a mini-program to push anomaly detection results.

2. The method for visual recognition and anomaly detection of PLC cabinet equipment status based on improved YOLOv12n as described in claim 1, characterized in that: S2 preprocesses the dataset and uses the DCGAN network for data augmentation, namely: S201: Construct a DCGAN network, which includes a generator G and a discriminator D; S202: The generator G is computed through a series of transposed convolutional layers ConvTranspose2d, batch normalization layers BN, and activation function σ; assuming the generator has a total of L G If the layer is defined, then the final output data sample G(z) of the generator is: (1) S203: Discriminator D extracts features through multiple convolutional layers (Conv2d), batch normalization layers (BN), and activation function σ; Assume the discriminator has L... D If the generator is layered, then the final output data sample G(x) is: (2) In equation (2) above, the output is a scalar value representing the probability that the input data sample is real data, and the value range is between [0,1]. S204: Train the DCGAN, alternately optimizing the generator and discriminator; the discriminator first processes the real data and generated data respectively, calculates the loss with the corresponding labels and updates the parameters through backpropagation; The generator produces samples using noise, which are then input into the discriminator. The discriminator updates its parameters based on the discriminator's judgment and the loss of the true labels. Training continues until the generator can produce samples that the discriminator cannot distinguish between real and fake samples. S205: Merge the new samples generated by the DCGAN network with the old samples to form an enhanced dataset.

3. The method for visual recognition and anomaly detection of PLC cabinet equipment status based on improved YOLOv12n as described in claim 1, characterized in that: An improved lightweight YOLOv12n device anomaly detection model is built in S3, namely: S301: Improve the original backbone network using the lightweight network model StarNet; S302: The original neck network's A2C2f module is changed to C3k2_Star, which combines Star_Block and enhances feature representation through a dual-branch MLP structure. S303: The Detect head of the head network is changed to the lightweight Detect_LSCD head, which achieves a lightweight design through shared convolutional layers, while improving the accuracy of bounding box localization by using DFL technology.

4. The method for visual recognition and anomaly detection of PLC cabinet equipment status based on improved YOLOv12n as described in claim 3, characterized in that: The lightweight network model StarNet uses its smallest variant—StarNet_s050—to analyze its structural design and key mechanisms; its specific network components are as follows: S3011: First, extract primary features from the input image: (3) In equation (3) above, where The output is ; S3012: Feature inputs are processed layer by layer through Stage1, Stage2 and Stage3 modules to achieve feature extraction and enhancement, and output multi-level feature representations.

5. The method for visual recognition and anomaly detection of PLC cabinet equipment status based on improved YOLOv12n as described in claim 4, characterized in that: Each Stage contains a Conv convolution and six Star Blocks as described in this paper. The Conv convolution is a downsampling module responsible for reducing spatial resolution and expanding the receptive field. The Star Blocks include a dual-path MLP structure and element-wise multiplication, and their main formulas are as follows: (4) In equation (4) above, where .

6. The method for visual recognition and anomaly detection of PLC cabinet equipment status based on improved YOLOv12n as described in claim 5, characterized in that: The C3k2_Star module includes an input convolutional layer, a Split function layer, multiple C3k2_Star modules, a second-dimensional stacking layer, and an output convolutional layer; The C3k2_Star module first employs a 7×7 depthwise separable convolution and a dual-branch MLP structure to allow the model to learn more complex feature interactions and reduce the number of parameters.

7. The method for visual recognition and anomaly detection of PLC cabinet equipment status based on improved YOLOv12n as described in claim 6, characterized in that: The lightweight detection head Detect_LSCD first processes the output three-layer feature maps P3, P4, and P5 into a shared set of convolutional layers and two 3×3 convolutions. Then, it performs scale adaptation and employs Distributed Free Localization (DFL) to improve the localization accuracy of the bounding boxes. DFL converts the network's predicted distribution into bounding box coordinates. (5) In equation (5) above, where P reg This is bounding box regression prediction, where 'a' is the anchor coordinate, and DFL(x) is the DFL operation, which converts the reg_max predictions at each location into a single scalar value. (6) 。 8. The method for visual recognition and anomaly detection of PLC cabinet equipment status based on improved YOLOv12n as described in claim 1, characterized in that: S4 uses an improved lightweight YOLOv12n model for feature extraction, target detection, and status recognition of equipment status within the PLC cabinet, namely: The model first extracts features, including the geometric and state features of the equipment. Then, it performs target detection to accurately locate various devices within the PLC cabinet and outputs the bounding box coordinates and category information of the devices. Finally, it performs state recognition based on the extracted state features, determines the operating state of each device through preset state judgment rules, distinguishes between normal and abnormal states, and outputs the recognition results including device ID, location information, state category, and confidence level.

9. The method for visual recognition and anomaly detection of PLC cabinet equipment status based on improved YOLOv12n as described in claim 1, characterized in that: S5 uses a mini-program to push anomaly detection results. Specifically, the data interaction interface between the mini-program and the anomaly detection system uses HTTP / HTTPS protocol to achieve data transmission, ensuring the security and stability of data transmission. After the anomaly detection result is generated, the anomaly detection system encapsulates the anomaly information according to a preset data format, including key information such as the anomaly occurrence time, PLC cabinet number, equipment name and model, anomaly type, anomaly status description, anomaly area image screenshot, and anomaly confidence level, and sends it to the mini-program's backend server through the interface.