IntroductionThe development of maritime autonomous surface ships (MASS) has rapidly emerged in recent years worldwide, with strong support in northern EU countries, the USA, China, and others, and is also supported by the International Maritime Organization. Currently, various autonomous and remote-controlled ships are being trialed in testing areas in Denmark, Finland, Norway, and many other areas worldwide. As an example, Yara Birkeland will be one of the world’s first fully electric and autonomous container vessels. Besides many navigations, regulatory, cyber-security and other challenges, sensory networks, and massive data processing for increasing situational awareness of MASS present one of the major challenges in autonomous maritime shipping. This example demonstrates how to extract useful information from satellite images using a simple deep learning-based ship detector, which can be included in a broad range of situational awareness sensors of MASS systems.
Data and resourcesSatellite images from the Airbus Ship Detection Challenge database are used and arranged in two folders: train and test.
- Train folder includes 100 ship images. These images are used for training the deep learning detector.
- Test folder includes additional 50 ship images. These are used after training to evaluate the performance of the developed detector on new, unseen data.
ObjectiveThe task of this example is to use the dataset of available images (train folder) and construct the ship detector using deep learning and transfer learning. The objective for the developed detector is then to detect and locate the ships on new images (test folder) which the detector hasn’t seen before.
Solution approachThe presented solution approach comprises of the following steps:
- Using Image Labeler for labeling the ship segments.
- Preprocessing data (creating datastore and resizing images).
- Applying pretrained ResNet50 network as a feature extractor.
- Creating and training YOLO object detection network.
- Evaluating the trained detector on test images.
Labeling ships in satellite imagesUsing the Image Labeler App, ships are manually labeled in all training satellite images, without writing any line of code. The app is very intuitive and self-explanatory (as shown in Figure 1) and enables the end-user to accomplish the labelling task in a very short time. Figure 1: Working with Image Labeler to label the ship segments.
Data preprocessingTo use the labeled images for deep network training, the following two steps must be accomplished:
- Create a datastore for loading the images and labels. The datastore acts as a repository for data and overcomes the out-of-memory issue which often appears when dealing with large data such as images.
- Resize images (and bounding boxes) into required YOLO dimensions. In this example, a ResNet-50 feature extractor model is used which requires the images to have the dimension of 224 x 224.
Applying pretrained ResNet50 deep network as a feature extractorA pretrained version of the ResNet-50 deep network model can be found in MATLAB Add-Ons. This model has been trained on a subset of the ImageNet database, has 177 layers in total, corresponding to a 50-layer residual network, and can classify images into 1000 object categories. In our example, the pretrained ResNet-50 model is used as a feature extractor. Therefore, the 'activation_40_relu' layer is selected as the feature extraction layer, and subsequent layers are replaced with the YOLO v2 detection subnetwork. We can do this process programmatically (writing the code in line) or interactively using the Deep Network Designer App. Figure 3 shows the location of the 'activation_40_relu' layer in the ResNet-50 model. Figure 3: Location of the 'activation_40_relu' layer in the ResNet-50 model, used as a feature extractor
Creating and training YOLO object detection networkYOLO object detection algorithm employs convolutional neural networks (CNN) to detect objects in real-time. YOLO is an abbreviation for the term ‘You Only Look Once’ which suggests that the algorithm requires only a single forward propagation through a neural network to detect objects. This algorithm is popular because of its speed and accuracy. It has been used in various applications to detect traffic signals, people, parking meters, and animals. Various parameters and settings need to be specified for the YOLO algorithm:
inputSize = [224 224 3]; % network input size numClasses = 1; % number of object classes to detect (we have only one class 'Ship') numAnchors = 7; % number of anchor boxesAnd then, Anchor Boxes for Object Detection are estimated based on the size of objects in the training data:
[anchorBoxes, meanIoU] = estimateAnchorBoxes(preprocessedData, numAnchors);YOLO v2 object detection network is created by using the ResNet50 feature extractor:
lgraph = yolov2Layers(inputSize,numClasses,anchorBoxes,featureExtractionNetwork,featureLayer)Figure 4: The resulting YOLO v2 image detector architecture based on the ResNet-50 feature extractor Finally, YOLO v2 object detector is trained (training may take an hour or two) using various training options:
options = trainingOptions('sgdm', 'MiniBatchSize',12, 'InitialLearnRate',1e-3, 'MaxEpochs',120, 'ValidationData',preprocessedData); [detector,info] = trainYOLOv2ObjectDetector(preprocessedData,lgraph,options);Note: all these steps (designing, loading training data, setting training options, and training) can be done within the Deep Network Designer App. After the training, the optimized model needs to be exported to the workspace. An automatic function can be generated of the entire process in order to avoid the manual design if needed again.
Evaluating YOLO detector on train imagesFigure 5 shows an excellent performance of the trained YOLO detector on train images (only the first 15 images are shown). Figure 5: Evaluating YOLO detector on train images
Evaluating YOLO detector on test imagesDetection of ships on new images (test data set) shows worse performance, although several ships are correctly detected (Figure 6). Figure 6: Evaluating YOLO detector on test images Considering the very good performance on the train data set and the relatively insufficient performance on the test data set, the trained model is most probably overfitted. However, it demonstrates that the small data set can be used to detect some objects. To improve the detection result on new images, the YOLO detector should be trained on a considerably larger dataset of images, and independent validation data set should be used to avoid overfitting. And finally, the training options (hyperparameters) can be further optimized to obtain a higher accuracy on the test data. This can be done using the Experiment Manager App which is a great tool to keep track of all the hyperparameter changes.
Key takeawaysThis example presents the step-by-step development of a deep learning solution for the detection of ships on satellite images. The solution approach is quite general and can be adapted to different domain areas, similarly as this case study was adopted from an earlier MATLAB application of Object Detection Using YOLO v2 Deep Learning. A few conclusions and takeaways can be summarized:
- The trained YOLO network already successfully detects several ships in satellite images, although some ships on test images are not detected.
- Training data set of only 100 ship images is too small to train a ship detector from scratch, but by using the transfer learning approach, the required number of images is enough to quickly obtain first results.
- The example presents the potential workflow toward the solution, and in practice, many more annotated images (in order of hundreds or thousands of images) should be provided to train a detector with good detection accuracy.
- This material can inspire other lecturers to develop further Deep Learning-based examples within the framework of Maritime Engineering.
MATLAB codeThe complete MATLAB code with a database of images is available at MATLAB Central File Exchange and GitHub:
댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.