Car damage assessment

Transfer learning with a pretrained snippet

Save training time and create well-performing models with small datasets. Sounds good?
This tutorial will teach you how.

By using transfer learning with our pretrained snippets, you can create a well-performing model even though you have a small dataset. You will do what your insurance company does, build a model that classifies damages.

click here to sign up

Person - Target audience: Beginners

You will learn to
Peltarion logo - Build a new AI model quick and easy.
Peltarion logo - Use a pretrained model in a classification problem.


Create project

First, click New project to create a project. Name it, so you know what kind of project it is. Naming is important.

New project button

A project combines all of the steps in solving a problem, from preprocessing of datasets to model building, evaluation, and deployment. Using projects makes it easy to collaborate with others.


Add dataset to the project

After creating the project, you will be taken to the Datasets view, where you can import data.

Click the Data library button and look for the Car damage - tutorial data dataset in the list. Click on it to get more information.

Data library button

If you agree with the license, click Accept and import. This will import the dataset in your project, and you will be taken to the dataset’s details where you can edit features and subsets.

The car damage dataset

The car damage dataset contains approximately 1,500 unique RGB images with the dimensions 224 x 224 pixels, and is split into a training- and a validation subset.

Classes

The illustration show sample images from the various classes in the dataset. Note that the unknown class contains images of cars that are in either a pristine or wrecked condition.

Each collected image represents one car with one specific type of damage. This means that the dataset can be used to solve a single-label classification problem.

Example images from each class
Figure 1. Example images from each class; Broken headlamp, Broken tail lamp, Glass shatter, Door scratch, Door dent, Bumper dent, Bumper scratch, Unknown

Create subsets of the car damage dataset

The subset column, containing a T or a V, indicates if the row should be used for training or validation. The split between training and validation data is approximately 80% and 10% (there is a 10% test set as well that you won’t use). This column was created during the preprocessing of the raw data.

Even though it is possible to use the default subsets created by the platform when you upload the data, it is more advantageous to create a conditional split based on the subset column.

  • Click New subset and name the training subset Training set split.
    Select Add conditional filter and set:

    • Feature to subset

    • Operator to is equal to

    • Value to T.

Click Create subset.

Conditional training subset
Figure 2. Training subset
  • Repeat the procedure. Name the new subset Validation set split.

    • Feature to subset

    • Operator to is equal to

    • Value to V.

Conditional validation subset
Figure 3. Validation subset

Save the dataset

Click Save version and click Use in new experiment.

Use in new experiment button

Build a model in the Experiment wizard

Name the experiment in the Experiment wizard.

  • Dataset tab
    Make sure that the Car Damage dataset is selected.
    Change Subset to standalone subsets
    Set Validation set split for Validation subset, and Training set split for Training subset.

  • Input(s) / Target tab
    Select image as Input feature and class as Target feature.

  • Snippet tab
    Select the EfficientNet B0 snippet.

  • Weights tab
    Select ImageNet for pretrained data.

Click Create, and the EfficientNet B0 blocks will be added to the Modeling canvas.

Create button

Run experiment

Before you run the experiment, click the Settings tab and change the Learning rate to 0.0005.

Now, everything is set up, so just click Run.

Run button

Analyze the experiment

Navigate to the Evaluation view. Since the model solves a classification problem, a confusion matrix is displayed. The top-left to bottom-right diagonal shows correct predictions. Everything outside this diagonal is errors.

Confusion matrix

Note that metrics are based on the validation subset which only consists of 10% of the original dataset.

Click the dropdown next to Cells and select Percentage. The normalized values that are now displayed correspond to the recall for each class.

The recall values clearly indicate that the model has learned the features in the images.

Model evaluation — Normalized confusion matrix
Figure 4. Model evaluation — Normalized confusion matrix

Deploy the trained model

In the Deployment view click New deployment and select experiment and checkpoint.

Click the Enable switch to deploy the experiment. You can now call your deployed experiment with your own product using the Url and Token. For example, when you build your own app with Bubble.

Test with Peltarion API tester

We’ve also made it super easy for you to test the deployment. Click on Test deployment, and you will be directed to our Image & Text Classifier - API tester.
All info from your deployment is prepopulated (token, URL, Input parameter).
You just need an image to test. Try to download this image of a seriously damaged car or take your own photo.

Damaged car
Figure 5. Seriously damaged window. Photo by Prateek Katyal on Pexels.

Add the photo to the bottom left corner and then click the Play button.

play

Result? Yes, the model predictied prediction is glass_shatter.


Tutorial recap

Using transfer learning with pretrained weights, you have saved hours of training time and created a better performance than would have been possible if you had trained the model from scratch.


Was this page helpful?
YesNo