Hyperspectral imagery captures information about objects across a wide range of the electromagnetic spectrum. These images possess much more amount of useful information compared to standard RGB images and are especially useful in fields like remote sensing and medical diagnosis. The main problem with hyperspectral imagery is the expensive hardware required to capture these images, leading to a lack of availability of datasets in the public domain. RGB images, on the other hand, are easy to obtain. A system for accurate reconstruction of spectral bands of an RGB image would be beneficial for furthering research into the applications of hyperspectral images.
It may seem problematic to try to convert RGB images to hyperspectral images since the task essentially requires the generation of information that was never captured by an RGB camera, but, hyperspectral image pixel values have a strong correlation  to their RGB counterparts. It is, therefore, possible, to learn a mapping from RGB to hyperspectral images, given enough data. In fact, from visual inspection of the quality of results obtained even with simple CNN based approaches, we believe this is an easier task than an analogous task of converting gray scale images to RGB.
Our approach consists of using a CNN to convert RGB to hyperspectral images. We use a U-Net  based model with several key improvements taken from recent advancements in the fields of image generation, super-resolution and style transfer. We use an XResnet model, as proposed by He et al.  (referred to as Resnet-D in ) with Mish activation function (replacing ReLU ) as the encoder. In the decoder, we use sub-pixel convolutions  for upsampling. Finally, we incorporate blur layers(approach B in ) and a self-attention layer from  in our decoder. We adapted the general decoder architecture from Howard and Gugger’s work in the Fastai  library and Antic’s work in DeOldify . We study the effect of adding each component on the accuracy and running time. We also study the effect of changing the depth of the encoder. Our proposed family of architectures are capable of accurately reconstructing spectral bands from RGB images with very low inference times, on standard single GPU systems. This paper is describes a soltuion to the challenge posed in 
2 Related Work
The problem of spectral reconstruction of RGB images is an area of computer vision that has not been studied too extensively. Current state-of-the-art approaches are mostly CNN based. Older methods made use of sparse coding
, but recent advances in CNNs and availability of relatively larger datasets for hyperspectral reconstruction have led to increasing research into neural network based approaches. Earlier CNN based approaches used relatively shallow networks or even hybrid approaches combining sparse-coding and neural networks . The NTIRE 2018 spectral reconstruction challenge introduced the BGU hyperspectral dataset, which was much larger than existing datasets. The challenge saw various deep CNN based  and a few GAN based approaches. The new state of the art was achieved by Shi et al. . Baran and Timofte also did important work for lightweight real time spectral reconstruction in 
Our model is a modified version of the U-Net 
architecture. The U-Net is a popular deep learning architecture originally introduced to perform image segmentation. It has since then been used for a wide range of image-to-image tasks. It improves over standard encoder-decoder architectures by incorporating skip connections between the encoder and decoder, allowing much deeper models to be trained. Over time the original U-Net architecture has seen several key improvements. These include incorporating skip connections in the encoder, using sub-pixel convolutions in the decoder  and using dilated convolution .
in our network. This kind of loss function has proved useful in style-transfer and super-resolution  applications. It makes networks focus on perceptual details
in an image. These details are not easily captured by standard evaluation metrics like RMSE, PSNR or MRAE but are readily visible to humans. We make use of sub-pixel convolutions for upsampling, in our decoder. It is an alternative to deconvolution operation for learned upsampling and is extensively used in super-resolution applications. It performs the convolution in a low resolution space and upsamples the result, instead of upsampling first. This approach is much more efficient while being mathematically equivalent to deconvolution.
Our proposed architecture uses models from the XResnet family with Mish activation function as the encoder(this architecture will be referred to as mxresnet ) in the U-Net. Skip connections between the encoder and decoder are made at four positions where the encoder subsamples the image. The final encoder output is passed through two successive convolutions and fed into the decoder.
The decoder consists of 4 upsampling blocks, each of which receives two input tensors and produces one output. The input from the previous decoder block isx upsampled with a sub-pixel convolution with an ICNR initialization scheme. A sub-pixel convolution operation combined with ICNR initialization has been attributed to performing high quality, checkerboard artifact free super-resolution. The upsampling is followed by a blur  layer which consists of average pooling with a x
filter and stride of. This operation also aims to reduce artifacts in generated images. The upsampled feature map is concatenated with the second input, which comes from an encoder skip connection. The final output is formed by passing the concatenated feature map through two successive convolutions. The second decoder block is followed by a self-attention layer as proposed by Zhang et al. in . This layer helps the network to focus on the relevant parts of the image.
The decoder output is x upsampled to make the resolution the same as the input image. This feature map is concatenated with the original RGB image and passed through a standard Resnet block. We find that this concatenation operation provides significant improvements to our results. Finally, a x convolution is used to bring down the channels to the desired number.
We use a slightly modified version of the loss function described by Johnson et al. in 
. Perceptual loss refer to a loss function that calculates the amount of dissimilarity between a generated image and the ground truth, based on perceptually relevant characteristics. Our loss function is the weighted sum of feature reconstruction loss, style reconstruction loss and pixel loss.
Feature Reconstruction Loss. We use a VGG16 
network pretrained on Imagenet
(also called the loss network) to compute the features of the model outputs. We modify the first layer of the network to contain filters withchannels by copying over weights of the existing channels. Let be the activations of the th layer of the network when processing the image ; if is a convolutional layer then will be a feature map of shape . The feature reconstruction loss is the mean L1 distance between feature representations:
We use the activations before the second, third and fourth max pool layers in the loss network to calculate our feature reconstruction loss.
Style Reconstruction Loss This loss was proposed by Gatys et al. in  and adapted in . It constitutes calculating the Gram matrices of the loss network activations for the output and target images. The modified style reconstruction loss is then the mean absolute difference between the Gram matrices of the output and target images. The Gram matrix can be computed efficiently by reshaping into a matrix of shape ; then .
Pixel Loss The pixel loss is the mean Euclidean distance between the output image and the target . If both have shape , then the pixel loss is defined as
We normalize the images and use the following data augmentation techniques: random flipping, random rotations, brightness and contrast jitter. All networks are trained for 200 epochs using the AdamW optimizer(Adam with weight decay) with a weight decay of 1e-3. The training follows the One Cycle schedule. Under this schedule, the learning rate is started at 1e-5 and increased to 1e-3 over 60 epochs following a half cosine curve. After the learning rate peaks, it is reduced to 1e-9 over another 140 epochs following a similar half cosine curve. The momentum of the optimizer goes through a similar but opposite cycle. It starts at 0.95 and is reduced to 0.85 over 60 epochs and again increased to 0.95 over 140 epochs. We also use mixed-precision training to lower training time and memory requirements. A single V100 GPU was used for all training runs. The entire training schedule takes hours (s per epoch) for an mxresnet34 encoder based U-Net.
|Resnet34 (no pretraining)||0.052844||0.090132|
Here we present some ablation studies comparing different variations of our proposed method. More specifically, we compare results for these encoder backbones: resnet34 , mxresnet34 , mxresnet18 and mxresnet50. We also vary the presence of the self-attention layer along with the blur layer in the decoder networks. All networks have sub-pixel convolution layers in their decoders. The loss function for every experiment is the aforementioned perceptual loss combination unless otherwise specified.
The dataset was provided in the New Trends in Image Restoration and Enhancement (NTIRE) Challenge on Spectral Reconstruction from RGB Images at CVPR 2020 . The datasets for both the competition tracks (Clean and Real World) consist of training images and validation images. The dataset for the clean track of the competition consists of -bit uncompressed RGB images and their channel hyperspectral counterparts as ground truth. For the real world track, we have the JPEG compressed -bit RGB images as the model input. In our experiments, the training and validation data for the models were as provided in the original datasets.
As table 1 clearly indicates, a U-Net with an mxresnet50 encoder along with self-attention and blur in the decoder with perceptual losses produces the best results. We note that using a pre-trained model causes a slight reduction in performance as compared to other approaches that did not use any Imagenet  pretraining. Further, adding self attention and blur to the decoder along with modifications to the original resnet  architecture (xresnet  with a mish  activation function) gave a small performance boost.
Most surprisingly, though, an mxresnet18 based encoder was able to outperform all our other approaches except the mxresnet50 encoder while still being significantly shallow and computationally efficient as opposed to other approaches.
5.3 Inference Time
Our model with the mxresnet50 encoder takes seconds per image during inference time. While all other approaches take to seconds per image during inference. Notably, the network with an mxresnet18 backbone takes seconds during inference making it suitable for real time video. The mxresnet18 encoder model has about times fewer parameters as compared to the mxresnet50 encoder model (M vs M) while still reducing the performance by only and on the clean and real world tracks with respect to the MRAE metric.
In this paper, we use an encoder-decoder network based on the U-Net architecture with some of the recent advances/improvements in deep learning. We use the resnet-d architecture with the mish  activation function as the encoder. In the decoder, we use sub-pixel convolution  layers for upsampling to help increase efficiency, blur  layers to reduce checkerboard artifacts and a self-attention layer  to focus the network on finer details. All these improvements allow our approach to produce good results even with a relatively shallow encoder network such as the mxresnet18. We note that much of these improvements were originally conceived and implemented in the FastAI  library by Howard, Gugger and Antic’s contributions. Our contribution has been to combine the mxresnet base architecture with these improvements that were made by the people mentioned above. We also introduce a model based on the mxresnet18 encoder that is suitable for real-time video applications with an inference time of seconds without any significant drop in performance.
-  (2017) Checkerboard artifact free sub-pixel convolution: a note on sub-pixel convolution, resize convolution and convolution resize. ArXiv abs/1707.02937. Cited by: §3.1.
-  (2020-03) DeOldify. External Links: Cited by: §1, §2.
NTIRE 2018 challenge on spectral reconstruction from rgb images.
2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops (CVPRW), pp. 1042–104209. Cited by: §2.
-  (2020-06) NTIRE 2020 challenge on spectral reconstruction from an rgb image. In The IEEE Conference on Computer Vision and Pattern Recognition (CVPR) Workshops, Cited by: §1, §5.1.
-  (2018) An efficient cnn for spectral reconstruction from rgb images. ArXiv abs/1804.04647. Cited by: §2.
-  (2011) Statistics of real-world hyperspectral images. In CVPR 2011, pp. 193–200. Cited by: §1.
-  (2017) LinkNet: exploiting encoder representations for efficient semantic segmentation. 2017 IEEE Visual Communications and Image Processing (VCIP), pp. 1–4. Cited by: §2.
-  (2015) A neural algorithm of artistic style. ArXiv abs/1508.06576. Cited by: §3.2.
-  (2016) Deep residual learning for image recognition. 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 770–778. Cited by: §5.2, §5.
Bag of tricks for image classification with convolutional neural networks. 2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 558–567. Cited by: MXR-U-Nets for Real Time Hyperspectral Reconstruction, §1, §5.2, §6.
-  (2020) Fastai: a layered api for deep learning. ArXiv abs/2002.04688. Cited by: MXR-U-Nets for Real Time Hyperspectral Reconstruction, §1, §6.
-  (2016) Perceptual losses for real-time style transfer and super-resolution. In ECCV, Cited by: §2, §3.2, §3.2.
-  (2016) Photo-realistic single image super-resolution using a generative adversarial network. 2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 105–114. Cited by: §2.
-  (2019) Decoupled weight decay regularization. In ICLR, Cited by: §4.
-  (2017) Mixed precision training. ArXiv abs/1710.03740. Cited by: §4.
-  (2019) Mish: a self regularized non-monotonic neural activation function. ArXiv abs/1908.08681. Cited by: MXR-U-Nets for Real Time Hyperspectral Reconstruction, §1, §5.2, §6.
-  (2010) Rectified linear units improve restricted boltzmann machines. In ICML, Cited by: §1.
-  (2014) Training-based spectral reconstruction from a single rgb image. In European Conference on Computer Vision, pp. 186–201. Cited by: §2.
-  (2008) Spatio-spectral reconstruction of the multispectral datacube using sparse recovery. 2008 15th IEEE International Conference on Image Processing, pp. 473–476. Cited by: §2.
-  (2015) Single image spectral reconstruction for multimedia applications. In MM ’15, Cited by: §2.
-  (2015) U-net: convolutional networks for biomedical image segmentation. ArXiv abs/1505.04597. Cited by: §1, §2.
-  (2015) ImageNet Large Scale Visual Recognition Challenge. International Journal of Computer Vision (IJCV) 115 (3), pp. 211–252. External Links: Cited by: §3.2, §5.2.
-  (2016) Real-time single image and video super-resolution using an efficient sub-pixel convolutional neural network. 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 1874–1883. Cited by: §1, §2, §2, §6.
-  (2018) HSCNN+: advanced cnn-based hyperspectral recovery from rgb images. 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops (CVPRW), pp. 1052–10528. Cited by: §2.
-  (2014) Very deep convolutional networks for large-scale image recognition. CoRR abs/1409.1556. Cited by: §3.2.
-  (2018) A disciplined approach to neural network hyper-parameters: part 1 - learning rate, batch size, momentum, and weight decay. ArXiv abs/1803.09820. Cited by: §4.
-  (2018) Super-resolution using convolutional neural networks without any checkerboard artifacts. 2018 25th IEEE International Conference on Image Processing (ICIP), pp. 66–70. Cited by: §1, §3.1, §6.
-  (2020-03) Lessw2020/mish: mxresnet release. Zenodo. External Links: Cited by: §3.1, §5.
-  (2019) Self-attention generative adversarial networks. ArXiv abs/1805.08318. Cited by: §1, §3.1, §6.
-  (2018) D-linknet: linknet with pretrained encoder and dilated convolution for high resolution satellite imagery road extraction. 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops (CVPRW), pp. 192–1924. Cited by: §2.