Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LDEMGAN2.0: Lunar DEM Super-Resolution

This repository implements LDEMGAN2.0, an improved generative adversarial network for pixel-scale lunar DEM generation from a single high-resolution image and a low-resolution DEM, following:

  • LDEMGAN1.0: Yang Liu et al., Remote Sensing 2022, 14, 5420.
  • LDEMGAN2.0: Tianhao Chen et al., Remote Sensing 2025, 17, 3097.

Data

Trained on the config (configs/ldemgan2_ldemgan.yaml), the LDEMGAN2.0 dataset of 256×256 tiles at 2 m, with a single-band image and the SLDEM2015 DEM already resampled to the tile grid. Each sample (dataset/LunarDEMDataset.py) is, following LDEMGAN1.0 §3.1 step 4 ("normalized to [0, 1]", applied to the image, the SLDEM channel and the DTM ground truth alike):

  • Input channels:
    • NAC orthophoto (2m per px, single-channel).
    • LR DEM (60m per px, single channel).
  • Ground truth:
    • HR DEM (2m per px, single channel).

Normalization: nodata pixels are set to 0, then the image, the LR DEM, and the HR DEM are each min-max scaled to [0, 1] per tile over their own range. To get meters back, train.py applies LDEMGAN1.0 Eq. 13, meters = pred * lr_std + lr_mean, using the LR DEM's mean and std in meters (computed before scaling and returned with each tile). This uses only the LR DEM, so no ground-truth information is needed at inference.

Augmentation: random horizontal flip, vertical flip, and 90° rotation (training split only).

Network Architecture

Generator

Implemented in model/LDEMGAN2.py as UNetGenerator, following LDEMGAN1.0 §3.2's encoder/decoder (LDEMGAN2.0 reuses the generator unchanged):

  • Input: tensor of the image channels + LR DEM (4 channels for HECATE, 2 for the LDEMGAN config), size H×W (H, W must each be a multiple of 2⁷ = 128; 256×256 tiles reach the paper's stated 2×2×1024 bottleneck).
  • Encoder: 7 "BCDL" blocks (BatchNorm → 1×1 conv → 4×4 stride-2 conv → LeakyReLU(0.2)), channels 64 → 128 → 256 → 512 → 1024 → 1024 → 1024.
  • Decoder: 7 "BUR" blocks (BatchNorm → 4×4 stride-2 transposed conv → activation) with skip connections from the matching encoder stage, channels 1024 → 1024 → 512 → 256 → 128 → 64 → 1. ReLU for BUR-1–6.
  • Output head (BUR-7): TanhL (Eq. 3), bounding the output to (0, 1) to match the min-max normalized target.

Discriminator (PatchGAN)

Implemented in model/LDEMGAN2.py as PatchGANDiscriminator, following LDEMGAN1.0 §3.2 (Fig. 2, Eq. 6):

  • Input: the generator input concatenated with the 1-channel DEM (generated or ground truth) → 5 channels for HECATE, 3 for the LDEMGAN config.
  • The tile is split into non-overlapping 64×64 patches, and each patch is classified separately.
  • Each patch goes through 4 "BCL" blocks (BatchNorm → 4×4 stride-2 conv → LeakyReLU(0.2)), channels 64 → 128 → 256 → 512, down to 4×4, then fully connected (1024) → LeakyReLU(0.2) → fully connected (1) → sigmoid.
  • The output is the mean real probability over a tile's patches (Eq. 6).

The paper doesn't give the patch size, the number of BCL blocks, the conv kernel or the fully connected width; those values are our choice.

Loss Functions

Implemented in LDEMGAN2Loss / SelfSimilarityLoss (model/LDEMGAN2.py) following LDEMGAN2.0 Eq. 8. LDEMGAN2.0 does not define its Huber, gradient, GAN and discriminator terms and refers to LDEMGAN1.0's generator loss for them, so those come from LDEMGAN1.0 (Eqs. 8, 9, 10, 12):

$$L_{G,\text{total}} = \alpha L_{\text{Huber}} + \beta L_{\text{grad}} + \gamma L_{\text{GAN}} + L_D + \delta L_{\text{SSG}}$$

  • Huber loss: between predicted and ground-truth DEMs, with δ set per batch to one fifth of the largest prediction/ground-truth difference (LDEMGAN1.0 Eq. 8).

  • Gradient loss: mean squared difference of the x/y gradients (LDEMGAN1.0 Eq. 9), with the gradient taken as the difference between neighbouring pixels. The paper doesn't name its gradient operator; this is our choice.

  • GAN loss: log(1 − D(G(·))) on the discriminator's real probability (Eq. 6) for the generated pair, exactly as LDEMGAN1.0 Eq. 10, computed as −BCELoss(D(G(·)), 0). It is the saturating form, so its gradient fades as the discriminator becomes confident the pair is generated.

  • Self-similarity loss (LDEMGAN2.0 §2.3):

    1. A mask of edge/texture pixels is made by thresholding the Laplacian of the ground truth (Eqs. 1–2, signed as Eq. 2 writes it), computed with OpenCV's 3×3 cv2.Laplacian (aperture size laplacian_ksize in SelfSimilarityLoss). The threshold (165) is applied to the ground truth min-max rescaled to 0–255, since the paper doesn't give the DTM's scale.
    2. For each pixel, the squared differences to its 3×3 neighbours are summed (averaged over channels, Eq. 3) and turned into a similarity exp(-d²/h) (Eq. 4), which is log-scaled to 0–255 (Eq. 5). Each masked pixel's graph is the 25 values in the 5×5 search area around it (§2.3.3). Both DEMs are min-max rescaled to [0, 1] by the ground truth's range first (a near-identity operation now that the target is itself already [0, 1]-normalized), the scale the paper's h = 0.004 is tuned for.
    3. The loss is the KL divergence between the ground-truth and predicted graphs, taken per masked pixel over its search area as in the loss LDEMGAN2.0 builds on (Chen et al. 2024), plus ε times their mean absolute difference (Eqs. 6–7).
  • L_D (LDEMGAN1.0 Eq. 12, used by LDEMGAN2.0 Eq. 8): 0.5[log D(generated pair) + log(1 − D(real pair))], added to the generator loss. It is also the loss the discriminator minimizes (LDEMGAN1.0 Eq. 7). As written it has no lower bound; BCELoss clamps each log at −100, which bounds it in practice.

Deviations from the Papers

Data and model

  1. Min-max method. The paper normalizes the image, SLDEM channel and DTM ground truth to [0, 1] (§3.1 step 4) without saying how; we use each tile's own per-channel min-max.
  2. Discriminator details. The layout follows Fig. 2, but the patch size (64), number of BCL blocks (4), conv kernel (4×4 stride 2) and fully connected width (1024) aren't given in the paper and are our choice.
  3. Augmentation. The paper says only that tiles are augmented by "rotation or flipping"; the random flips plus 90° rotations are our choice.

Losses

  1. Self-similarity loss details the paper leaves open, filled in as follows:
    • The mask thresholds the Laplacian response on the ground truth rescaled to 0–255, using OpenCV's 3×3 Laplacian.
    • Self-similarities are computed on DEMs min-max rescaled to [0, 1] by the ground truth's range.
    • Both SSGs use the ground truth's maximum similarity as the Eq. 5 normalizer, so they share one scale.
    • The KL term treats each masked pixel's 25 search-area values as a distribution (normalized to sum to 1), following Chen et al. 2024. Both terms are averaged over all masked pixels in the batch.
    • A batch with no masked pixels contributes zero SSL.
    • ε = 1 is the value Chen et al. 2024 use for the same weight; LDEMGAN2.0 doesn't give it.

Training and evaluation

  1. Optimizer: Adam(β₁=0.5, β₂=0.999), assumed. The papers state neither an optimizer nor its betas. This is the usual choice for pix2pix-style GANs. The discriminator's learning rate (0.1× the generator's) is also our choice; the papers give none.

Running Training and Evaluation

Training and test evaluation both run from one entrypoint: test() is called automatically at the end of train.py, using the checkpoint with the best validation RMSE.

cd LDEMGAN2.0
conda run -n lunarhd python train.py --config configs/ldemgan2_ldemgan.yaml

Checkpoints are written to weights/<run name>/ relative to the working directory.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages