Assessment of car Damage By Classification AI model for Insurance

Want an assessment of car damage only by taking photo of it! Interplay is here

Written By Chetan Iterate ()

Updated at January 20th, 2021

By this example, we will learn to create a classification AI model for classifying into multiple outputs.

Here in this example, we created a simple classification model for segregating car damage by these factors.

  • Door Scratches
  • Bumper Scratches/structural damage
  • Broken/Damaged Tail Lamp
  • Glass Shatter
  • Door dent
  • Bumper Dent
  • Broken/Damaged Head Lamp
  • Other/Unknown

Training Specimens :

Steps

1 ) search for the 'inject' node which looks like this:


 


Drop this node in the editor.

 Search for the 'function' node which looks like this :



also, drop this node in the editor.

The 'console' node is optional and can be used for viewing console output when development is needed, search and drop in the editor. This node looks like this:


2) Connect these nodes to create flow as shown in figure (for this example, we named:  MULTICLASS - Image Classification ) to host our main flow, Here We renamed "Python function" to "Dir-maker" which can be done by double-clicking and giving it name using "Name":  

3) Prior to training a model (In this case of the classification model), we need to create a directory structure for the project which is as: 

Inject the code where function generates the structure of folder as given above.

Simplifying the process by a python script.

Dir-Maker

import os
//# root path
path = './public/private/Image_Classification/'
project_name = path + "car_damage"
try:
os.mkdir(path)
os.mkdir(project_name)
except:
os.mkdir(project_name)
required_dir_struct = ['Dataset','Temp','Executed_NB','Models','Results','QueryImages']
for folder in required_dir_struct:
try:
os.mkdir(project_name+'/'+folder)
except OSError as error:
print(error)
status = 'Dir struct has been created !'
msg['payload'] = status
 return status

This will create Directories as a script for viewing directory click on:

We can see the directory structure Generated as:

5) Create a new node with the same 'inject', 'Python 3', 'HTTP output', 'console' and connect them as shown in the figure :

The Fastai framework is used for training a model for this project as the Fastai background works on Jupyter notebook.

Code in: Trainer

import osimport subprocess
import papermill as pm
import os
from os import path
def execute(): result_json =
pm.execute_notebook("/interplay_v2/public/private/Image_Classification/pneumonia/I mg-classification-base
-v1.ipynb","/interplay_v2/public/private/Image_Classification/pneumonia/Executed_NB/executed-img-class-v1.ipynb") return result_json final_execute = execute() msg['payload'] = final_execute
 return msg

8) Click on the Trigger point of the inject node (Highlighted) :

9) After triggering the second node initiates the Jupyter notebook consisting of Training AI with predefined parameters.

The final part is to segregate images based on trained output from the model.

6) Here comes the classification part, beneath our created route let's create a new route by dropping the same 'inject', 'Python 3 Fastai ', 'console', 'HTTP output' and connect them as shown:

 Code in Predictor : 

import subprocess
import papermill as pm
import os
from os import path
# Dependency : p2j , papermill , python kernal
# jupyter lab : https://github.com/jupyterlab/debugger
#---------------------------------------------------------------------------------------------------+
# PATHS
# #---------------------------------------------------------------------------------------------------+
def execute():
#https://i.ibb.co/9cN3YVT/NORMAL2-IM-1427-0001.jpg
#https://i.ibb.co/BjD5qVg/person1954-bacteria-4886.jpg
#https://i.ibb.co/jHD4zX9/noodle.png
#https://i.ibb.co/xqrQQfd/hotdog.png
# PROJECT_NAME,
# MODEL_Ver
PROJECT_NAME_ = "car_damage"
MODEL_Ver_ = "v1"
USER_QUERY_FOLDER_PATH_ =
"/interplay_v2/public/private/Image_Classification/car_damage/QueryImages"
result_json = pm.execute_notebook("/interplay_v2/public/private/Image_Classification/car_damage/ImgClassification-Predictor-Bunch
-v2.ipynb","/interplay_v2/public/private/Image_Classification/car_damage/Executed_NB/[Executed]ImgClassification-Predictor-Bunch-v2.ipynb",
parameters
=dict(PROJECT_NAME=PROJECT_NAME_,MODEL_Ver=MODEL_Ver_,USER_QUERY_FOLDER_PATH=USER_QUERY_FOLDER_PATH_))
return result_json
status = "Classification is completed!, check results at : ./car_damage/Results"
final_execute = execute()
msg['payload'] = {"json":final_execute , "status":status}
 return msg

7) Click on "Deploy", after Successful deployment notification, we can trigger nodes as we desire

8) Click on the Trigger point of the inject node (Highlighted) :



after triggering the third flow (Predictor) wait for some time for classification output and segregated are stored in our working directory in the 'Results' folder.


Was this article helpful?