**1. Introduction**

The Fourth Industrial Revolution, or Industry 4.0, aims at automating traditional manufacturing and industrial practices exploiting the most recent technologies depicted in **Figure 1**. Integrating artificial intelligence (AI) and robotics with traditional practices, the world of manufacturing processes is undergoing a transformation from activities that rely on human experience and skills into flexible environments, including objective decisional systems fully integrated within the industrial process. Advanced robotics is meant to develop autonomous and intelligent systems that could reduce the intervention of human workers [1] in many of the crucial and repetitive tasks that represent the core business of companies. Augmented and virtual reality can give operators more information about their tasks [2] and help them to alleviate mental stress during some jobs. Additive manufacturing [3] can speed up the production process. Internet of things (IoT) [4] allows new forms of communication between machines, giving rise to smart devices that can help humans achieve their objectives. Radiofrequency identification (RFID) technologies are used for efficient logistics and inventory warehouse management [5] reducing costs while increasing quality and competitiveness.

**Figure 1.** *Industry 4.0 pillar technologies.*

Among all the aforementioned technologies, AI is perhaps the one that received more interest during the years. Indeed, nowadays, the industrial interest in AI applications in various sectors is undeniable. However, for industries, artificial intelligence is both a source of enthusiasm and skepticism. One reason is that deep learning (DL) is a technology based on data, and problems solved using AI are as good or as bad as the data they are trained on. In addition, companies perceive AI as a black box and would prefer understandable and explainable processes [6]. Both these aspects should be taken into consideration when developing industrial AI solutions.

Current automation-assisted production is mostly open-loop and relies on specific checkpoints to perform product quality analysis. Early systems based on vision date back to the nineties. Such an approach suits best when critical issues can be formally expressed by taking advantage of geometrical measurements or well-known features on the inspected objects. Unfortunately, these techniques cannot perform many quality-control activities because they need a predefined sequence of actions where quality checks should be designed carefully to meet the precise production requirements. Moreover, human nature shows formidable efficiency in learning simple checks even if it would be difficult to formalize such operations with a sequence of rules. Indeed, experience plays a relevant role in human evaluation for products quality assessment. Similarly, vision inspection processes performed by automated machines will require the development of novel algorithms that should be trained and improved with time and experience.

The introduction of automation systems in the production lines that exploit AI techniques has reduced the need for human intervention in the manufacturing process of many products. This innovation had a major impact on many industrial applications, and visual inspection is by far the activity that has profited most. Thanks to deep neural networks (DNNs), difficult computer vision tasks, such as object classification or detection and image segmentation, have been addressed recently using an adequate number of training data. DNNs are scalable, experience-based, and have similar performance to human workers. Since the development of AlexNet [7],

solutions based on deep learning have been encouraged, and convolutional neural networks (CNN) also have been extensively utilized for automating optical quality inspections. However, since such networks need a huge amount of labeled data for training their parameters, it is difficult to have an adequately large set of faulty samples with well-optimized industrial processes for creating a *balanced dataset* for efficiently training the network to defect classification. Therefore, in most cases, the objective of the training moves from defect classification to anomaly detection.

Welding is a fundamental activity in many industrial manufacturing processes, such as automotive, shipbuilding, aerospace, and electronics. It is a crucial operation for the overall quality of the production line because a defect not detected in the early stages can determine the rejection of the entire product. This chapter introduces deep neural networks in the context of welding defect detection, starting by analyzing common problems in the industrial applications of such technologies and presenting in detail a solution for quality checks in fuel injectors welding during the production stage.
