Transformers
EDSR
super-image
image-super-resolution
Eugene Siow commited on
Commit
b372606
·
1 Parent(s): 2ce8311

Add hf datasets training recipe.

Browse files
Files changed (1) hide show
  1. README.md +13 -18
README.md CHANGED
@@ -5,6 +5,10 @@ tags:
5
  - image-super-resolution
6
  datasets:
7
  - eugenesiow/Div2k
 
 
 
 
8
  metrics:
9
  - pnsr
10
  - ssim
@@ -42,8 +46,9 @@ preds = model(inputs)
42
  ImageLoader.save_image(preds, './scaled_2x.png') # save the output 2x scaled image to `./scaled_2x.png`
43
  ImageLoader.save_compare(inputs, preds, './scaled_2x_compare.png') # save an output comparing the super-image with a bicubic scaling
44
  ```
 
45
  ## Training data
46
- The EDSR models for 2x, 3x and 4x image super resolution were pretrained on [DIV2K](https://data.vision.ee.ethz.ch/cvl/DIV2K/), a dataset of 800 high-quality (2K resolution) images for training, augmented to 4000 images and uses a dev set of 100 validation images (images numbered 801 to 900).
47
  ## Training procedure
48
  ### Preprocessing
49
  We follow the pre-processing and training method of [Wang et al.](https://arxiv.org/abs/2104.07566).
@@ -51,24 +56,14 @@ Low Resolution (LR) images are created by using bicubic interpolation as the res
51
  During training, RGB patches with size of 64×64 from the LR input are used together with their corresponding HR patches.
52
  Data augmentation is applied to the training set in the pre-processing stage where five images are created from the four corners and center of the original image.
53
 
54
- The following code provides some helper functions to preprocess the data.
55
  ```python
56
- from super_image.data import EvalDataset, TrainAugmentDataset, DatasetBuilder
57
 
58
- DatasetBuilder.prepare(
59
- base_path='./DIV2K/DIV2K_train_HR',
60
- output_path='./div2k_4x_train.h5',
61
- scale=4,
62
- do_augmentation=True
63
- )
64
- DatasetBuilder.prepare(
65
- base_path='./DIV2K/DIV2K_val_HR',
66
- output_path='./div2k_4x_val.h5',
67
- scale=4,
68
- do_augmentation=False
69
- )
70
- train_dataset = TrainAugmentDataset('./div2k_4x_train.h5', scale=4)
71
- val_dataset = EvalDataset('./div2k_4x_val.h5')
72
  ```
73
  ### Pretraining
74
  The model was trained on GPU. The training code is provided below:
@@ -120,7 +115,7 @@ The results columns below are represented below as `PSNR/SSIM`. They are compare
120
  |Urban100 |3x | |**29.23/0.8723** |
121
  |Urban100 |4x |23.14/0.6573 |**26.02/0.7832** |
122
 
123
- ![Comparing Bicubic upscaling against EDSR x2 upscaling on Set5 Image 2](images/Set5_2_compare.png "Comparing Bicubic upscaling against EDSR x2 upscaling on Set5 Image 2")
124
 
125
  ## BibTeX entry and citation info
126
  ```bibtex
 
5
  - image-super-resolution
6
  datasets:
7
  - eugenesiow/Div2k
8
+ - eugenesiow/Set5
9
+ - eugenesiow/Set14
10
+ - eugenesiow/BSD100
11
+ - eugenesiow/Urban100
12
  metrics:
13
  - pnsr
14
  - ssim
 
46
  ImageLoader.save_image(preds, './scaled_2x.png') # save the output 2x scaled image to `./scaled_2x.png`
47
  ImageLoader.save_compare(inputs, preds, './scaled_2x_compare.png') # save an output comparing the super-image with a bicubic scaling
48
  ```
49
+ [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/eugenesiow/super-image-notebooks/blob/master/notebooks/Upscale_Images_with_Pretrained_super_image_Models.ipynb "Open in Colab")
50
  ## Training data
51
+ The EDSR models for 2x, 3x and 4x image super resolution were pretrained on [DIV2K](https://huggingface.co/datasets/eugenesiow/Div2k), a dataset of 800 high-quality (2K resolution) images for training, augmented to 4000 images and uses a dev set of 100 validation images (images numbered 801 to 900).
52
  ## Training procedure
53
  ### Preprocessing
54
  We follow the pre-processing and training method of [Wang et al.](https://arxiv.org/abs/2104.07566).
 
56
  During training, RGB patches with size of 64×64 from the LR input are used together with their corresponding HR patches.
57
  Data augmentation is applied to the training set in the pre-processing stage where five images are created from the four corners and center of the original image.
58
 
59
+ The following code provides some helper functions to get the data and preprocess/augment the data.
60
  ```python
61
+ from datasets import load_dataset
62
 
63
+ augmented_dataset = load_dataset('eugenesiow/Div2k', 'bicubic_x4', split='train')\
64
+ .map(augment_five_crop, batched=True, desc="Augmenting Dataset") # download and augment the data with the five_crop method
65
+ train_dataset = TrainDataset(augmented_dataset) # prepare the train dataset for loading PyTorch DataLoader
66
+ eval_dataset = EvalDataset(load_dataset('eugenesiow/Div2k', 'bicubic_x4', split='validation')) # prepare the eval dataset for the PyTorch DataLoader
 
 
 
 
 
 
 
 
 
 
67
  ```
68
  ### Pretraining
69
  The model was trained on GPU. The training code is provided below:
 
115
  |Urban100 |3x | |**29.23/0.8723** |
116
  |Urban100 |4x |23.14/0.6573 |**26.02/0.7832** |
117
 
118
+ ![Comparing Bicubic upscaling against x2 upscaling on Set5 Image 2](images/Set5_2_compare.png "Comparing Bicubic upscaling against x2 upscaling on Set5 Image 2")
119
 
120
  ## BibTeX entry and citation info
121
  ```bibtex