The objective of the problem is to implement classification and localization algorithms to achieve high object classification and labelling accuracies, and train models readily with as least data and time as possible. The solution to the problem is considered in the following blog.
The efficiency of a model is dependent on various parameters, including the architecture of the model, number of weight parameters in the model, number of images the net has been trained on, and the computational power available to test the models in real time. The third parameter can’t be controlled, thus leaving us dependent on the first two parameters. Thus transfer learning works the best in this scenario, for the pre-trained weights are adjusted according to our dataset, although minimal errors and reliable accuracies are obtained.
For image classification, we use a keras model with the model summary obtained by running the code below**.** The model’s parameters are tuned to suit the maximum change in information for as minimum data as possible. Thus, we have the batch normalization layers, that randomly shake up the weights to make the model generalized.
We use the MobileNet model for training on our dataset. The dataset has been taken from HackerEarth deep learning challenge to classify animals.
If you need any other domain-specific dataset:
You can find thousands of such open datasets here.
We choose 10 random classes from the dataset and change the number of images per class and the size of the fully connected layers, and report the results.
SSD runs a convolutional network on input image only once and calculates a feature map. Now, we run a small 3×3 sized convolutional kernel on this feature map to predict the bounding boxes and classification probability. SSD also uses anchor boxes at various aspect ratio similar to Faster-RCNN and learns the off-set rather than learning the box. In order to handle the scale, SSD predicts bounding boxes after multiple convolutional layers. Since each convolutional layer operates at a different scale, it is able to detect objects of various scales.
We compared two models, initially YOLO(darknet) and later SSDs and compared their accuracies and speeds. Since our inputs are images, the FPS parameter is not used to differentiate the models. Moreover, the SSDs are a balance between the Faster — RCNN model and the YOLO model. Let’s see what the experiment tells us?
The SSD model is implemented using the dnn module, with the help of Adrian Rosebrock, in openCV’s library.
The YOLO pre-trained weights were downloaded from the author’s website where we choose the YOLOv3 model. Since it is the darknet model, the anchor boxes are different from the one we have in our dataset. Hence we initially convert the bounding boxes from VOC form to the darknet form using code from here. Then we train the network by changing the config file.
Results:
SSDs: IOU= 0.74, mAP: 0.83 Time /epoch: 12 minutesYOLOs: IOU= 0.69, mAP: 0.85 Time/epoch: 11 minutes
Output Images
SSDs used for Vehicle Detection
Output with YOLOv3 Pretrained Weights
The overall problem is stated as one where we need to trade off the speed and accuracy. The overall solution is proposed as two different models for various types of images.
The trade-off between speed and accuracy is accompanied with computational power available. The YOLO model is suitable for high-speed outputs, where accuracy is not that high… whereas SSDs provide higher accuracies with high-speed outputs with a higher computation time.
Hence choose SSDs on good microprocessors, else YOLO is the goto for microprocessor-based computations.
Shameless plugin: We are an online tool to make it super easy for you to build ML datasets like doing image bounding boxes, NER tagging etc. Check us out: the best image labeling tool!