MCPcopy Index your code
hub / github.com/JingyunLiang/MANet

github.com/JingyunLiang/MANet @v0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.0 ↗ · + Follow
270 symbols 614 edges 24 files 46 documented · 17%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Mutual Affine Network for Spatially Variant Kernel Estimation in Blind Image Super-Resolution (MANet)

This repository is the official PyTorch implementation of Mutual Affine Network for Spatially Variant Kernel Estimation in Blind Image Super-Resolution (arxiv, supplementary).

:rocket: :rocket: :rocket: News: - Aug. 17, 2021: See our recent work for flow-based image SR: Hierarchical Conditional Flow: A Unified Framework for Image Super-Resolution and Image Rescaling (HCFlow), ICCV2021 - Aug. 17, 2021: See our recent work for real-world image SR: Designing a Practical Degradation Model for Deep Blind Image Super-Resolution (BSRGAN), ICCV2021 - Aug. 17, 2021: See our previous flow-based work: Flow-based Kernel Prior with Application to Blind Super-Resolution (FKP), CVPR2021.


Existing blind image super-resolution (SR) methods mostly assume blur kernels are spatially invariant across the whole image. However, such an assumption is rarely applicable for real images whose blur kernels are usually spatially variant due to factors such as object motion and out-of-focus. Hence, existing blind SR methods would inevitably give rise to poor performance in real applications. To address this issue, this paper proposes a mutual affine network (MANet) for spatially variant kernel estimation. Specifically, MANet has two distinctive features. First, it has a moderate receptive field so as to keep the locality of degradation. Second, it involves a new mutual affine convolution (MAConv) layer that enhances feature expressiveness without increasing receptive field, model size and computation burden. This is made possible through exploiting channel interdependence, which applies each channel split with an affine transformation module whose input are the rest channel splits. Extensive experiments on synthetic and real images show that the proposed MANet not only performs favorably for both spatially variant and invariant kernel estimation, but also leads to state-of-the-art blind SR performance when combined with non-blind SR methods.

Requirements

  • Python 3.6, PyTorch >= 1.6
  • Requirements: opencv-python
  • Platforms: Ubuntu 16.04, cuda-10.0 & cuDNN v-7.5

Note: this repository is based on BasicSR. Please refer to their repository for a better understanding of the code framework.

Quick Run

Download stage3_MANet+RRDB_x4.pth from release and put it in ./pretrained_models. Then, run this command:

cd codes
python test.py --opt options/test/test_stage3.yml

Data Preparation

To prepare data, put training and testing sets in ./datasets as ./datasets/DIV2K/HR/0801.png. Commonly used datasets can be downloaded here.

Training

Step1: to train MANet, run this command:

python train.py --opt options/train/train_stage1.yml

Step2: to train non-blind RRDB, run this command:

python train.py --opt options/train/train_stage2.yml

Step3: to fine-tune RRDB with MANet, run this command:

python train.py --opt options/train/train_stage3.yml

All trained models can be downloaded from release. For testing, downloading stage3 models is enough.

Testing

To test MANet (stage1, kernel estimation only), run this command:

python test.py --opt options/test/test_stage1.yml

To test RRDB-SFT (stage2, non-blind SR with ground-truth kernel), run this command:

python test.py --opt options/test/test_stage2.yml

To test MANet+RRDB (stage3, blind SR), run this command:

python test.py --opt options/test/test_stage3.yml

Note: above commands generate LR images on-the-fly. To generate testing sets used in the paper, run this command:

python prepare_testset.py --opt options/test/prepare_testset.yml

Interactive Exploration of Kernels

To explore spaitally variant kernels on an image, use --save_kernel and run this command to save kernel:

python test.py --opt options/test/test_stage1.yml --save_kernel

Then, run this command to creat an interactive window:

python interactive_explore.py --path ../results/001_MANet_aniso_x4_test_stage1/toy_dataset1/npz/toy1.npz

Results

We conducted experiments on both spatially variant and invariant blind SR. Please refer to the paper and supp for results.

Citation

@inproceedings{liang21manet,
  title={Mutual Affine Network for Spatially Variant Kernel Estimation in Blind Image Super-Resolution},
  author={Liang, Jingyun and Sun, Guolei and Zhang, Kai and Van Gool, Luc and Timofte, Radu},
  booktitle={IEEE Conference on International Conference on Computer Vision},
  year={2021}
}

License & Acknowledgement

This project is released under the Apache 2.0 license. The codes are based on BasicSR, MMSR, IKC and KAIR. Please also follow their licenses. Thanks for their great works.

Core symbols most depended-on inside this repo

bgr2ycbcr
called by 9
codes/data/util.py
load
called by 8
codes/models/B_model.py
get_network_description
called by 5
codes/models/base_model.py
load_network
called by 5
codes/models/base_model.py
sequential
called by 5
codes/models/modules/MANet_arch.py
create_dataloader
called by 4
codes/data/__init__.py
create_dataset
called by 4
codes/data/__init__.py
calculate_weights_indices
called by 4
codes/data/util.py

Shape

Method 136
Function 93
Class 41

Languages

Python100%

Modules by API surface

codes/utils/util.py85 symbols
codes/models/modules/MANet_arch.py28 symbols
codes/data/util.py21 symbols
codes/models/base_model.py18 symbols
codes/models/B_model.py17 symbols
codes/models/modules/loss.py15 symbols
codes/models/SR_model.py13 symbols
codes/models/SRGAN_model.py10 symbols
codes/options/options.py6 symbols
codes/models/modules/module_util.py6 symbols
codes/models/modules/discriminator_vgg_arch.py6 symbols
codes/models/lr_scheduler_test.py6 symbols

For agents

$ claude mcp add MANet \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page