<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Junho on Medium]]></title>
        <description><![CDATA[Stories by Junho on Medium]]></description>
        <link>https://medium.com/@yjh960314?source=rss-52476dc5bb48------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Junho on Medium</title>
            <link>https://medium.com/@yjh960314?source=rss-52476dc5bb48------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 10:13:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yjh960314/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Anomaly Detection for Visual Inspection in Machine Vision]]></title>
            <link>https://blog.snuailab.ai/anomaly-detection-for-visual-inspection-in-machine-vision-58d2e820aab4?source=rss-52476dc5bb48------2</link>
            <guid isPermaLink="false">https://medium.com/p/58d2e820aab4</guid>
            <category><![CDATA[autoencoder]]></category>
            <category><![CDATA[machine-vision]]></category>
            <category><![CDATA[anomaly-detection]]></category>
            <category><![CDATA[visual-inspection]]></category>
            <category><![CDATA[restoration]]></category>
            <dc:creator><![CDATA[Junho]]></dc:creator>
            <pubDate>Tue, 16 Jan 2024 04:48:46 GMT</pubDate>
            <atom:updated>2024-03-15T02:17:27.254Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>This article explores machine vision solutions designed to accommodate the characteristics of datasets acquired in industrial manufacturing processes. In the realm of manufacturing, visual inspection serves the primary purpose of detecting abnormal products. The datasets obtained in this context exhibit the following key characteristics:</p><ul><li>The acquired data is predominantly composed of normal products, with only a small portion dedicated to representing abnormal products.</li><li>In contrast, abnormal data manifests in various types, showcasing a diverse range of deviations.</li></ul><p>The difficulty of collecting anomalous data makes supervised learning hard. However, the uniformity of normal data makes it easier for deep learning models to learn features on normal data. Therefore, we discuss how to detect anomalies based on differences in restoration performance using an autoencoder trained only on normal data as unsupervised learning.</p><h3>Dataset</h3><p>Considering the characteristics of data in manufacturing process, categories of transistor, bottle, and metal nut in the MVTecAD[1] dataset were selected for the experiment. Statistics for split and abnormal types of data are shown below. Statistics for split and the number of normal and abnormal images are shown in Table 1, and details of abnormal types are shown in Table 2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LvjgOEIVJ5anPmCvWCuCug.png" /><figcaption>&lt;Table 1. Statistics of normal &amp; abnormal in the selected dataset&gt;</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u-04TMsbdJCf_dVUwtqsnQ.png" /><figcaption>&lt;Table 2. Details of abnormal types&gt;</figcaption></figure><h3><strong>Method</strong></h3><p>For anomaly detection, we employ an autoencoder, illustrated in Figure 1. During the training phase, the autoencoder trains only on reconstruct normal data, making it less effective to detect abnormal data in the inference phase. To quantify reconstruction performance, we measure the MSE(Mean Squared Error) between the original and the output, yielding the abnormal score. A higher score indicates lower restoration performance, implying a higher likelihood of the data being anomalous. The classification of normal and abnormal data involves dividing them into two spaces based on a specific threshold, determined by the score distribution of abnormal scores. A ViT(vision transformers)[2] is employed as a backbone, and the final encoder-decoder structure is derived from the model architecture of a MAE(Masked Autoencoder)[3]. All images were processed in grayscale.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pqeDpVkWeUghaD2gC-uLXQ.png" /><figcaption>&lt;Figure 1. Schematic diagram of the autoencoder structure&gt;</figcaption></figure><h3><strong>Result</strong></h3><p>Firstly, for the metal nut category, the anomaly score statistics are presented in Table 3. Most types exhibited similar score distributions, except for the ‘flip’ type, which displayed a distinct distribution. Consequently, we established a score threshold of 9.7, enabling the detection of approximately 95% of flipped metal nuts as abnormal. The classification results are summarized in Table 4, depicting the confusion matrix.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CXdb_OgV3a-SfD69EvvLYw.png" /><figcaption>&lt;Table 3. Abnormal score statistics for metal nut test data&gt;</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rz-x6AXtDwHRk8GWVRb4Dg.png" /><figcaption>&lt;Table 4. Confusion matrix for metal nut test data&gt;</figcaption></figure><p>Secondly, our experiments on bottles yielded anomaly score statistics, as outlined in Table 5. Notably, scores for normal data tended to be distributed in a lower interval compared to abnormal data. Setting the score threshold to 7.4 resulted in the accurate prediction of all normal data as normal, and approximately 55% of abnormal data could be detected, regardless of the specific abnormal type. Further details are provided in the confusion matrix found in Table 6.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V7aRum7KfkrJI7VsoQboig.png" /><figcaption>&lt;Table 5. Abnormal score statistics for bottle test data&gt;</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XrDQW4XQmF1haYSdn1NuFA.png" /><figcaption>&lt;Table 6. Confusion matrix for bottle test data&gt;</figcaption></figure><p>Finally, the statistics of the anomaly scores for transistor were shown in Table 7. The score distribution of misplaced abnormals was relatively high. Setting the score threshold to 9.4 allowed the detection of all misplaced types as abnormal data, while accurately predicting all normal data as normal. Detailed results can be found in the confusion matrix provided in Table 8.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZjmB57SOtuP-NHbTBAif0g.png" /><figcaption>&lt;Table 7. Abnormal score statistics for transistor test data&gt;</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8WGPk8CDwcEbe-qQojUM4w.png" /><figcaption>&lt;Table 8. Confusion matrix for transistor test data&gt;</figcaption></figure><h3><strong>Discussion</strong></h3><p>In this experiment, we assessed the feasibility of anomaly detection through unsupervised learning using an autoencoder. However, this method exhibits high detection performance for images with global abnormal features while showing limitations in detecting images with localized abnormal features.</p><p>Across all categories, images with global abnormal features consistently demonstrated better detection compared to those with localized abnormal features. The abnormal types, such as bent, color, and scratch, within the metal nut category, possess local abnormal features and display a score distribution similar to that of normal images. This is in contrast to ‘flip,’ which has global abnormal features and a distinct score distribution. In the bottle category, larger breaks tend to have higher anomaly scores than smaller breaks because they have more global abnormal features. Similarly, in transistors, the misplaced type with global abnormal features tended to have a higher anomaly score, while the remaining images with local abnormal features such as bent lead, cut lead, and damaged case had relatively low anomaly scores. Figure 2 shows an Autoencoder trained only on normal data restoring abnormal data to resemble normal data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*yAQlxx3_QKyfEsbv8Xok6w.png" /><figcaption>Figure 2. Visualization of Input/Output for transistor test data. (a) and (b) are original and reconstructed image of abnormals in bent lead, and (c) and (d) are original and reconstructed image of abnormals in misplaced</figcaption></figure><p>To achieve high detection power for images with localized abnormal features, the following trials may be interesting.</p><ul><li>Measuring abnormal score for ROI(region of interest) by abnormal type</li><li>Replace the ViT backbone, which specializes in global features, with a model that specializes in local features</li></ul><p>This visual inspection method will help to reduce the labor cost of human inspectors in manufacturing processes by detecting some types of abnormal data.</p><h3><strong>Reference</strong></h3><p>[1] Bergmann, Paul, et al. “MVTec AD — A comprehensive real-world dataset for unsupervised anomaly detection.” <em>Proceedings of the IEEE/CVF conference on computer vision and pattern recognition</em>. 2019.</p><p>[2] Dosovitskiy, Alexey, et al. “An image is worth 16x16 words: Transformers for image recognition at scale.” <em>arXiv preprint arXiv:2010.11929</em> (2020).</p><p>[3] He, Kaiming, et al. “Masked autoencoders are scalable vision learners.” <em>Proceedings of the IEEE/CVF conference on computer vision and pattern recognition</em>. 2022.</p><p>[4] Chalapathy, Raghavendra, and Sanjay Chawla. “Deep learning for anomaly detection: A survey.” <em>arXiv preprint arXiv:1901.03407</em> (2019).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58d2e820aab4" width="1" height="1" alt=""><hr><p><a href="https://blog.snuailab.ai/anomaly-detection-for-visual-inspection-in-machine-vision-58d2e820aab4">Anomaly Detection for Visual Inspection in Machine Vision</a> was originally published in <a href="https://blog.snuailab.ai/">SNUAILAB</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>