## 3 Defect-Adapted Hierarchical Deep Learning Model  
### Hierarchical Design Based on Characteristics of Anomaly Types  
The no_lens type refers to a situation in which the lens is not captured by the camera. The **etc_abnormal** type is defined as a category encompassing abnormal conditions caused by various factors, primarily external influences such as camera capture failures or lens positioning errors. As shown in Figure 6, for both abnormal types, the feature size can occupy the entire image. In particular, for **no_lens**, the entire image may be considered defective when the lens is missing or not properly captured. This highlights the necessity for defect detection models to accurately identify and classify large features. Figure 7 shows the **broken** and **b_edge** defects. The **broken** defects signify severe damage to the edge of the lens, which is prominently visible in a linear form. Such damage critically affects the structural integrity of the lens and can cause significant problems during use. The **b_edge** defect represents linear damage along the edge of the lens. These defects vary in size and shape, indicating different levels of severity. If **b_edge** defects progress, they may develop into a **broken** state, suggesting that these defects should be considered part of a continuous spectrum. Figure 5: An overview of Vision Transformer (on the left) and the details of Transformer encoder (on the right) [33]. Figure 8 illustrates the **burr** and **b_bubble** defect types that arise from inherent flaws during the manufacturing process. Burr defects occur when improper cutting results in curved features on the surface or edge of the lens. The **b_bubble** defect appears when insufficient material is introduced during the molding process, leading to curved bubbles or irregular patterns within or on the surface of the lens. Both defect types share a common characteristic of curved forms. Additionally, as observed in Figure 7b,c and Figure 8b,c, the defect sizes for **b_edge** and **b_bubble** types vary significantly. The **b_edge** defects range from minor damage to large cracks along the lens edge. Similarly, the **b_bubble** defects range from small to large bubbles, which can affect the lens's optical properties. In this study, as shown in Figure 9, we observed cases in which multiple defect types appeared simultaneously within a single lens. This phenomenon reflects the complexity of the manufacturing process and the concurrent occurrence of various defects. To effectively handle these overlapping defect types, adopting a multi-output structure is essential. A multi-output structure should be designed to simultaneously identify and classify multiple defect types for a single lens. By providing separate prediction results for each defect type, this structure enables accurate identification of multiple defects within a single lens. It also allows more precise analysis of each defect and plays a critical role in environments where various defect types may occur simultaneously during manufacturing. Figure 6: Characteristics of abnormal type—(**a**) no_lens, (**b**) etc_abnormal. Figure 7: Characteristics of abnormal type—(**a**) broken, (**b**) b_edge with small size, (**c**) b_edge with large size. In the multi-output structure, if a lens does not correspond to any of the six defect types (**no_lens**, **etc_abnormal**, **burr**, **broken**, **b_edge**, **b_bubble**)--meaning all defect classifications are determined to be \"False\"--the lens is classified as \"Good\", indicating the absence of defects. This approach enables the model to identify both defect types and defect-free conditions. In this study, the abnormality size was used as a critical criterion during the initial classification stages of the model. Specifically, a strategy was adopted to prioritize the classification of larger abnormal values in the early stages of the model because larger abnormalities are more likely to significantly impact product quality.