[ICCV'2021] Image Inpainting via Conditional Texture and Structure Dual Generation

Related tags

Deep Learning CTSDG
Overview

CTSDG

Paper | Pre-trained Models | BibTex

Image Inpainting via Conditional Texture and Structure Dual Generation

Xiefan Guo, Hongyu Yang, Di Huang
In ICCV'2021

Introduction

Generator. Image inpainting is cast into two subtasks, i.e., structure-constrained texture synthesis (left, blue) and texture-guided structure reconstruction (right, red), and the two parallel-coupled streams borrow encoded deep features from each other. The Bi-GFF module and CFA module are stacked at the end of the generator to further refine the results.

Discriminator. The texture branch estimates the generated texture, while the structure branch guides structure reconstruction.

Prerequisites

  • Python >= 3.6
  • PyTorch >= 1.0
  • NVIDIA GPU + CUDA cuDNN

Getting Started

Installation

  • Clone this repo:
git clone https://github.com/Xiefan-Guo/CTSDG.git
cd CTSDG
pip install -r requirements.txt

Datasets

Image Dataset. We evaluate the proposed method on the CelebA, Paris StreetView, and Places2 datasets, which are widely adopted in the literature.

Mask Dataset. Irregular masks are obtained from Irregular Masks and classified based on their hole sizes relative to the entire image with an increment of 10%.

Training

Analogous to PConv by Liu et.al, initial training followed by finetuning are performed.

python train.py \
  --image_root [path to image directory] \
  --mask_root [path mask directory]

python train.py \
  --image_root [path to image directory] \
  --mask_root [path to mask directory] \
  --pre_trained [path to checkpoints] \
  --finetune True

Distributed training support. You can train model in distributed settings.

python -m torch.distributed.launch --nproc_per_node=N_GPU train.py

Testing

To test the model, you run the following code.

python test.py \
  --pre_trained [path to checkpoints] \
  --image_root [path to image directory] \
  --mask_root [path to mask directory] \
  --result_root [path to output directory] \
  --number_eval [number of images to test]

Citation

If any part of our paper and repository is helpful to your work, please generously cite with:

@InProceedings{Guo_2021_ICCV,
    author    = {Guo, Xiefan and Yang, Hongyu and Huang, Di},
    title     = {Image Inpainting via Conditional Texture and Structure Dual Generation},
    booktitle = {Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV)},
    month     = {October},
    year      = {2021},
    pages     = {14134-14143}
}
Comments
  • Quantitative evaluation

    Quantitative evaluation

    Hi, Thank you for your great works. I couldn't find a section for quantitative results. Would you provide me with the pipeline with the quantitative results? And are you using irregular masks for different masks or do you use your own masks? Are they isolated for testing or they are included in the training time too?

    opened by youyeg 8
  • about experiment detail?

    about experiment detail?

    Thank you for your excellent work, I would really like to reproduce your model as a baseline for comparison, at your convenience can you tell us the number of training and fine-tuning iterations for each dataset?Thanks !

    opened by ScarletBlaze 3
  • Error while testing

    Error while testing

    python test.py --pre_trained ./checkpoints/places2.pt --image_root ./images/ --mask_root ./masks/ --result_root ./result/ --number_eval 1
    

    Sorry to bother you in this way. When I tried to test this project following the instruction in markdown, this error shows up.

     Cuda is available
    OrderedDict([('pre_trained', './checkpoints/places2.pt'),
                 ('image_root', './images/'),
                 ('mask_root', './masks/'),
                 ('num_workers', 4),
                 ('batch_size', 1),
                 ('load_size', (256, 256)),
                 ('sigma', 2.0),
                 ('mode', 'test'),
                 ('result_root', './result/'),
                 ('number_eval', 1)])
    start test...
      0%|                                                                                                                                                                                   | 0/1 [00:00<?, ?it/s]
    Traceback (most recent call last):
      File "test.py", line 64, in <module>
        output, __, __ = generator(input_image, torch.cat((input_edge, input_gray_image), dim=1), mask)
      File "/root/anaconda3/envs/CTSDG/lib/python3.6/site-packages/torch/nn/modules/module.py", line 489, in __call__
        result = self.forward(*input, **kwargs)
      File "/root/CTSDG/models/generator/generator.py", line 97, in forward
        ec_textures['ec_t_1'], ec_textures['ec_t_masks_1'] = self.ec_texture_1(ec_textures['ec_t_0'], ec_textures['ec_t_masks_0'])
      File "/root/anaconda3/envs/CTSDG/lib/python3.6/site-packages/torch/nn/modules/module.py", line 489, in __call__
        result = self.forward(*input, **kwargs)
      File "/root/CTSDG/models/generator/pconv.py", line 103, in forward
        images, masks = self.conv(images, masks)
      File "/root/anaconda3/envs/CTSDG/lib/python3.6/site-packages/torch/nn/modules/module.py", line 489, in __call__
        result = self.forward(*input, **kwargs)
      File "/root/CTSDG/models/generator/pconv.py", line 50, in forward
        padding=self.padding, dilation=self.dilation, groups=1)
    RuntimeError: Given groups=1, weight of size [64, 3, 7, 7], expected input[1, 9, 256, 256] to have 3 channels, but got 9 channels instead
    

    And I have no clue how to fix it.

    opened by AndyVerne 2
  • During training, an error occurred

    During training, an error occurred

    Hello, author, I think your work is amazing, but when I started training, he made a mistake, I can't solve it temporarily, can you help me? thank you! Traceback (most recent call last): File "E:/code/CTSDG-main/train.py", line 102, in train(opts, image_data_loader, generator, discriminator, extractor, generator_optim, discriminator_optim, is_cuda) File "E:\code\CTSDG-main\trainer.py", line 45, in train output, projected_image, projected_edge = generator(input_image, torch.cat((input_edge, input_gray_image), dim=1), mask) File "D:\Anaconda3\envs\torch18\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl result = self.forward(*input, **kwargs) File "E:\code\CTSDG-main\models\generator\generator.py", line 248, in forward dc_texture = torch.cat((dc_texture, ec_textures[ec_texture_skip]), dim=1) RuntimeError: Sizes of tensors must match except in dimension 2. Got 3 and 2 (The offending index is 0)

    opened by song201216 1
  • quantitative results on celeba

    quantitative results on celeba

    Dear authors, thank you for making this great work public.

    I did not find quantitative results for celeba in your paper, such as ssim and psnr.And I want to know the results on celeba in your experiment. I saw you post a pre-trained model about celeba. Can I calculate the indicator based on this model?

    Hope to hear from you, thank you very much!

    opened by slowwords 0
  • The question of discriminator adversarial loss

    The question of discriminator adversarial loss

    criteria/loss.py loss_adversarial = criterion(real_pred, real_target) + criterion(fake_pred, fake_target) +
    criterion(real_pred_edge, edge) + criterion(fake_pred_edge, edge) I think the former three "criterion(real_pred, real_target), criterion(fake_pred, fake_target), criterion(real_pred_edge, edge)" are right, but the last one "criterion(fake_pred_edge, edge)", I think the second parameter is the "non-truth edge" instead of "the ground_truth edge". I need your help to help me to understand the "criterion(fake_pred_edge, edge)".

    opened by zhangyonle 0
  • Could you give me some little experience that why you choice **178** for the celebA dataset drop size?

    Could you give me some little experience that why you choice **178** for the celebA dataset drop size?

    Here I can see you add a comment.

    https://github.com/Xiefan-Guo/CTSDG/blob/def02741ba1a110e70ee1a6365868e5d43731132/datasets/transform.py#L9

    Maybe you have some special reason for that, cause other size will not generate nice result.

    And that will be helpful for me.

    opened by FavorMylikes 3
  • 关于在测试时获取损坏边缘信息的方式疑问

    关于在测试时获取损坏边缘信息的方式疑问

    你好,我发现在你的论文中,无论是测试还是训练过程损坏的edge都是作为模型的输入的一部分。并且在你发布的训练和测试代码中,损坏的edge是通过将完整的edge点乘masks获得的,其中完整的edge是从完整的图像中获得的。

    但是,在实际或测试中,我们并没有完整的图像,因此我们无法获得完整的edge。而且您并没有像 Edge Connect 那样预训练一个用于修复损坏的edge的模型,这也是您在论文中声称的贡献。

    然而,从损坏图像中提取的edge并不等于从完整图像中提取出来的完整edge点乘mask,前者在损坏区域的附近会具有更少的信息。

    我认为你对你的模型的测试方式有问题:通过将完整边缘乘以掩码替换从损坏的图像中提取边缘,在损坏区域的边界处存在信息泄漏。我相信这种泄漏将有利于修复性能。请问能解释一下吗?

    opened by FFChopin456 1
Owner
Xiefan Guo
Xiefan Guo
My implementation of Image Inpainting - A deep learning Inpainting model

Image Inpainting What is Image Inpainting Image inpainting is a restorative process that allows for the fixing or removal of unwanted parts within ima

Joshua V Evans 1 Dec 12, 2021
Official PyTorch code for Hierarchical Conditional Flow: A Unified Framework for Image Super-Resolution and Image Rescaling (HCFlow, ICCV2021)

Hierarchical Conditional Flow: A Unified Framework for Image Super-Resolution and Image Rescaling (HCFlow, ICCV2021) This repository is the official P

Jingyun Liang 159 Dec 30, 2022
Official PyTorch code for Hierarchical Conditional Flow: A Unified Framework for Image Super-Resolution and Image Rescaling (HCFlow, ICCV2021)

Hierarchical Conditional Flow: A Unified Framework for Image Super-Resolution and Image Rescaling (HCFlow, ICCV2021) This repository is the official P

Jingyun Liang 159 Dec 30, 2022
CVPR 2021: "Generating Diverse Structure for Image Inpainting With Hierarchical VQ-VAE"

Diverse Structure Inpainting ArXiv | Papar | Supplementary Material | BibTex This repository is for the CVPR 2021 paper, "Generating Diverse Structure

null 152 Nov 4, 2022
Incremental Transformer Structure Enhanced Image Inpainting with Masking Positional Encoding (CVPR2022)

Incremental Transformer Structure Enhanced Image Inpainting with Masking Positional Encoding by Qiaole Dong*, Chenjie Cao*, Yanwei Fu Paper and Supple

Qiaole Dong 190 Dec 27, 2022
Implementation for our ICCV2021 paper: Internal Video Inpainting by Implicit Long-range Propagation

Implicit Internal Video Inpainting Implementation for our ICCV2021 paper: Internal Video Inpainting by Implicit Long-range Propagation paper | project

null 202 Dec 30, 2022
The source code of the ICCV2021 paper "PIRenderer: Controllable Portrait Image Generation via Semantic Neural Rendering"

The source code of the ICCV2021 paper "PIRenderer: Controllable Portrait Image Generation via Semantic Neural Rendering"

Ren Yurui 261 Jan 9, 2023
The source code of the ICCV2021 paper "PIRenderer: Controllable Portrait Image Generation via Semantic Neural Rendering"

Website | ArXiv | Get Start | Video PIRenderer The source code of the ICCV2021 paper "PIRenderer: Controllable Portrait Image Generation via Semantic

Ren Yurui 81 Sep 25, 2021
Exploring the Dual-task Correlation for Pose Guided Person Image Generation

Dual-task Pose Transformer Network The source code for our paper "Exploring Dual-task Correlation for Pose Guided Person Image Generation“ (CVPR2022)

null 63 Dec 15, 2022
StudioGAN is a Pytorch library providing implementations of representative Generative Adversarial Networks (GANs) for conditional/unconditional image generation.

StudioGAN is a Pytorch library providing implementations of representative Generative Adversarial Networks (GANs) for conditional/unconditional image generation.

null 3k Jan 8, 2023
Official pytorch code for SSC-GAN: Semi-Supervised Single-Stage Controllable GANs for Conditional Fine-Grained Image Generation(ICCV 2021)

SSC-GAN_repo Pytorch implementation for 'Semi-Supervised Single-Stage Controllable GANs for Conditional Fine-Grained Image Generation'.PDF SSC-GAN:Sem

tyty 4 Aug 28, 2022
"3D Human Texture Estimation from a Single Image with Transformers", ICCV 2021

Texformer: 3D Human Texture Estimation from a Single Image with Transformers This is the official implementation of "3D Human Texture Estimation from

XiangyuXu 193 Dec 5, 2022
codes for Image Inpainting with External-internal Learning and Monochromic Bottleneck

Image Inpainting with External-internal Learning and Monochromic Bottleneck This repository is for the CVPR 2021 paper: 'Image Inpainting with Externa

null 97 Nov 29, 2022
[ACM MM 2021] Diverse Image Inpainting with Bidirectional and Autoregressive Transformers

Diverse Image Inpainting with Bidirectional and Autoregressive Transformers Installation pip install -r requirements.txt Dataset Preparation Given the

Yingchen Yu 25 Nov 9, 2022
Auto-Lama combines object detection and image inpainting to automate object removals

Auto-Lama Auto-Lama combines object detection and image inpainting to automate object removals. It is build on top of DE:TR from Facebook Research and

null 44 Dec 9, 2022
Code for Dual Contrastive Learning for Unsupervised Image-to-Image Translation, NTIRE, CVPRW 2021.

arXiv Dual Contrastive Learning Adversarial Generative Networks (DCLGAN) We provide our PyTorch implementation of DCLGAN, which is a simple yet powerf

null 119 Dec 4, 2022
The pytorch implementation of the paper "text-guided neural image inpainting" at MM'2020

TDANet: Text-Guided Neural Image Inpainting, MM'2020 (Oral) MM | ArXiv This repository implements the paper "Text-Guided Neural Image Inpainting" by L

LisaiZhang 75 Dec 22, 2022