## 2 Materials and Methods
### Proposed NIA  
The proposed NIA uses Azure Custom Vision. This service has been trained to identify whether an object is a defect-free cast labeled as \"ok\" or a non-conform object labeled as \"nok\". This training involves using a 4440 dataset of images containing both categories. The defect detection model was trained using a separate dataset, which included images of cast parts captured from multiple angles under controlled conditions. The training images were downloaded from the dataset available in [64]. This dataset was chosen due to its comprehensive coverage of various perspectives. This way, the model generalizes the detection defect characteristics in real-world scenarios. Each image is annotated to indicate whether the cast is in good condition or has defects. During the training phase, the model learns to recognize various features and characteristics of both categories. This includes analyzing the cast's shape, texture, and surface details. Once trained, Azure Custom Vision analyzes unseen images of casts and outputs a probability score for each label. The NIA is illustrated in Figure 5, and it uses the following pseudocode:  
* Send a set of five frames for the same cast;
* Each image is analyzed by the Azure Custom Vision service, which returns the probabilities for each label;
* For each image, NIA keeps only the highest probability associated with each label (\"ok\" or \"nok\");
* Use the proposed mathematical formula (Equation (1)) to combine the probabilities from the five images and determine the likelihood that the cast is conformed or nonconforming with the technical requirements. Azure IoT Hub enables multiple devices to be integrated and managed under one framework. Employing Equation (1) to analyze numerous images (rather than relying on just a single image and its label from Azure Custom Vision) serves several purposes:  
* Changes in lighting, angles, or minor obstructions diminish the model's accuracy. This potentially causes misclassification. By examining several images of the same part, the NIA accounts for these factors, building a more complete overview of the cast's features;
* Evaluating multiple instances increases confidence in the conclusion by drawing on a broader set of assessments rather than being depending on a single piece of data;
* In a manufacturing or quality control context, the stakes are high when determining whether or not a part is defect-free--implementing Equation (1), which synthesizes information from multiple images, safeguards against potential errors, ensuring that only those casts that meet the highest quality standards are labeled \"ok\". Equation (1) uses a standard method for combining the cast (OK) and defect (NOK) probabilities. Equation (1) employs a weighted average approach with an adjustment factor setup up to 2 as the first adjusting parameter. Multiple tests are provided in the Results Section. \[ \begin{array}{c}P_{OK\_Total}=\frac{\sum_{j=1}^{5}P_{OK_{j}}^{w}}{\sum_{i=1}^{5} \left(P_{OK_{i}}^{w}+P_{NOK_{j}}^{w}\right)}\\ P_{NOK\_Total}=\frac{\sum_{i=1}^{5}P_{NOK_{i}}^{w}}{\sum_{i=1}^{5}\left(P_{OK_{i} }^{w}+P_{NOK_{j}}^{w}\right)}\end{array}  \tag{1}\]  
where:  
\(P_{OKi}\) is the probability that image \(i\) is labeled as \"ok\";  
\(P_{NOK}\)--the likelihood that image \(i\) is labeled \"nok\";  
\(w\)--an exponent that can adjust the influence of each probability (for example, \(w=2\), to penalize lower probabilities more heavily). Equation (1) combines information from multiple images to obtain high accuracy and ensure quality control. In the context of evaluating the NIA for cast quality assessment, the terms True Positive (TP), True Negative (TN), False Positive (FP), and False Negative (FN) are defined as follows:  
1. TP refers to the number of correctly identified casts as \"ok\". In other words, these are the casts that are actually in good condition and are accurately classified as such by the NIA;
2. TN represents the instances where the model correctly identifies a cast as \"nok\".