-
download the checkpoint Du to the GitHub's file size limit is 100.00 MB, our model checkpoint can't be push to github. The checkpoint team23_NAF.pth can be downloaded from google link below: https://drive.google.com/file/d/17euA75OwQj22_moEbGLadee2rCNzM9qO/view?usp=sharing
In test_demo.py, line
torch.hub.download_url_to_file(url, '.model_zoo/team23_NAF.pth') # download checkpoint from url first and put it in model_zoo
-
load the checkpoint
# you can also use function load_network_path(net, path, device): new_state_dict = {} model_state = model.state_dict() for k, v in state_dict.items(): if k in model_state: new_state_dict[k] = v model.load_state_dict(new_state_dict, strict=True)
git clone https://github.com/ofsoundof/NTIRE2023_Dn50.git
- Select the model you would like to test from
run.sh
CUDA_VISIBLE_DEVICES=0 python test_demo.py --data_dir [path to your data dir] --save_dir [path to your save dir] --model_id 0
- Be sure the change the directories
--data_dir
and--save_dir
.
- Be sure the change the directories
- Register your team in the Google Spreadsheet and get your team ID.
- Put your the code of your model in
./models/[Your_Team_ID]_[Your_Model_Name].py
- Please add only one file in the folder
./models
. Please do not add other submodules. - Please zero pad [Your_Team_ID] into two digits: e.g. 00, 01, 02
- Please add only one file in the folder
- Put the pretrained model in
./model_zoo/[Your_Team_ID]_[Your_Model_Name].[pth or pt or ckpt]
- Please zero pad [Your_Team_ID] into two digits: e.g. 00, 01, 02
- Add your model to the model loader
./test_demo/select_model
as follows:elif model_id == [Your_Team_ID]: # define your model and load the checkpoint
- Note: Please set the correct data_range, either 255.0 or 1.0
- Send us the command to download your code, e.g,
git clone [Your repository link]
- We will do the following steps to add your code and model checkpoint to the repository. This repository shows how to add noise to synthesize the noisy image. It also shows how you can save an image.
import numpy as np
import imageio
def add_noise(image, sigma=50):
"""
image: input image, numpy array, dtype=uint8, range=[0, 255]
sigma: default 50
"""
image = np.array(image / 255, dtype=float)
noise = np.random.normal(0, sigma / 255, image.shape)
gauss_noise = image + noise
return gauss_noise * 255
def save_image(image, path):
"""
image: saved image, numpy array, dtype=float
path: saving path
"""
# The type of the image is float, and range of the image might not be in [0, 255]
# Thus, before saving the image, the image needs to be clipped.
image = np.round(np.clip(image, 0, 255)).astype(np.uint8)
imageio.imwrite(path, image)
def crop_image(image, s=8):
h, w, c = image.shape
image = image[:h - h % s, :w - w % s, :]
return image
image_name = "example.png"
img = imageio.imread(image_name)
# The provided noisy validation images in the following link are cropped such that the width and height are multiples of 8.
# https://drive.google.com/file/d/1iYurwSVBUxoN6fQwUGP-UbZkTZkippGx/view?usp=share_link
# You can achieve that using the function crop_image.
img = crop_image(img)
# This image is used as the noisy image for training.
img_noise = add_noise(img, sigma=50)
# This function ensures that the image is properly clipped and rounded before saving.
save_image(img_noise, "example_saved.png")