Code Monkey home page Code Monkey logo

rgtsi's Introduction

Reference-Guided Texture and Structure Inference for Image Inpainting

visitors paper

This is the repository of the paper Reference-Guided Texture and Structure Inference for Image Inpainting, accepted by ICIP 2022.

Abstract: Existing learning-based image inpainting methods are still in challenge when facing complex semantic environments and diverse hole patterns. The prior information learned from the large scale training data is still insufficient for these situations. Reference images captured covering the same scenes share similar texture and structure priors with the corrupted images, which offers new prospects for the image inpainting tasks. Inspired by this, we first build a benchmark dataset containing 10K pairs of input and reference images for reference-guided inpainting. Then we adopt an encoder-decoder structure to separately infer the texture and structure features of the input image considering their pattern discrepancy of texture and structure during inpainting. A feature alignment module is further designed to refine these features of the input image with the guidance of a reference image. Both quantitative and qualitative evaluations demonstrate the superiority of our method over the state-of-the-art methods in terms of completing complex holes.

Usage Instructions

Environment

Please install Anaconda, Pytorch. For other libs, please refer to the file requirements.txt.

git clone https://github.com/Cameltr/RGTSI.git
conda create -n RGTSI python=3.8
conda activate RGTSI
pip install -r requirements.txt

Dataset Preparation

Please download DPED10K dataset from Google Drive or Baidu Netdisk (Password: roqs). Create a folder and unzip the dataset into it, then edit the pathes of the folder in options/base_options.py

Our model is trained on the irregular mask dataset provided by Liu et al. You can download publically available Irregular Mask Dataset from their website.

For Structure image of datasets, we follow the Structure flow and utlize the RTV smooth method.Run generation function data/Matlab/generate_structre_images.m in your matlab. For example, if you want to generate smooth images, you can run the following code:

generate_structure_images("path to dataset root", "path to output folder");

Training and Testing

# To train on the you dataset, for example.
python train.py --st_root=[the path of structure images] --de_root=[the path of ground truth images] --input_mask_root=[the path of mask images] --ref_root=[the path of reference images]

There are many options you can specify. Please use python train.py --help or see the options

For the current version, the batchsize needs to be set to 1.

To log training, use --./logs for Tensorboard. The logs are stored at logs/[name].

# To test on the your dataset, for example.
python test.py  

Please edit the the path of test images in test.py when testing on your dataset.

Pre-trained weights and test model

Download pretrained models from Google Drive or Baidu Netdisk (Password: bb0j).

Citation

If you find our code or datasets helpful for your research, please cite our paper.

@inproceedings{liu2022reference,
  title={Reference-guided texture and structure inference for image inpainting},
  author={Liu, Taorong and Liao, Liang and Wang, Zheng and Satoh, Shin’Ichi},
  booktitle={2022 IEEE International Conference on Image Processing (ICIP)},
  pages={1996--2000},
  year={2022},
  organization={IEEE}
}

Acknowledgments

RGTSI is bulit upon the MEDFE and inspired by SSEN. We appreciate the authors' excellent work!

rgtsi's People

Contributors

cameltr avatar

Stargazers

Toya Oyama avatar Wanglong Lu avatar  avatar kangaroo563 avatar  avatar WEI, ZHIXIANG avatar SresserS avatar  avatar HUANG Yuanhao avatar Nathan_Fjptchh avatar  avatar diadestiny avatar Lanxin Zeng avatar  avatar Stoney Kang avatar Stanley Salvatierra avatar Yoon, Seungje avatar Katsuya Hyodo avatar Seok Joon Kim avatar Jingxuan Zhang avatar  avatar  avatar  avatar  avatar  avatar  avatar sindo avatar  avatar Zhiwen Wang avatar Delin Chen avatar Yan avatar  avatar

Watchers

Kostas Georgiou avatar  avatar

rgtsi's Issues

Error

Running the test.py, there be some errors:
“Given groups=1, weight of size [64, 768, 3, 3], expected input[1, 1536, 32, 32] to have 768 channels, but got 1536 channels instead.”

Error encountered when running test.py

hello~ I have just downloaded the checkpoint files and prepared the structure data under your guidance. And I would like to test the model on my own data. However, when I was running test.py, an error occurred indicating that there is a size mismatch when loading the net_RefEN.pth.

The error message is as follows:

initialize network with normal
initialize network with normal
/home/zlx/RGTSI/models/networks.py:60: UserWarning: nn.init.normal is now deprecated in favor of nn.init.normal_.
  init.normal(m.weight.data, 1.0, gain)
/home/zlx/RGTSI/models/networks.py:61: UserWarning: nn.init.constant is now deprecated in favor of nn.init.constant_.
  init.constant(m.bias.data, 0.0)
model [training1] was created
Traceback (most recent call last):
  File "test.py", line 43, in <module>
    model.netRefEN.module.load_state_dict(net_EN['net'])
  File "/home/zlx/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1052, in load_state_dict
    self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for RefEncoder:
        size mismatch for Encoder_1.model.0.weight: copying a param with shape torch.Size([64, 6, 4, 4]) from checkpoint, the shape in current model is torch.Size([64, 3, 4, 4]).```

Please help me solve this problem, since I'm looking forward to the inpainting results. 

Best regards~ 

How to run the code

Thanks.How do we run the code? Do I use python train.py directly? Are there any paths that need to be changed? And there is no de_root in the train_options.py file. Do we add this by ourselves? What does st_root mean?Sorry,I have too many qusetions. Looking forward to your reply.

Dataset download

Thanks for sharing code and concept it was great to me to study image process.

By the way, I can't download dataset at Baidu...

Is there any other download link?

Thanks.

dataset

Thanks for your sharing.But I can't find the dataset 'DPED10K', could you support the link of the dataset? Thank you

experiment

Hello, I am very interested in your article, how do you sit on your own dataset for the GI experiment in your comparative experiments section? Can you tell me? I can't modify the GI code to train the image with my own mask.

pip install -r requirements.txt fails

Hello!

I'm following the README to install the Python libraries. pip fails as following:

ERROR: Invalid requirement: '_libgcc_mutex=0.1=main' (from line 4 of requirements.txt)
Hint: = is not a valid operator. Did you mean == ?

pip is the latest version

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.