Skip to content

Latest commit

 

History

History

DeepGuidedFilteringNetwork

DGF for Image Processing

Prepare Dataset

  1. Download MIT-Adobe FiveK Dataset.
    dataset
    ├── ......
    └── fivek
        ├── ......
        └── raw_photos
            ├── HQa1to700
            │   └── photos
            │       ├── a0001-jmac_DSC1459.dng
            │       └── ......
            └── ......
  2. Convert from *.dng to *.tif.
    cd scripts
    python convert_dng_to_tif.py
  3. Generate Training/Test set with different resolution.
    cd scripts
    
    python precompute_size.py --min 512
    python precompute_size.py --min 1024
    python precompute_size.py --random
    
    python resize_image.py --file_name 512
    python resize_image.py --file_name 1024
    python resize_image.py --file_name random
  4. Generate Ground Truth for each task.
    • L0 smoothing / Multi-scale detail manipulation / Style transfer / Non-local dehazing
      cd scripts/[l0_smooth|multi_scale_detail_manipulation|style_transfer|non_local_dehazing]
      
      matlab -r "prepare_dataset(   '512'); exit" -nodisplay
      matlab -r "prepare_dataset(  '1024'); exit" -nodisplay
      matlab -r "prepare_dataset('random'); exit" -nodisplay
    • Image retouching (Auto-PS, Auto Beautification)
      1. Generate / Download Ground Truth
        dataset
        ├── ......
        └── fivek
            ├── ......
            └── gts
                ├── a0001-jmac_DSC1459.tif
                └── ......
        • Option 1: Generate ground truth with Adobe Lightroom by following the instruction.
        • Option 2 (Preferred): Download from the website.
          cd scripts/auto_ps
          
          # Expert [A|B|C|D|E]
          bash generate_list.sh [a|b|c|d|e]
          
          cd ../../dataset/fivek && mkdir gts && cd gts
          # Option 1: single thread
          wget -i ../../../scripts/auto_ps/img_list_[a|b|c|d|e].csv
          # Option 2: multi thread
          sudo apt-get install aria2
          aria2c -j 100 -i ../../../scripts/auto_ps/img_list_[a|b|c|d|e].csv
      2. Postprocess
        cd scripts/auto_ps
        python postprocess.py
        
        cd ..
        python resize_image.py --file_name 512    --task auto_ps
        python resize_image.py --file_name 1024   --task auto_ps
        python resize_image.py --file_name random --task auto_ps
  5. Split Training/Test set
    cd scripts/training_test_split
    python split.py --set 512 \
                    --task [l0_smooth|multi_scale_detail_manipulation|style_transfer|non_local_dehazing|auto_ps]
    python split.py --set 1024 \
                    --task [l0_smooth|multi_scale_detail_manipulation|style_transfer|non_local_dehazing|auto_ps]
    python split.py --set random \
                    --task [l0_smooth|multi_scale_detail_manipulation|style_transfer|non_local_dehazing|auto_ps]

Training

  • Option 1: Train from scratch
    python train_hr.py --task [l0_smooth|multi_scale_detail_manipulation|style_transfer|non_local_dehazing|auto_ps] \
                       --name [HR|HR_AD|CONV_HR|CONV_HR_AD] \
                       --model [deep_guided_filter|deep_guided_filter_advanced|deep_conv_guided_filter|deep_conv_guided_filter_adv]
  • Option 2: Train with low-resolution data + Finetune
    python train_lr.py --task [l0_smooth|multi_scale_detail_manipulation|style_transfer|non_local_dehazing|auto_ps]
    
    python train_hr_finetune.py --task [l0_smooth|multi_scale_detail_manipulation|style_transfer|non_local_dehazing|auto_ps] \
                                --name [HR_FT|HR_AD_FT|CONV_HR_FT|CONV_HR_AD_FT] \
                                --model [deep_guided_filter|deep_guided_filter_advanced|deep_conv_guided_filter|deep_conv_guided_filter_adv]

NOTE:

  • deep_guided_filter: DGFb
  • deep_guided_filter_advanced: DGF
  • deep_conv_guided_filter: DGFbc
  • deep_conv_guided_filter_adv: DGFc

Evaluate

python test_hr.py --task [l0_smooth|multi_scale_detail_manipulation|style_transfer|non_local_dehazing|auto_ps] \
                  --name [LR|HR|HR_AD|CONV_HR|CONV_HR_AD|HR_FT|HR_AD_FT|CONV_HR_FT|CONV_HR_AD_FT] \
                  --model [guided_filter|deep_guided_filter|deep_guided_filter_advanced|deep_conv_guided_filter|deep_conv_guided_filter_adv]

NOTE:

  • guided_filter: DGFs
  • deep_guided_filter: DGFb
  • deep_guided_filter_advanced: DGF
  • deep_conv_guided_filter: DGFbc
  • deep_conv_guided_filter_adv: DGFc

Running Time

python test_time.py --model_id [0|1|2|3|4|5]

NOTE:

  • 0: DGFb
  • 1: GuidedFilteringLayer
  • 2: DGF
  • 3: ConvGuidedFilteringLayer
  • 4: DGFbc
  • 5: DGFc

Predict

python predict.py  --task [l0_smooth|multi_scale_detail_manipulation|style_transfer|non_local_dehazing|auto_ps] \
                  [--img_path IMG_PATH | --img_list IMG_LIST] \
                   --save_folder SAVE_FOLDER \
                   --model [guided_filter|deep_guided_filter|deep_guided_filter_advanced|deep_conv_guided_filter|deep_conv_guided_filter_adv] \
                   --low_size 64 \
                   --gpu 0 \
                  [--gray]

NOTE:

  • --model
    • guided_filter: DGFs
    • deep_guided_filter: DGFb
    • deep_guided_filter_advanced: DGF
    • deep_conv_guided_filter: DGFbc
    • deep_conv_guided_filter_adv: DGFc
  • --gray: It's better to generate gray images for style transfer.

Acknowledgement

A part of the code was adapted from FastImageProcessing.