{'fraction_non_alphanumeric': 0.04554527309018327, 'fraction_numerical': 0.017646525131555072, 'mean_word_length': 4.445899209486166, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Degradation-Aware Unfolding Half-Shuffle Transformer for Spectral Compressive Imaging

In coded aperture snapshot spectral compressive imaging (CASSI) systems, hyperspectral image (HSI) reconstruction methods are employed to recover the spatial-spectral signal from a compressed measurement. Among these algorithms, deep unfolding methods demonstrate promising performance but suffer from two issues. Firstly, they do not estimate the degradation patterns and ill-posedness degree from the highly related CASSI to guide the iterative learning. Secondly, they are mainly CNN-based, showing limitations in capturing long-range dependencies. In this paper, we propose a principled Degradation-Aware Unfolding Framework (DAUF) that estimates parameters from the compressed image and physical mask, and then uses these parameters to control each iteration. Moreover, we customize a novel Half-Shuffle Transformer (HST) that simultaneously captures local contents and non-local dependencies. By plugging HST into DAUF, we establish the first Transformer-based deep unfolding method, Degradation-Aware Unfolding Half-Shuffle Transformer (DAUHST), for HSI reconstruction. Experiments show that DAUHST significantly surpasses state-of-the-art methods while requiring cheaper computational and memory costs. Code and models will be released at https://github.com/caiyuanhao1998/MST

To obtain HSIs, traditional imaging systems use spectrometers to scan the scenes along the spectral or spatial dimensions, usually requiring a long time. These imaging systems fail to capture dynamic objects. Recently, snapshot compressive imaging (SCI) systems [17,18,19,20,21,22,23] have been developed to capture HSIs at video rate. Among these SCI systems, coded aperture snapshot spectral imaging (CASSI) [18,24,25] stands out for its impressive performance. CASSI uses a coded aperture and a disperser to modulate the HSI signal at different wavelengths, and then mixes all modulated signal to generate a 2D compressed measurement. Subsequently, HSI restoration methods are employed to solve the CASSI inverse problem, i.e., restore the HSIs from the measurement. These methods are divided into four categories.
(iii) End-to-end (E2E) algorithms employ a powerful model, usually a convolutional neural network (CNN) [12,24,40,41], to learn the E2E mapping function from a measurement to the desired HSIs. E2E methods enjoy the power of deep learning. However, they learn a brute-force mapping from the compressed measurement to the underlying spectral images, thereby ignoring the working principles of CASSI systems. They come without theoretically proven properties, interpretability [42], and flexibility because the imaging models widely differ from each other for various hardware systems.
(iv) Deep unfolding methods [43,44,45,46,47,48,49] adopt a multi-stage network to map the measurement into the HSI cube. Each stage usually includes two phases, i.e., linear projection followed by passing the signal through a single-stage network that learns the underlying denoiser prior. In deep unfolding methods, the network architecture is intuitively interpretable by explicitly characterizing the image priors and the system imaging model. Besides, these methods also enjoy the power of deep learning and thus have great potential. Yet, this potential has not been fully explored.
Existing deep unfolding algorithms suffer from two issues. (a) The iterative learning is highly related to the CASSI system. However, current unfolding methods do not estimate CASSI degradation patterns and ill-posedness degree to adjust the linear projection and denoising network in each iteration.
(b) Existing deep unfolding methods are mainly CNN-based, therefore showing limitations in capturing non-local self-similarity and long-range dependencies, both critical for HSI reconstruction.
To address the above problems, in this paper, we firstly formulate a principled Degradation-Aware Unfolding Framework (DAUF) based on maximum a posteriori (MAP) theory for HSI reconstruction. Different from previous deep unfolding methods, our DAUF implicitly estimates informative parameters from the degraded compressed measurement and the physical mask used in the modulation. Then DAUF feeds the parameters, which capture key cues of CASSI degradation patterns and ill-posedness degree, into each iteration to adaptively scale the linear projection and provide the noise level information for the denoising network. Secondly, we design a novel Half-Shuffle Transformer (HST) as the denoiser prior in each iteration. Our HST can jointly extract local contextual information and model non-local dependencies, while requiring much cheaper computational costs than global Transformer. We achieve this by customizing a Half-Shuffle Multi-head Self-Attention (HS-MSA) mechanism that composes the basic unit of HST. More specifically, our HS-MSA has two branches, i.e., local branch and non-local branch. The local branch calculates the self-attention within the local window while the non-local branch shuffles the tokens and captures cross-window interactions. We plug HST into DAUF to establish an iterative architecture, Degradation-Aware Unfolding Half-Shuffle Transformer (DAUHST). With the proposed techniques, DAUHST models dramatically outperform state-of-the-art (SOTA) deep unfolding methods with the same number of stages by over 4 dB, as shown in Fig. 1.
In a nutshell, our contributions can be summarized as follows: (i) We formulate a principled MAP-based unfolding framework DAUF for HSI reconstruction.
(ii) We propose a novel Transformer HST and plug it into DAUF to establish DAUHST. To the best of our knowledge, DAUHST is the first Transformer-based deep unfolding method for HSI restoration.    In CASSI, we denote the vectorized measurement as y ∈ R n , where n = H(W + d(N λ − 1)). H, W , d, and N λ denote the HSI's height, width, shifting step in dispersion, and total number of wavelengths. Given the vectorized shifted HSI signal x ∈ R nN λ and the sensing matrix Φ ∈ R n×nN λ that is determined by the physical mask, the degradation model of CASSI can be formulated as where n ∈ R n represents the vectorized imaging noise on the measurement. As analyzed in [86,87,88], Φ is a fat, sparse, and highly structured matrix that is hard to handle. Please refer to the supplementary material for details about the mathematical model of CASSI. Then the task of HSI reconstruction is given y (captured by the camera) and Φ (calibrated based on pre-design), solving x.

Degradation-Aware Unfolding Framework
Previous unfolding frameworks [43,44,45,46] do not estimate the CASSI degradation patterns to adjust the iterative learning. To alleviate this limitation, we formulate a principled Degradation-Aware Unfolding Framework (DAUF) as depicted in Fig. 2. DAUF starts from the MAP theory. In particular, the original HSI signal could be estimated by minimizing the following energy function aŝ where 1 2 ||y − Φx|| 2 is the data fidelity term, R(x) is the image prior term, and τ is a hyperparameter balancing the importance. By introducing an auxiliary variable z, Eq. (2) can be reformulated aŝ This is a constrained optimization problem. To obtain an unfolding inference, we adopt half-quadratic splitting (HQS) algorithm for its simplicity and fast convergence. Then Eq. (3) is solved by minimizing where µ is a penalty parameter that forces x and z to approach the same fixed point. Subsequently, Eq. (4) can be solved by decoupling x and z into the following two iterative sub-problems as where k = 0, 1, ... , K − 1 indexes the iteration. Note that the data fidelity term is associated with a quadratic regularized least-squares problem, i.e., x k+1 in Eq. (5). It has a closed-form solution as where I is an identity matrix. Since Φ is a fat matrix, (Φ T Φ + µI) will be large and thus we simplify the computation of the inverse problem (Φ T Φ + µI) −1 by the matrix inversion formula as By plugging Eq. (7) into Eq. (6), we can reformulate Eq. (6) as In CASSI systems, ΦΦ T is a diagonal matrix which can be defined as ΦΦ T def = diag{ψ 1 , . . . , ψ n }. By plugging ΦΦ T into (I + Φµ −1 Φ T ) −1 and (I + Φµ −1 Φ T ) −1 ΦΦ T , we obtain: Let y def = [y 1 , . . . , y n ] T and [Φz k ] i denotes the i-th element of Φz k . We plug Eq. (9) into Eq. (8) as Note that can be directly updated by y − Φz k , and {ψ i } n i=1 is pre-calculated and stored in ΦΦ T . Thus, by element-wise computation in Eq. (10), x k+1 can be updated very efficiently. According to Eq. (5), the penalty parameter µ should be large enough so that x and z can approach approximately the same fixed point. This indicates that µ controls the convergence and output of each iteration. Thus, instead of manually tweaking µ, we set µ as a series of iteration-specific parameters to be automatically estimated from the CASSI system. We denote µ in the k-th iteration as µ k .
Returning to Eq. (5), we also set τ as iteration-specific parameters and z k+1 can be reformulated as From the perspective of Bayesian probability, Eq. (11) is equivalent to denoising image x k+1 with a Gaussian noise at level τ k+1 /µ k+1 [33]. To conveniently solve Eq. (11), we set Then we can formulate our DAUF as an iterative scheme: where E denotes the parameter estimator that takes the compressed measurement y and the sensing matrix Φ of the CASSI system as inputs, P equivalent to Eq. (10) denotes the linear projection, and D represents the Gaussian denoiser solving Eq. (11). z 0 is initialized by passing the shifted y concatenated with Φ through a conv1 × 1 (convolution with 1×1 kernel). Fig. 2 shows the architecture of E. It consists of a conv1 × 1, a strided conv3 × 3, a global average pooling, and three fully connected layers. Through E, DAUF captures critical cues from CASSI by learning the degradation patterns and ill-posedness degree caused by the mask-modulation and dispersionintegration. Parameters α and β estimated by E direct the iterative learning by adaptively scaling the linear projection in Eq. (10) and providing noise level information for the denoiser prior in Eq. (11).

Half-Shuffle Transformer
When designing the denoiser prior, previous deep unfolding methods [43,44,45,46] mainly adopt CNNs, showing limitations in capturing long-range dependencies. Directly applying local and global Transformers will encounter two problems, i.e., limited receptive fields and nontrivial computational costs. To address these challenges, we propose Half-Shuffle Transformer (HST) to play the role of D.
Network Architecture. As shown in Fig. 3 (a), HST adopts a three-level U-shaped structure built by the basic unit Half-Shuffle Attention Block (HSAB). Firstly, HST uses a conv3 × 3 to map reshaped Secondly, X 0 passes through the encoder, bottleneck, and decoder to be embedded into deep feature X d ∈ R H×Ŵ ×C . Each level of the encoder or decoder contains an HSAB and a resizing module.

Encoder Decoder
Local Branch In Fig. 3 (b), HSAB consists of two layer normalization (LN), an HS-MSA, and a Feed-Forward Network (FFN) that is detailed in Fig. 3 (c). The downsampling and upsampling modules are strided conv4 × 4 and deconv2 × 2. Finally, a conv3 × 3 operates on X d to generate a residual image R ∈ R H×Ŵ ×N λ . The output denoised image z k is obtained by the sum of x k and reshaped R.

Non-Local Branch
Half-Shuffle Multi-head Self-Attention. The most important element of HSAB is the proposed Half-Shuffle Multi-head Self-Attention (HS-MSA) module. Fig. 3 (d) depicts the HS-MSA used in the first level. The input tokens of HS-MSA are denoted as X in ∈ R H×Ŵ ×C . Subsequently, X in is linearly projected into query Q ∈ R H×Ŵ ×C , key K ∈ R H×Ŵ ×C , and value V ∈ R H×Ŵ ×C as where W Q , W K , W V ∈ R C×C are learnable parameters and biases are omitted for simplification. Our HS-MSA combines the advantages of global MSA [53] and local window-based MSA [51], i.e., HS-MSA can jointly capture local contextual information through the local branch and model long-range dependencies through the non-local branch, all while being computationally cheaper than global MSA. Specifically, Q, K, V are split into two equal parts along the channel dimension as where Q l , K l , V l ∈ R H×Ŵ × C 2 are fed into the local branch to capture local contents, while Q nl , K nl , V nl ∈ R H×Ŵ × C 2 pass through the non-local branch to model non-local dependencies. Local Branch. The local branch computes MSA within position-specific windows. As shown in the upper path of Fig. 3 (d), Q l , K l , V l are partitioned into non-overlapping windows of size M × M .
Then they are reshaped into R HŴ M 2 ×M 2 × C 2 . Subsequently, Q l , K l , V l are split along the channel wise into h heads: Fig. 3 (d) depicts the situation with h = 1 and some details are omitted for simplification. The local self-attention A i l is calculated inside each head as where P i l ∈ R M 2 ×M 2 are learnable parameters embedding the position information.
Non-local Branch. The non-local branch computes cross-window interactions through shuffle operations inspired by ShuffleNet [89]. In particular, Q nl , K nl , V nl ∈ R H×Ŵ × C 2 are firstly partitioned into non-overlapping windows with size M × M . Then their shapes are transposed from where P i nl ∈ R where W i l , W i nl ∈ R d h ×C refer to learnable parameters. We reshape the result of Eq. (17) to obtain the output X out ∈ R H×Ŵ ×C . Instead of globally sampling all tokens, HS-MSA builds inter-window correlations by shuffle operations. The self-attention is calculated in the local window but with tokens from non-local regions. Therefore, HS-MSA is much computationally cheaper than global MSA.

Experiment Setup
Similar to [24,40,45,47,81], 28 wavelengths are selected from 450nm to 650nm and derived by spectral interpolation manipulation for the HSI data. Simulation and real experiments are conducted.
Simulation Dataset. We adopt two datasets, i.e., CAVE [92] and KAIST [93] for simulation experiments. The CAVE dataset consists of 32 HSIs with spatial size 512×512. The KAIST dataset contains 30 HSIs of spatial size 2704×3376. Following the settings of [24,40,45,47,81], the CAVE dataset is adopted as the training set while 10 scenes from the KAIST dataset are selected for testing.
Real Dataset. Five real HSIs collected by the CASSI system developed in [24] are used for testing. Implementation Details. We implement DAUHST by Pytorch. All DAUHST models are trained with Adam [94] optimizer (β 1 = 0.9 and β 2 = 0.999) using Cosine Annealing scheme [95] for 300 epochs on an RTX 3090 GPU. The initial learning rate is 4×10 −4 . Patches with spatial sizes 256×256 and 660×660 are randomly cropped from the 3D HSI cubes with 28 channels as training samples for the simulation and real experiments. The shifting step d in the dispersion is set to 2. The batch size is 5. We set the basic channel C = N λ = 28 to store HSI information. The weights of D in different stages are unshared. Data augmentation includes random rotation and flipping. The training objective is to minimize the Root Mean Square Error (RMSE) between reconstructed and ground-truth HSIs.
(ii) Our DAUHST models dramatically surpass SOTA methods while requiring cheaper computational and memory costs. For instance, when compared with the only one Transformer-based E2E method MST, our DAUHST-2stg outperforms MST-L by 1. 16    detailed contents, cleaner textures, and fewer artifacts while preserving the spatial smoothness of homogeneous regions. In contrast, previous methods either yield over-smooth results compromising fine-grained structures, or introduce undesired chromatic artifacts and blotchy textures that are absent in the ground truth (GT). The top-middle part illustrates the density-wavelength spectral curves corresponding to the green boxes identified as a and b in the RGB image (top-left). The spectral curves of DAUHST-9stg achieve the highest correlation and coincidence with the reference curves, showing the advantage of our proposed DAUHST in spectral-dimension consistency reconstruction.
Real HSI Reconstruction. We further evaluate the effectiveness of DAUHST in real HSI reconstruction. Following the same settings as [24,47,81] for a fair comparison, we re-train DAUHST-3stg with the real mask on the CAVE and KAIST datasets jointly. To simulate the real imaging situations, the training samples are also injected with 11-bit shot noise. Fig. 5 shows the visual comparisons between our DAUHST-3stg and nine SOTA methods. In the top three rows, only our DAUHST-3stg can reconstruct the flower patch corresponding to the yellow box at all wavelengths while other methods all fail to recover the entire patch. In the bottom row, DAUHST-3stg restores more HSI structural details and clearer contents with fewer artifacts. In contrast, other methods recover blurry images, generate incomplete responses, and are susceptible to the noise corruption. This evidence suggests that DAUHST is more robust to the noise distortion and more effective in real HSI reconstruction.

Ablation Study
Break-down Ablation. We adopt baseline-1 that is derived by removing HS-MSA and DAUF from DAUHST-3stg to conduct the break-down ablation. Our goal is to study the effect of each component towards higher performance. Baseline-1 is cascaded end to end by three single-stage networks. As shown in Tab. 2a, baseline-1 achieves 33.05 dB. When we respectively apply DAUF and HS-MSA, the model achieves 2.32 and 2.44 dB improvements. When we exploit DAUF and HS-MSA jointly, the model gains by 4.16 dB. These results demonstrate the effectiveness of our DAUF and HS-MSA.
Self-Attention Mechanism. To compare HS-MSA with other MSAs, we adopt baseline-2 that is obtained by removing HS-MSA from DAUHST-1stg to conduct the ablation in Tab. 2b. We remove different position embedding schemes to avoid their impacts and only compare MSAs. For fairness, we keep the Params of MSAs the same by fixing the number of channels and heads. Baseline-2 yields 32.79 dB. We apply global MSA (G-MSA) [53], Swin MSA (SW-MSA) [51], Spectral-wise MSA (S-MSA) [81], and HS-MSA. Note that we downsample the input feature maps of G-MSA to avoid memory bottlenecks. As shown in Tab. 2b, HS-MSA yields the most significant improvement of 1.26 dB, which is 0.42, 0.30, and 0.23 dB higher than G-MSA, SW-MSA, and S-MSA. This superiority is mainly derived from HS-MSA's ability to jointly capture local contents and non-local dependencies.
Unfolding Framework. We compare our DAUF with previous unfolding frameworks including DNU [43], ADMM-Net [46], and GAP-Net [45]. For a fair comparison, we replace each single-stage network of DNU, ADMM-Net, and GAP-Net by our HST. 3-stage architecture is adopted to conduct ablations. The results are shown in Tab. 2c. Our DAUF significantly outperforms DNU, ADMM, and GAP by 2.59, 1.69, and 1.63 dB while adding only 0.05M Params and 0.94G FLOPS. This is mainly because DAUF uses the parameters estimated from the compressed measurement and physical mask in the CASSI system to direct the iterative learning. These parameters capture critical information of CASSI degradation patterns and ill-posedness degree, providing key cues for HSI reconstruction.   To study the effect of the estimated parameters α and β, we perform a break-down ablation of DAUF.
We adopt DAUHST-3stg as baseline-3 but α is set as learnable parameters instead of being estimated by E in Eq. (12) and β is not fed into D. The results are shown in Tab. 2d. Baseline-3 yields 36.49 dB. When α is set to be estimated by E, baseline-3 is improved by 0.45 dB. When β is fed into D, baseline-3 gains by 0.34 dB. When α and β are exploited jointly in the iterative learning, baseline-3 achieves a significant improvement of 0.72 dB. These results verify that the estimated parameters α and β are beneficial for the linear projection and denoising network of deep unfolding methods.
To further analyze the roles of the estimated parameters, we visualize z k and x k of Eq. (12), and plot the curves of α and β as they change with the iteration in Fig. 6. We observe: (i) z 0 and x 1 yield either blurry or noisy images. There is a significant gap between them. Since α k = µ k in Eq. (5) penalizes the differences between z and x, α 1 is estimated to be a large value. From the linear projection of the second iteration (z 1 → x 2 ) on, the gap between z and x decreases substantially. Therefore, α k are estimated to be small values when k ≥ 2. This indicates that α can adaptively scale the linear projection P. (ii) The noise corruption is severe in the first iteration. Thus, β 1 = µ 1 /τ 1 = 1/( τ 1 /µ 1 ) 2 , which is inversely proportional to the noise level, is estimated to be a small value. With further iterations, the noise level decreases, and thus the estimated β k increases. These results demonstrate that β can provide the information about noise level for the denoising network D.

Conclusion
In this paper, we remedy two issues of previous deep unfolding methods, i.e., they do not estimate informative parameters from the CASSI system to direct the iterative learning and they are mainly CNN-based showing limitations in capturing long-range dependencies. To cope with these challenges, we firstly formulate a principled MAP-based unfolding framework DAUF that estimates parameters from the compressed measurement and physical mask. Then the parameters, which capture critical cues of CASSI degradation patterns and ill-posedness degree, are fed into each iteration to contextually scale the linear projection and provide noise level information for the denoising network. Secondly, we propose a novel Transformer HST that can jointly extract local contents and model non-local dependencies. By plugging HST into DAUF, we derive the first Transformer-based unfolding method DAUHST for HSI reconstruction. Comprehensive experiments show that our DAUHST outperforms SOTA methods by a large margin while requiring much cheaper memory and computational costs.