<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: umapyoi</title>
    <description>The latest articles on Forem by umapyoi (@umapyoi).</description>
    <link>https://forem.com/umapyoi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F829572%2F837f3ec9-fa8b-49ac-9d21-c155158be6b8.png</url>
      <title>Forem: umapyoi</title>
      <link>https://forem.com/umapyoi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/umapyoi"/>
    <language>en</language>
    <item>
      <title>Performance of anomaly detection cloud platform with MVTec dataset</title>
      <dc:creator>umapyoi</dc:creator>
      <pubDate>Sat, 12 Mar 2022 11:10:34 +0000</pubDate>
      <link>https://forem.com/umapyoi/performance-of-anomaly-detection-cloud-platform-with-mvtec-dataset-4h0n</link>
      <guid>https://forem.com/umapyoi/performance-of-anomaly-detection-cloud-platform-with-mvtec-dataset-4h0n</guid>
      <description>&lt;p&gt;I verified the performance of the anomaly detection model automatic creation platform “ADFI” written in the previous article!&lt;/p&gt;

&lt;p&gt;See &lt;a href="https://dev.to/umapyoi/image-anomaly-detection-how-to-create-models-quickly-and-easily-i9l"&gt;the previous article for ADFI&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Screen of ADFI:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rjPkc0qS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/apymo4kvxywjjimy8xbz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rjPkc0qS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/apymo4kvxywjjimy8xbz.png" alt="Image description" width="880" height="552"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;h1&gt;
  
  
  Experimental settings
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Dataset
&lt;/h2&gt;

&lt;p&gt;For the verification experiment, I used the MVTec dataset, which is a very famous image dataset for anomaly detection.&lt;/p&gt;

&lt;p&gt;It contains datasets of 15 categories that are frequently used in verification experiments of anomaly detection related papers.&lt;/p&gt;

&lt;p&gt;Dataset image example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Fz_hgxfV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mh3v82bb4yf8gbg1azrf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Fz_hgxfV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mh3v82bb4yf8gbg1azrf.png" alt="Image description" width="880" height="597"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;h2&gt;
  
  
  The number of data
&lt;/h2&gt;

&lt;p&gt;Since the number of normal images and abnormal images differs depending on the data set, the below is used for each data set.&lt;/p&gt;

&lt;p&gt;Training images were randomly extracted from the dataset. Test images are randomly extracted from images not used in Training images.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Normal training data: 50&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Anomaly training data: 10&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Normal test data: 20&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Anomaly test data: 20&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Verification items&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Learning time&lt;br&gt;
Time taken to train the model&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Test time&lt;br&gt;
Time from running the test to getting the results of all test data (40 images)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;AUC (Area Under the Curve)&lt;br&gt;
An evaluation index often used for anomaly detection.&lt;br&gt;
ROC (Receiver Operating Characteristic) The area corresponding to the lower part of the curve.&lt;br&gt;
The closer the AUC is to 1, the higher the performance of the model. (If predicted completely randomly, the AUC will be 0.5.)&lt;br&gt;
I downloaded the score result CSV and calculated the AUC.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;



&lt;h1&gt;
  
  
  Experimental results
&lt;/h1&gt;

&lt;p&gt;The table below shows the results of creating a deep distance learning (DML) model with ADFI for all datasets.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1zVR1nCG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/06df4oo9sg6qlje654ce.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1zVR1nCG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/06df4oo9sg6qlje654ce.png" alt="Image description" width="695" height="714"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The average learning time is about 11 minutes.&lt;/p&gt;

&lt;p&gt;The average test time is about 4 seconds.&lt;/p&gt;

&lt;p&gt;The average AUC is 0.947.&lt;br&gt;
Very good results with AUC above 0.9 for datasets other than Cable and Screw.&lt;/p&gt;



&lt;h2&gt;
  
  
  Performance comparison with methods of deep metric learning
&lt;/h2&gt;

&lt;p&gt;I compared the AUC of the model of ADFI and the AUC of the model created by each method of deep metric learning without using ADFI.&lt;/p&gt;

&lt;p&gt;AUCs of each method in the MVTec dataset:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--S9aPvhnw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ztjjjpugc0fa4tioks4z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--S9aPvhnw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ztjjjpugc0fa4tioks4z.png" alt="Image description" width="880" height="424"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is not possible to simply give a superiority or inferiority because the experimental settings are different.&lt;/p&gt;

&lt;p&gt;But the AUC values of ADFI are the highest in many datasets.&lt;/p&gt;

&lt;p&gt;See also &lt;a href="https://dev.to/umapyoi/image-anomaly-detection-how-to-create-models-quickly-and-easily-i9l"&gt;the previous article for ADFI&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/umapyoi/image-anomaly-detection-how-to-create-models-quickly-and-easily-i9l"&gt;https://dev.to/umapyoi/image-anomaly-detection-how-to-create-models-quickly-and-easily-i9l&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>machinelearning</category>
      <category>deeplearning</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Image Anomaly Detection: How to create models quickly and easily</title>
      <dc:creator>umapyoi</dc:creator>
      <pubDate>Sat, 12 Mar 2022 10:52:27 +0000</pubDate>
      <link>https://forem.com/umapyoi/image-anomaly-detection-how-to-create-models-quickly-and-easily-i9l</link>
      <guid>https://forem.com/umapyoi/image-anomaly-detection-how-to-create-models-quickly-and-easily-i9l</guid>
      <description>&lt;p&gt;I was able to create and evaluate an anomaly detection model in 30 minutes using ADFI( &lt;a href="https://adfi.jp"&gt;https://adfi.jp&lt;/a&gt; ), a cloud platform for image anomaly detection.&lt;/p&gt;

&lt;p&gt;It was very useful, so I would like to introduce you how to use it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dfbvtDfL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jqdk95ug72xom4pj4jy3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dfbvtDfL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jqdk95ug72xom4pj4jy3.png" alt="Image description" width="880" height="552"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  What’s ADFI?
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;ADFI( &lt;a href="https://adfi.jp"&gt;https://adfi.jp&lt;/a&gt; ) is a cloud platform that automatically creates anomaly detection models for images&lt;/strong&gt; and evaluates their performance.&lt;/p&gt;

&lt;p&gt;The AI model we created can be used at any time via the API.&lt;br&gt;
Anyone can try model creation and performance evaluation for free. &lt;br&gt;
There is a charge when using the API.&lt;/p&gt;

&lt;p&gt;There are only two things we do with ADFI: “upload training and test images” and “set thresholds”!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Without coding, we can create an image anomaly detection model and perform performance evaluation automatically.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Of course, there is no need to set or tune hyperparameters. Even non-experts can create anomaly detection models.&lt;/p&gt;



&lt;h2&gt;
  
  
  Anomaly detection methods available in ADFI
&lt;/h2&gt;

&lt;p&gt;The following two methods can be used.&lt;br&gt;
It’s nice to be able to create a deep metric learning model on the cloud even if you don’t have a GPU machine!&lt;/p&gt;



&lt;h3&gt;
  
  
  MSPC (Multivariate Statistical Process Control)
&lt;/h3&gt;

&lt;p&gt;Only available in cases where the position of the inspection target in the image is fixed.&lt;br&gt;
No anomalous data is required for training.&lt;br&gt;
It is written as “PCA-MSPC” on the ADFI.&lt;/p&gt;



&lt;h3&gt;
  
  
  Deep Metric Learning
&lt;/h3&gt;

&lt;p&gt;DML is used in cases where MSPC is not available.&lt;br&gt;
Requires 5 or more anomalous data for training.&lt;br&gt;
It is written as “DML” on the ADFI.&lt;/p&gt;



&lt;h2&gt;
  
  
  The result of creating models on ADFI
&lt;/h2&gt;

&lt;p&gt;I tried several public datasets (MVTec) to measure training time and performance.&lt;/p&gt;

&lt;p&gt;There is a limit to the number of images that can be uploaded with the ADFI free plan.&lt;br&gt;
Since it is limited to 100 images per dataset, I uploaded 100 images for training and test.&lt;br&gt;
If paid plan, you can upload up to 2000 images per dataset.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dataset image examples:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DBF2Wgzj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qzl8sloggmsg6q6prmfw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DBF2Wgzj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qzl8sloggmsg6q6prmfw.png" alt="Image description" width="880" height="597"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Results of creating anomaly detection model for each dataset with ADFI:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DLWPBmDd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yyjhq7omnx4g57yv0ts0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DLWPBmDd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yyjhq7omnx4g57yv0ts0.png" alt="Image description" width="695" height="714"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It was amazing results!&lt;br&gt;
What’s more, the training time is so short (about 20 seconds to 10 minutes).&lt;/p&gt;



&lt;h1&gt;
  
  
  Try using ADFI (Procedure explanation)
&lt;/h1&gt;

&lt;h2&gt;
  
  
  1. Create an account and sign in
&lt;/h2&gt;

&lt;p&gt;(1) Press “Sign In / Sign Up” on the upper right of the ADFI website( &lt;a href="https://adfi.jp"&gt;https://adfi.jp&lt;/a&gt; ).&lt;/p&gt;

&lt;p&gt;(2) Press “Create a new account”.&lt;/p&gt;

&lt;p&gt;(3) Enter the required information such as your email address in the account registration form, check the check box, and press “REGISTRATION”.&lt;/p&gt;

&lt;p&gt;(4) A confirmation email will be sent to the registered email address. Click the link in the email to complete the account registration.&lt;/p&gt;

&lt;p&gt;(5) Sign in with the registered account.&lt;/p&gt;



&lt;h2&gt;
  
  
  2. Project creation and dataset creation
&lt;/h2&gt;

&lt;p&gt;(1) On the screen immediately after sign in, click the “NEW PROJECT” button on the upper right to create a new project.&lt;/p&gt;

&lt;p&gt;(2) Click the link of the created project name.&lt;/p&gt;

&lt;p&gt;(3) There are lists of “Dataset for PCA-MSPC” and “Dataset for DML” at the bottom of the screen where “Project Detail” is displayed, so click the “NEW DATASET” button on the right side of the dataset.&lt;/p&gt;

&lt;p&gt;(4) Click the link of the created dataset name.&lt;/p&gt;



&lt;h2&gt;
  
  
  3. Image upload
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pFCRHVNC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4wdnju6a9la7xu0r2lz2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pFCRHVNC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4wdnju6a9la7xu0r2lz2.png" alt="Image description" width="880" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(1) Click the “Normal Train image” button to upload normal data for training.&lt;/p&gt;

&lt;p&gt;(2) (For DML only) Click the “Abnormal Train image” button to upload anomaly data for training. Press the “Select” button on the right side of the anomaly data to select the area containing anomalies.&lt;/p&gt;

&lt;p&gt;(3) Click the “Normal Test image” button to upload normal test data.&lt;/p&gt;

&lt;p&gt;(4) Click the “Abnormal Test image” button to upload the anomaly data for testing.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you select multiple image files to upload, you can upload multiple images at once.&lt;/li&gt;
&lt;/ul&gt;



&lt;h2&gt;
  
  
  4. Set the inspection range
&lt;/h2&gt;

&lt;p&gt;The range of the inspection in the image can be optionally set.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iu6DAm1v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ux9vzuv0k25wlbxpddh8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iu6DAm1v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ux9vzuv0k25wlbxpddh8.png" alt="Image description" width="880" height="694"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(1) Click the “INSPECTION RANGE SETTING” tab.&lt;/p&gt;

&lt;p&gt;(2) Drag in the image to set the range to be inspected.&lt;/p&gt;

&lt;p&gt;(3) Click the “Save Inspection Range” button.&lt;/p&gt;



&lt;h2&gt;
  
  
  5. Anomaly detection model creation
&lt;/h2&gt;

&lt;p&gt;Click the “Create AI Model” button to start learning. Wait for a while.&lt;/p&gt;



&lt;h2&gt;
  
  
  6. Setting the threshold
&lt;/h2&gt;

&lt;p&gt;After learning is complete, you can set thresholds on the “AI MODEL SETTING” tab.&lt;br&gt;
Two threshold values, “Main” and “Sub”, can be set at the same time.&lt;/p&gt;

&lt;p&gt;By setting a strict threshold and a loose threshold at the same time when introducing ADFI to a visual inspection system, it is possible to operate such as “if the score of an object is between the two thresholds, it will be checked by human”.&lt;/p&gt;

&lt;p&gt;(1) Press the “AI MODEL SETTING” tab.&lt;/p&gt;

&lt;p&gt;(2) Click the “Set Auto Threshold” button. The threshold is automatically set.&lt;/p&gt;

&lt;p&gt;(3) (If you want to adjust the threshold by yourself) While checking the histogram of the score distribution of the test data, enter an arbitrary value for the threshold and then press the “Save Threshold” button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Og-hs4va--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gn47cfvnvo9affer3hwm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Og-hs4va--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gn47cfvnvo9affer3hwm.png" alt="Image description" width="880" height="689"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;h2&gt;
  
  
  7. Test and confirmation of evaluation results
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bmZjjlvn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6w2gq3a0xakds1tz5tuq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bmZjjlvn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6w2gq3a0xakds1tz5tuq.png" alt="Image description" width="880" height="674"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(1) Press the “TEST” tab.&lt;/p&gt;

&lt;p&gt;(2) Click the “TEST” button to display the test results.&lt;/p&gt;

&lt;p&gt;(3) Click the “Download” button to download detailed test results for each data in CSV format.&lt;/p&gt;

&lt;p&gt;(4) Repeat “6. Setting the threshold” and “7. Test and confirmation of evaluation results” until the result is satisfactory.&lt;/p&gt;



&lt;h2&gt;
  
  
  Supplement
&lt;/h2&gt;

&lt;p&gt;I found the official operation manual.&lt;/p&gt;

&lt;p&gt;If you want to know more, please see &lt;a href="https://adfi.jp/manual/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://adfi.jp/manual/"&gt;https://adfi.jp/manual/&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Next article
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://dev.to/umapyoi/performance-of-anomaly-detection-cloud-platform-with-mvtec-dataset-4h0n"&gt;https://dev.to/umapyoi/performance-of-anomaly-detection-cloud-platform-with-mvtec-dataset-4h0n&lt;/a&gt;&lt;/p&gt;

</description>
      <category>deeplearning</category>
      <category>python</category>
      <category>cloud</category>
      <category>machinelearning</category>
    </item>
  </channel>
</rss>
