This is the tutorial article about the Deep Block’s image segmentation application.
In this tutorial, we will create an AI model that segments hair from a photo. We will use the photos of celebrities to train the AI model.
Sign in, and click “TRY DEEP BLOCK” button on the top right corner.
At the Console page, click “Create” button on the top right corner.
Click Computer Vision and click Image Segmentation. Set the Project Name as “IMDB_CROP_Hair_Segmentation”. Be careful not to use space in the project name. Click “Create” button.
Click and open the project in the console page.
Create a category by clicking the + sign in the “Categories” pane in the left.
Click the added category and click the edit name icon like below. You can then change the category name to “hair”.
Now we can upload the images by dragging and dropping to the Train pane. We are going to use 100 images for the training. But we recommend you to use more images. Having more training data will make a better model.
You will get this message when all of the images are uploaded. Click confirm.
Now we will create the training data set for the AI model. Click one of the image files in the “Train” pane. We will use full screen mode by clicking the full screen button like below. We recommend you to use full screen mode when you want to use high-resolution images.
Then click the draw mode button to mark the hair in the image.
You can start drawing a polygon now on the image. Slowly draw the polygon along the hairline. Clicking or pressing Ctrl key will draw a vertex.You can change the line direction at each vertex. Keep drawing until when you get close to the start vertex.
When the last vertex is close to the start vertex, press enter key to complete drawing the polygon.
You can click the select mode to modify the polygon. You can change the position of each vertex.
Once the boundary is well connected, you can move on to the next image. Press esc key to exit the full screen mode.
Continue to mask the object you want to segment. Clicking will be physically straining, so we recommend you to use the Ctrl key. Since you will be using more than 100 images for the training data, it may be a lot of work. We recommend you to take breaks in between. Your work will be saved in our cloud. We also plan to support sharing a project, so you can collaborate with others to reduce work.
When you are done with all of the images, click “Run” and then click the “Train” button. We’ll have our Epochs set to 5000.
After some time, the training will begin. The time remaining will be shown on the screen. You can turn off your web browser and come back later.
After training, you will see the Training score graph. Check that it has increased well throughout time. Also, check that the loss has decreased.
Click the “Predict” tab to upload images you want to validate with.
Drag and drop the images you want to validate the trained model with.
We will first set the threshold value to as low as 30%. In general, if you set a low threshold value, there will be objects that the AI model finds wrong. To fix that, find the false positive object with the highest likelihood value. Then change the threshold score above that value and run the prediction again. The AI model will be able to do the segmentation well without the false positive cases
Run the prediction by clicking the “Predict” button on the top right.
You will see the results like below. You can click on the images in the Predict pane to check different images. If you want to improve the accuracy, you can add more training data.
If you have any questions, feel free to contact us.