If Generative AI has excited you all, you will be pleased to know that GANs play an essential role in Generative AI. Love those funny deepfake videos? GANs have probably been used to generate those convincing fake videos, a.k .a. deepfakes. The range of applications is wide, from deepfakes to generating 3D images from 2D images. The key capability that we need to keep in mind is that Generative Adversarial Networks help accurately estimate and create information from an incomplete source. And this is huge! One of the applications is in the area of automated defect detection in manufacturing. In this article, we will first overview how GANs work and then understand how they are effective in solutions like automated, vision-based quality inspection in manufacturing.
Understanding GANs
GANs are deep neural network architectures made up of two networks. Through multiple cycles, both networks train each other while simultaneously trying to outwit each other. A typical GAN architecture consists of a generator network and a discriminator network.
Generator network
In very simple terms, a generator network leverages existing data to generate new data. As highlighted in the beginning of the article, an example is using existing images to create new images. The primary goal of the generator is to generate data (like images, video, audio, text etc.) from a randomly generated vector of numbers. The important thing to note when developing a generator network is that you need to specify the goal. This goal could be image generation, text generation, audio generation, video generation etc.
Discriminator network
Again, in simple terms, the discriminator network works to differentiate between the actual data and the data generated by the generator. The discriminator classifies the incoming data into predefined categories. Generally, binary classification is performed in GANs.
Together, they learn and create. As shown in Figure 1, the generator network generates a potential solution, like an image of a specific landscape. The discriminator network then leverages actual images of that landscape to evaluate or validate the “correctness” of the generated image.
Figure 1 : General overview of GAN

Source: Developers.Google.Com
The difference, known as error, is leveraged via a feedback loop to learn and improve the ability to generate more realistic images. The word “adversarial” comes from the fact that there are two networks, a generator and a discriminator, competing against each other as adversaries. The result is that the overall solution gets incrementally better. This architecture of GANs makes them a good choice of algorithms for vision-based quality inspection solutions.
GANs for anomaly (defect) detection
For defect detection, the high-level approach compares the actual with an “ideal.” If we are looking for defects on a surface, we approximate a picture of the surface with a picture of an ideal surface, free from defects and imperfections. Figure 2, from the research paper, Unsupervised fabric defect detection based on a deep convolutional generative adversarial network, illustrates an example of an architecture that can be leveraged in a manufacturing process for defect detection for quality purposes.
Figure 2: GANs for defect detection in manufacturing

Source: https://journals.sagepub.com/doi/abs/10.1177/0040517519862880?journalCode=trjc
During training, the model is first trained on defect-free images, as shown on the left-hand side of the image. The solution’s generator learns to reconstruct the images with minimal error. The discriminator helps detect pictures that do not align with the “learning” of ideal images.

