Classification of object in a specific image region using a convolutional neural net with ROI mask as input
Given an image and region of interest (ROI) mask as input, the net classifies the region of the image marked in the mask.
Figure 1. Segment-specific Classification using CNN
For example, in Figure 1 the net is given the same image twice with different masks and output the object class of the segment marked by each mask.
This net achive 83% accuracy on the coco objects data set.
For more details see Classifying a specific image region using convolutional nets with an ROI mask as input
Stronger but harder to use version of this net can be found here*
Figure 2.a Standard Classification net, b. Region specific classification net
The net architecture can be seen in Figure 2.b. The net main branch consists of standard image classification neural net (Resnet 50). The side branch responsible for focusing the attention of the classifier net on the input mask region, in order to achieve region specific classification of the mask segment. As shown in Figure 2.b attention focusing is done by taking the dot product the attention map and the first layer of net.
This network was run with Python 3.6 Anaconda package and Pytorch 1.
- Train net or download pre trained net weight from here or download net with weight set (run out of the box) from 1 or 2.
- Open RunPrediction.py
- Set Path to the trained net weights file in: Trained_model_path
- Run script to get prediction on the test set
- Paths of input image and input ROI mask is given in ROIMaskFile and InputMaskFile parameters.
- Test image and ROI maps are supplied in the Test folder
- Download and extract the COCO 2017 train images and Train/Val annotations
- Download and make the COCO python API base on the instructions in (https://github.com/cocodataset/cocoapi).
- Copy the pycocotools from cocodataset/cocoapi to the code folder (replace the existing pycocotools folder in the code). Note that the code folder already contain pycocotools folder with a compiled API that may or may not work as is.
- Open Train.py
- Set Train image folder path in: TrainImageDir
- Set the path to the coco Train annotation json file in: TrainAnnotationFile
- Run the script
- The trained net weight will appear in the folder defined in: logs_dir
- For other training parameters see Input section in train.py script