Enhanced Deep Residual Networks for Single Image Super-Resolution
Paper
β’
1707.02921
β’
Published
This model is a custom-trained version of the Enhanced Deep Super-Resolution (EDSR) model from the super-image library.
It is adapted for downscaling of 2-channel ERA5 data (e.g., wind u and v components), by a factor of 4Γ (trained using COSMO-REA6 as high-resolution data).
n_feats): 64 | File | Description |
|---|---|
config.json |
Configuration for the modified EDSR model |
pytorch_model_4x.pt |
Pretrained weights for 4Γ upscaling |
from super_image import EdsrModel, EdsrConfig
from huggingface_hub import hf_hub_download
import torch
import xarray as xr
import numpy as np
# load config
config, _ = EdsrConfig.from_pretrained("lschmidt/edsr-dsc")
# load model & remove normalization
model = EdsrModel(config)
del model.sub_mean
del model.add_mean
# load pre-trained weights
state_dict_path = hf_hub_download(repo_id="lschmidt/edsr-dsc", filename="pytorch_model_4x.pt")
state_dict = torch.load(state_dict_path, map_location="cpu")
model.load_state_dict(state_dict, strict=False)
# create random input: must be a 4D tensor (B, C=2, H, W)
inputs = torch.randn(1, 2, 40, 40) # replace with coarse wind velocity fields
# or use sample data
data_path = hf_hub_download(
repo_id="lschmidt/edsr-dsc",
filename="test_wind_velocities.nc",
subfolder="test_data"
)
ds = xr.open_dataset(data_path)
u = ds["u100"].values[0]
v = ds["v100"].values[0]
inputs = torch.from_numpy(np.stack([u, v], axis=0)).unsqueeze(0).float()
# prediction
outputs = model(inputs)