Create an anomaly model

Prev Next

This article describes the process for detecting anomalies using good image samples and, optionally, defect image samples. The output includes segmented regions that accurately identify and localize the anomalies.

Refer to the following video to create an anomaly segmentation model.

  1. In the left navigation panel, navigate to Model Copilot > Anomaly Identification.

  2. In the Anomaly Models screen, click New at the top-right corner to create a model project.

  3. In the Create Anomaly Model window:

    1. Enter Name and Description.

    2. Under Clone from, you can select an existing model to clone the images and edit as needed.

    3. Click Submit.

  4. Upload good non-anomalous images and test images for the model training.

    You can upload images from your local system or import images from the catalog.

    1. Under the Spec tab, click the + (plus) icon on the right-hand side, and click Upload Images.

      You can upload a minimum of 10 and a maximum of 100 good images. If you have selected more than 100 images for upload, only the first 100 images will be uploaded.

    2. In the Upload Images screen, under the Add object name tab:

      1. Enter the Object Name to identify the object in the images on which the anomalies will be detected. For example, if cracks and smudges on glass are the anomalies of interest, the object name must be specified as ‘glass’.

      2. For a model that uses text inputs(ModelVisText), enable the Advanced options and add Adjectives that define the characteristics of a good image.

      3. The adjectives are used to derive the description of the object. You can additionally provide a Custom description that best describes the characteristics of a non-anomalous object. Once done, click Next.

    3. Under the Upload good images tab

      1. Browse to the folder location and select the good images. You can view the progress of uploading the images.

      2. Once the images are uploaded, click Submit.

    4. Click Ok to get the good images.

      If you need to add more images, you can click the + (plus) sign again to add more, as needed.

    5. The next step outlines the process for uploading anomaly images. Uploading anomaly images is optional.

    6. Under the Spec tab, upload anomaly and mask images or query the images from the catalog, if needed, to support better analysis and more accurate anomaly detection. However, this step is not mandatory.

      1. Click Add Anomaly Images and add the defect class name.

      2. Click Next and Upload anomaly images.

        Specific models(ModelSegmentGT) benefit from the presence of anomaly masks. Upload the mask images, following the same steps as above. The mask image format must be as follows.

        1. The file names of the mask images and the anomaly images must be the same.

        2. The file must be a greyscale PNG file with pixel values of 0 representing a good pixel and 255 representing an anomaly pixel.

          In case an anomaly image does not have a corresponding mask image, you can draw a polygon on the anomaly image after upload. Any anomaly image with a missing mask image is indicated with a red dot, as shown.

             

    7. Draw the Region of Interest (ROI) in the images where anomalies must be detected.

      1. Click the rectangular icon adjacent to the pen icon on the top-left corner.

      2. In the Draw region of interest screen, draw a polygon representing the area of interest that should be considered for anomaly detection.

        1. Click a point on the image and double-click at a point to start marking the box.

        2. Click at different points on the image to form the polygon as the area of interest, as shown below.

        3. Double-click to stop and close the polygon.

          The same bounding box will be applied to all the images, indicating that the anomaly detection will now occur within the bounding box area, i.e., the region of interest.

      3. To remove an image, select an image, click the Cancel mark, and click Remove Image.
         
        The image gets removed from the set.  Similarly, you can click the delete icon on the top-right corner to delete all the images.

    8. Click Save > Continue.

    9. Under the Data tab, click the + (plus) icon against Test Images, and click Upload Images.
      You can upload a maximum of 10000 images.  

      The anomaly model will be run on the test images to provide sample results for review and further action.

    10. Once the images are uploaded, click the Verbose icon to view details of the uploaded image files.

  5. Click Continue.
    The project screen displays the images in the respective sections one after the other, such as Good Images, Anomaly Images, and Test Images.

  6. Review the images, and click Submit.

  7. In the Submit session window, specify a few parameters that will be used to decide a suitable model.

    1. Select model: Enable the Advanced settings, if you want to select the model based on which the anomaly results should be populated.

    2. Apply location constraints: Enable this if the anomaly is expected at the same location in every image.

      For example, if all good images have a spot on the top left corner of the image and the test image has a spot on the bottom right corner of the image, then with location constraint applied, this will be flagged as an anomaly since the top left corner of good images is different from the top left corner in the test image.

      Hover the mouse on the question mark (?) icon to view the tooltip.

    3. Use visual features only: Enable this option to ignore any textual information, such as Object name, in the image during detection.

    4. Enable tiled segmentation: Enable this option if you have extremely fine anomaly artifacts or have high-resolution images. The procedure divides the image into a grid of tiles and runs the anomaly segmentation model individually on each tile.

    5. In case you have created your own docker image for anomaly segmentation, select the docker image
       

    6. Allowing the system to select a model is preferred but in case of advanced use cases, you can choose the model explicitly. To do this, enable Advanced Settings.

      1. Select a model from the list.

      2. Enter the Train params and Infer params with the corresponding values, if needed.

        Param settings for advanced users

        Train params: Enter advanced train params to fine-tune how the anomaly segmentation model is trained.
        Infer params: Enter advanced infer params to fine-tune how anomalies are inferred.

      3. If you select a model with tile segmentation, use Enable tiled segmentation and specify the parameters, if needed.

      4. Under Heat map settings, set the Heat map size, as needed, and the Heatmap smoothness factor.

        If you choose Custom, you can set the width and height of the heat map. Alternatively, you can choose Auto, for the system to automatically set the heat map size.

  8. Click Submit..

    This initiates an anomaly segmentation model training session, followed by generating inference results on the test images. Depending on the size of the test image set, the anomaly results may be displayed in a few minutes to hours.
     
    Once the model is created, it will appear in the Anomaly Models page, displaying the creation details, as shown.