{'fraction_non_alphanumeric': 0.032399150743099785, 'fraction_numerical': 0.011847133757961783, 'mean_word_length': 4.966810235621991, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
A Generative Approach for Detection-driven Underwater Image Enhancement

In this paper, we introduce a generative model for image enhancement specifically for improving diver detection in the underwater domain. In particular, we present a model that integrates generative adversarial network (GAN)-based image enhancement with the diver detection task. Our proposed approach restructures the GAN objective function to include information from a pre-trained diver detector with the goal to generate images which would enhance the accuracy of the detector in adverse visual conditions. By incorporating the detector output into both the generator and discriminator networks, our model is able to focus on enhancing images beyond aesthetic qualities and specifically to improve robotic detection of scuba divers. We train our network on a large dataset of scuba divers, using a state-of-the-art diver detector, and demonstrate its utility on images collected from oceanic explorations of human-robot teams. Experimental evaluations demonstrate that our approach significantly improves diver detection performance over raw, unenhanced images, and even outperforms detection performance on the output of state-of-the-art underwater image enhancement algorithms. Finally, we demonstrate the inference performance of our network on embedded devices to highlight the feasibility of operating on board mobile robotic platforms.


INTRODUCTION
Autonomous Underwater Vehicles (AUVs) are seeing increasing use in assisting humans with tasks in underwater environments, e.g., in environmental [2] and infrastructure [3] (e.g., pipelines and cables) monitoring, marine archaeology [4,5], and underwater search and rescue. Visual perception is one of the preferred tools for many of these tasks due to the availability of cameras and their passive, energy-efficient sensing capabilities. However, due to environmental factors such as turbidity and image distortions caused by light absorption, refraction, and attenuation, the utility of visual sensing can be severely hampered. Recent work has thus looked into underwater image enhancement techniques for marine robotics and have yielded promising results. Enhancement techniques can be broadly classified into two categories: those taking the classical approach, and those using deep machine learning algorithms. The latter methods have seen rapid rise recently, using both Convolutional Neural Networks (CNNs) [6] and Generative models, e.g., Generative Adversarial Networks (GANs) [7] and Variational Autoencoders (VAEs) [8]. However, the goal of these methods is usually to either alter the image to match in-air images or improve general image quality, as determined by a human viewer, focusing solely on image aesthetics. With regard to task completion, if the enhancement model is able to be executed on the AUV, these enhanced images can then be used in conjunction with visual detection or tracking models needed to complete the given task. As these tasks are often performed with a team of divers, the ability to detect, track, and follow divers will be a fundamental requirement in many applications.
For underwater diver tracking, traditional methods and more recent tracking-by-detection approaches have been successfully used. Islam et al. [9], extending the Fourier Tracker algorithm [10], uses frequencydomain motion signatures of divers as a 'filtering' criteria to identify tracks extracted using Hidden Markov Figure 1: Samples of detector-driven, enhanced images. The bottom images are from unenhanced ocean footage [1]. The top images are enhanced using our proposed model. Models [11]. Current methods of visual diver detection and tracking include training state-of-the-art (SOTA) detection models on diver datasets (e.g., [1]) using CNN-based models [12] and tracking algorithms that take into account diver motion (e.g., [13,14]).
Due to environmental factors (see Figure 1) there will be situations where the trained detector does not work adequately without preprocessing or re-training. In these cases, it is shown that first using an image enhancement model and then performing diver detection can improve results [15,16]. We take this idea a step further and propose that a generative model designed to incorporate task requirements during the training stage can improve task-based perception.
In other words, rather than improving images guided by human assessment, they should be enhanced based on the needs of a specific robot task. In this work, we explore image enhancement guided by the task of detecting scuba divers. Methods directly integrating perception into GAN image enhancement have been used for improving small-object detection [17,18,19,20], and reducing blurriness of in-air images [21]; we hypothesize that a similar approach could also improve diver detection.
In this paper, we propose a Detection-driven Underwater Image Enhancement model based on Generative Adversarial Networks, which we refer to as DUnIE-GAN. In addition to focusing on learning image-toimage translation from a distorted to enhanced domain, the proposed model makes use of bounding box locations and classification information provided by a pre-trained diver detection model to guide the enhancement towards better detection results. We provide insights into its design choices and present experimental results showing the positive effects of incorporating additional detection information into a GAN-based image enhancement model such as FUnIE-GAN [22]. Moreover, we quantify the improved diver detection results for a variety of cases and perform extensive image quality analysis on the DUnIE-GAN-enhanced images. We also conduct performance comparison with several SOTA underwater image enhancement models that further validates the effectiveness of our proposed approach.

Visual Diver Detection
Visual detection and following of human divers by autonomous robots is well-studied for its usefulness in human-robot cooperative underwater missions [23,24]. Due to operational simplicity and computational efficiency, the simple feature-based detectors followed by standard model-free trackers have been traditionally used in autonomous diver-following applications [25,26]. Particle filters and optical flow-based methods are also utilized for tracking divers in spatio-temporal domain [26]. Since color distortions and low visibility issues are common underwater, the frequency-domain cues [27,28] of divers' motion are used for reliable detection as well. Besides, several feature-based learning approaches [26,29] such as SVMs and ensemble methods have been investigated for diver tracking and underwater object tracking in general. However, these methods lack generalizability and often fail in noisy visual conditions.
To address the inherent difficulties of underwater vision, several CNN-based diver detection models are proposed recently [12,30,31]. Once trained with large-scale comprehensive data, these models can achieve invariance to the appearance, scale, or orientation of divers (to the camera). They also provide a considerably better generalization performance than classical approaches. Despite the high learning capacity, in practice, their performance gets severely affected by marine artifacts such as noise and optical distortions, which result in low-contrast, often blurred, and color-degraded images [22]. Various image enhancement techniques are generally adopted to mitigate these challenges, i.e., to restore the perceptual and statistical qualities of the input images before passing it to the diver detection pipeline.

Enhancing Underwater Imagery
The underwater image enhancement problem deals with correcting non-linear image distortions caused by the particularities of light propagation underwater [32,33]. Some of these aspects can be modeled and well estimated by physics-based solutions by exploiting prior knowledge (e.g., haze-lines and dark channel prior [32,34]) or making statistical assumptions (e.g., adopting an atmospheric dehazing model [35,36]). However, these approaches require scene depth and water-quality measures for accurate modeling, which are not always available in practice.
As a practical alternative, learning-based approaches have been widely explored and they have demonstrated inspiring success in recent years. Several models based on deep CNNs and GANs report SOTA performance [37,22,38] on benchmark datasets. Driven by large-scale supervised training, these approaches learn sequences of non-linear filters to approximate the underlying pixel-to-pixel mapping [39] between the distorted and target image domains. The contemporary CNN-based generative and residual networks (e.g., Deep SESR [37], WaterNet [38]) are shown to be very effective in learning such mapping. Moreover, the GAN-based models (e.g., FUnIE-GAN [22], UGAN [15], Fusion-GAN [40]) attempt to improve generalization performance by employing a two-player min-max game, where an adversarial discriminator evaluates the generator -enhanced images compared to ground truth samples. This forces the generator to learn realistic enhancement while evolving with the discriminator toward equilibrium. While the existing models provide good generic solutions for perceptual enhancement, learning to recover image distortions for specific tasks such as diver detection or classification has not been explored in-depth in the literature.

GANs and Object Detection
While not extensively explored for underwater applications, integrating object detection components within the GAN architecture has been well-studied in the terrestrial domain. For instance, the auxiliary classifier GANs [41] are proposed to synthetically generate realistic images, while several variants of the Multi-task GAN (MT-GAN) [20] and Perceptual GAN [18] are used to improve small-object detection performance by using image super-resolution techniques. In such models, the components of bounding box regression and classification are determined through discriminator branches using additional fully-connected layers. Besides, Liu et al. [19] integrate a RetinaNet [42] detector in DetectorGAN; however, this is done for generating data to train an object detector rather than improving its performance through image enhancement.
Our model differs firstly in that we formulate a detection-guided style transfer problem to learn to enhance the distorted images rather than performing enhancement or super-resolution separately. Secondly, our model attempts to enhance images for use in conjunction with a pre-trained object detector for specific task execution.

Methodology
As shown in Figure 3, our proposed DUnIE-GAN model integrates a pre-trained diver detector with a GANbased image enhancement model. Similar to the existing learning-based models [22,15], given a source domain X of distorted underwater images and target domain Y , our goal is to learn a mapping G : X → Y . However, instead of learning a map that perceptually enhances the resulting image, our goal is to enhance the images in a way that improves detection results of the diver detector. For the purposes of this paper, the only diver detector used is a trained Single Shot Detector (SSD) [43] model with a MobileNet V2 backbone 1 .

Data preparation
For the supervised training, our dataset was prepared with the end goal of better diver detection in mind.
Our dataset was created from the combined ocean data from [12] and [1], which contain single diver images with a variety of environmental factors. We then used the diver detector to select images in which the diver was detected with a 0.55 accuracy score to ensure possible (detector determined) true positive detections during the training process. These images were then distorted based on the method used by Islam et al. [22] in order to create a paired dataset; see Figure 2 for some training image samples. Each training image includes only one diver. Hand-labeled annotations of these images are used for the ground truth bounding box data.

Overarching Model
Following the standard paired training pipelines of [15,22], we use distorted images as input to the generator. The generator then produces synthetic images, which are sent to the discriminator to get its validity response. As mentioned earlier, the generator and discriminator then play a min-max game to eventually learn the mapping G : X → Y . In our model, we also use the synthetic images as input for the diver detector to find detector-specific bounding boxes and classification scores, which are used in an additional detection-based loss function.

Generative Adversarial Network Architectures
The GAN portion of our model is based on the FUnIE-GAN [22] architecture. The generator network follows the U-Net [44]-like encoder-decoder structure with an input resolution of 256 × 256 × 3; the encoder eventually learns 256 feature-maps of size 8 × 8. The decoder uses these feature-maps to learn to generate an enhanced 256 × 256 × 3 image. The discriminator uses the Markovian Patch-GAN [39] architecture, which takes as input the combination of real and generated images in 256 × 256 × 6 form and outputs a 16 × 16 × 1 real or fake response. Specific network details on FUnIE-GAN architecture can be found in [22]. As the generator and discriminator networks are not altered, we are able to take advantage of seeding our model with a pre-trained FUnIE-GAN model to initiate training.

Diver Detector
Our model incorporates the previously mentioned SSD (MobileNet V2) pre-trained diver detector. We incorporate this model outside of the GAN architecture, with the detector being independent from the generator and discriminator networks. This design is intentional in order to create a modular network that could be used with other types of detectors or image enhancement models. For the training process, we set the detection threshold to 0.01 and choose to only return the detected bounding box with the highest classification score to tune DUnIE-GAN towards improving detections after enhancement. For each batch during training, the detector runs on every generated image and outputs a bounding box b = (x min , y min , w, h), as well as the confidence score s ∈ [0, 1]; here, (x min , y min ) is an image coordinate, whereas w and h represent width and height of the box, respectively. These outputs are subsequently used in the detection loss L rc described below.

Objective Function
Like the learning pipeline of FUnIE-GAN [22], our objective function incorporates global similarity and image content losses, as well as the conditional adversarial loss. Additionally, we design a detection loss similar to those used in [17] and [20] which includes bounding box regression and classification portions.
Base GAN Loss: We use the standard conditional adversarial loss [45] to learn the mapping of G : {X, Z} → Y where X(Y ) represents the distorted (target) domain and Z represents random noise; it is defined as follows Since we also want to maintain the same aspects between the target and generated images, as in [22], we also include the loss terms for global similarity (L 1 ) and image content (L con ) as follows: RC Loss: Here, we include the output of the diver detector into the objective. Let s be the confidence score, and b d and b a be the bounding box information from the detection and ground truth annotations, respectively. Our detection loss is then calculated as where L reg (b d , b a ) is the following loss proposed in [46] Smooth and L cls = − log s. The use of these losses is inspired by the methods used in [20,18] and [17]. If there is no detection found in a specific image, an arbitrary bounding box and score are introduced. This in turn returns a high loss value for that specific image in order to weight the model towards accurate detection. Besides, Liu et al. [19] mentions that adding a loss similar to L rc to the generator may minimize performance on real images as the model will be tuned towards good detections on synthetic images. However, Zhang et al. [20] suggests including a similar loss in optimizing the generator to help enforce a semantic level similarity constrain. Our ablation experiments investigate the effects of using such loss terms in the learning, which we discuss in Section 4.2.
Objective function: Using the loss components defined in [22] as well as the new detector-based loss formulated in Eq. 4, our final objective function is expressed as We use λ 1 = 0.7 and λ c = 0.3 as in [22] as scaling factors.

Implementation details
Our model is implemented using the PyTorch libraries 2 for the majority of the optimization pipeline. However, the trained diver detector is implemented in Tensorflow [47], so our environment includes both libraries. Each DUnIE-GAN model was trained on a Linux Machine using a NVIDIA GTX 1080 GPU. DUnIE-GAN was trained on 8k images with single annotated divers. Various categories of test sets are created by images from [12] and [1] that were excluded from the training. More detailed information on these test sets can be found in Section 4.3.
Our model uses pre-trained weights of FUnIE-GAN on the EUVP dataset 3 for 100 epochs, and then it is further tuned with our training pipeline in Eq. 6. The convergence of different training models fall between 80-160 additional epochs. In particular, the model using L rc to optimize the generator and discriminator is trained for 120 epochs, while the model with L rc in the discriminator is trained 140 epochs. A batch size of 32 is used in all the training modes; here, we use a larger batch size than is used in [22] to increase the probability of images with detectable divers.

Loss Ablation
We first present an ablation study based on how the object detection loss is integrated with our model. We abbreviate the location of L rc loss optimizations as follows:  [20]. We also make note that as our base network architecture and losses are inspired by FUnIE-GAN, results of DUnIE-GAN-N would be similar to those of pre-training FUnIE-GAN with the EUVP dataset and then additionally training with our diver dataset.
As we are interested in increasing the diver detection accuracy, we use DUnIE-GAN in conjunction with the diver detector used in training our model. We use Average Precision (AP) [48] and Intersection over Union (IoU) as our performance metrics. Mean IoU per image is found, with penalties of an additional score of 0 included for each extra detection per image. The mean of all IoUs over the dataset is then taken. All tests are performed with the diver detector score threshold of 0.55. The overall performance is determined based on 415 distorted single diver images that are not used for training or validation. The results are illustrated in Table 1. The baseline for this evaluation is determined by using the diver detector directly on the distorted images. It can be seen that while all models increase detection results, DUnIE-GAN-B and DUnIE-GAN-D have the highest scores of IoU and AP, respectively. To test these results on a more generalized task, we use these two models in comparison with other underwater enhancement tasks on non-distorted images.

Ocean Image Test Set and Comparison Models
We compare DUnIE-GAN with several underwater image enhancement models based on the results of the task of diver detection as well as on the results of image quality metrics. The test set, like the training set, contains images taken directly from [12] and [1] in various categories based on thresholding detected divers at 0.55 with the detector. The various categories include: • Single Diver (SD)-Detected: 415 images These sets are not synthetically distorted; also note that SD-Detected are the undistorted images used in creation of images for testing DUnIE-GAN ablation and have not been seen by the model during training. The enhancement models that we use for comparison include the physics based model multi-scale Retinex (MS-Retinex) [49] and the learning-based models WaterNet [38], Underwater GAN (UGAN) [15], Fast Underwater Image Enhancement GAN (FUnIE-GAN) [22], and Deep Simultaneous Enhancement and Super-Resolution (Deep SESR) [37]. All learning-based models are trained on the EUVP [22] dataset.

Diver Detection Comparisons
For the comparison of diver detection performance, we use the same metrics included in the loss ablation: mean AP and mean IoU. We evaluate the results of the diver detector after enhancing the images using the various models. The baseline is created by running the diver detector directly on the dataset images. The results of this comparison can be seen in Table 2. We find an interesting result that on this particular dataset, none of the enhancement models return AP results better the baseline images. However, both DUnIE-GAN model results are competitive with the enhancement models, while DUnIE-GAN-B achieves the highest scores on AP and IoU for the SD-Detected dataset. We posit that one reason Deep SESR does very well on this task is the model takes into account an additional information loss for saliency predictions during its training [37]. With regards to mean IoU, we again observe favorable results with both DUnIE- GAN models, and particularly in the case of SD-Undetected, having the highest scores. As we intentionally train the model for minimization of distance between bounding boxes, an increase in IoU when objects are detected is an encouraging result.

Image Quality Analysis
To analyze the enhancement, we conduct a performance comparison of all models using the underwater image quality metric (UIQM) [50]. We choose this evaluation as it is inspired by properties of human vision systems and evaluates image quality in methods that are shown to relate to human preference. A higher overall score lends itself to a higher correlation with perceived image quality. Results of this comparison are found in Table 3. As our goal is to show task-specific enhancement, rather than enhancement for human perception, we are not looking to have the best score but rather looking to compare these results with the capability of diver detection. We find that while WaterNet and UGAN receive high UIQM scores, it does not translate to higher detection results. See Figure 5 for a visual comparison. As our model is designed for task-specific goals, depending on the task, it may be preferable for the enhanced image to have UIQM scores similar to those of the original image.

Conclusion
In this paper, we introduce the objective of task-based image enhancement for the underwater domain. We propose a model inspired by current image enhancement techniques, and create a GAN-based architecture for image enhancement for the purpose of diver detection, which can be used on an AUV or ROV. We also perform an ablation test to investigate the use of different objective functions. While the model is trained on synthetic images, we show generalization to raw ocean images. The results of a diver detection model used in conjunction with various image enhancement models are compared with our model. We show that images enhanced for the human perspective do not always lead to the best results for a task assigned to a robotic platform. In the future, we plan to improve upon this idea through an exploration of other tasks in addition to detecting divers through bounding boxes, such as for image segmentation. We also intend to explore the introduction of other objective functions, such as incorporating information loss to predict saliency.