[TUTORIAL] Image Segmentation

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.

  1. Sign in, and click “TRY DEEP BLOCK” button on the top right corner.
     
  2. At the Console page, click “Create” button on the top right corner.
  3. 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.
  4. Click and open the project in the console page.
  5. Create a category by clicking the + sign in the “Categories” pane in the left.
  6. Click the added category and click the edit name icon like below. You can then change the category name to “hair”.

  7. 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.
  8. You will get this message when all of the images are uploaded. Click confirm.
  9. 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.
  10. Then click the draw mode button to mark the hair in the image.
  11. 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.
  12. When the last vertex is close to the start vertex, press enter key to complete drawing the polygon.
  13. You can click the select mode to modify the polygon. You can change the position of each vertex.

  14. Once the boundary is well connected, you can move on to the next image. Press esc key to exit the full screen mode.
  15. 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.
  16. 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.
  17. 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.
  18. After training, you will see the Training score graph. Check that it has increased well throughout time. Also, check that the loss has decreased.
  19. Click the “Predict” tab to upload images you want to validate with.
  20. Drag and drop the images you want to validate the trained model with.
  21. 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
  22. Run the prediction by clicking the “Predict” button on the top right.
  23. 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.
  24. If you have any questions, feel free to contact us.

 

Leave a Comment