PyTorch Implement of Context Encoders: Feature Learning by Inpainting

Overview

Context Encoders: Feature Learning by Inpainting

This is the Pytorch implement of CVPR 2016 paper on Context Encoders

corrupted result

1) Semantic Inpainting Demo

  1. Install PyTorch http://pytorch.org/

  2. Clone the repository

git clone https://github.com/BoyuanJiang/context_encoder_pytorch.git
  1. Demo

    Download pre-trained model on Paris Streetview from Google Drive OR BaiduNetdisk

    cp netG_streetview.pth context_encoder_pytorch/model/
    cd context_encoder_pytorch/model/
    # Inpainting a batch iamges
    python test.py --netG model/netG_streetview.pth --dataroot dataset/val --batchSize 100
    # Inpainting one image 
    python test_one.py --netG model/netG_streetview.pth --test_image result/test/cropped/065_im.png

2) Train on your own dataset

  1. Build dataset

    Put your images under dataset/train,all images should under subdirectory

    dataset/train/subdirectory1/some_images

    dataset/train/subdirectory2/some_images

    ...

    Note:For Google Policy,Paris StreetView Dataset is not public data,for research using please contact with pathak22. You can also use The Paris Dataset to train your model

  2. Train

python train.py --cuda --wtl2 0.999 --niter 200
  1. Test

    This step is similar to Semantic Inpainting Demo

Comments
  • problem about torchvision

    problem about torchvision

    hi, I was install torchvision from pip, and it worked. but when I install torchvision from source, it occured a problem as:

    Traceback (most recent call last):
      File "test.py", line 79, in <module>
        real_cpu, _ = dataiter.next()
      File "/usr/local/lib/python2.7/dist-packages/torch/utils/data/dataloader.py", line 212, in __next__
        return self._process_next_batch(batch)
      File "/usr/local/lib/python2.7/dist-packages/torch/utils/data/dataloader.py", line 239, in _process_next_batch
        raise batch.exc_type(batch.exc_msg)
    AttributeError: Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/torch/utils/data/dataloader.py", line 41, in _worker_loop
        samples = collate_fn([dataset[i] for i in batch_indices])
      File "build/bdist.linux-x86_64/egg/torchvision/datasets/folder.py", line 116, in __getitem__
        img = self.loader(path)
      File "build/bdist.linux-x86_64/egg/torchvision/datasets/folder.py", line 63, in default_loader
        return pil_loader(path)
      File "build/bdist.linux-x86_64/egg/torchvision/datasets/folder.py", line 45, in pil_loader
        with Image.open(f) as img:
      File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 528, in __getattr__
        raise AttributeError(name)
    AttributeError: __exit__
    

    It is there anything wrong? Thanks

    opened by GumpCode 3
  • Unable to change the input size

    Unable to change the input size

    I think a larger input size will utilize the GPU source better, but I failed to change the input size, could give me some guidance on which operation leads to a fixed size of imageSize 128, is this size a must?

    opened by zhou-rui1 0
  • can't train on the pretrained model

    can't train on the pretrained model

    I wanted to train on the pretrained model, but after using this command, the program prints the model structure and ends. What seems to be the problem? python train.py --cuda --netG model/netG_streetview.pth --wtl2 0.999 --niter 200

    opened by moonpieeee 0
  • Black Boxes in reconstructed Images on CIFAR-10 dataset

    Black Boxes in reconstructed Images on CIFAR-10 dataset

    I have been running the training.py file on CIFAR-10 dataset without any modifications from the original code. I have been getting black translucent boxes in reconstructed images. Any idea how to fix that?

    Screenshot 2021-03-15 at 4 02 28 PM

    opened by ankush18194 0
  • argument 'size' must be tuple of ints, but found element of type float at pos 3

    argument 'size' must be tuple of ints, but found element of type float at pos 3

    This is what I am getting when I run test.py

    Traceback (most recent call last): File "test.py", line 64, in real_center = torch.FloatTensor(opt.batchSize, 3, opt.imageSize/2, opt.imageSize/2) TypeError: new(): argument 'size' must be tuple of ints, but found element of type float at pos 3

    any ideas?

    opened by caruofc 3
  • images during training are too dark

    images during training are too dark

    Hi, thanks for sharing your great work! I follow your recommendation that use the The Paris Dataset to train the network. After training, when I check the result/train/real or result/train/cropped or result/train/recon folder, I found that all the images are too dark, such as this: real image: image cropped image: image recon image: recon_center_samples_epoch_199

    The result of inpainting is effective, but why all the image are so dark?

    ps: I do not change anything of the code except dataset/train folder.

    opened by liminn 4
Owner
null
AOT-GAN for High-Resolution Image Inpainting (codebase for image inpainting)

AOT-GAN for High-Resolution Image Inpainting Arxiv Paper | AOT-GAN: Aggregated Contextual Transformations for High-Resolution Image Inpainting Yanhong

Multimedia Research 214 Jan 3, 2023
GAN encoders in PyTorch that could match PGGAN, StyleGAN v1/v2, and BigGAN. Code also integrates the implementation of these GANs.

MTV-TSA: Adaptable GAN Encoders for Image Reconstruction via Multi-type Latent Vectors with Two-scale Attentions. This is the official code release fo

owl 37 Dec 24, 2022
IAUnet: Global Context-Aware Feature Learning for Person Re-Identification

IAUnet This repository contains the code for the paper: IAUnet: Global Context-Aware Feature Learning for Person Re-Identification Ruibing Hou, Bingpe

null 30 Jul 14, 2022
This repo holds code for TransUNet: Transformers Make Strong Encoders for Medical Image Segmentation

TransUNet This repo holds code for TransUNet: Transformers Make Strong Encoders for Medical Image Segmentation Usage

null 1.4k Jan 4, 2023
TSP: Temporally-Sensitive Pretraining of Video Encoders for Localization Tasks

TSP: Temporally-Sensitive Pretraining of Video Encoders for Localization Tasks [Paper] [Project Website] This repository holds the source code, pretra

Humam Alwassel 83 Dec 21, 2022
RE3: State Entropy Maximization with Random Encoders for Efficient Exploration

State Entropy Maximization with Random Encoders for Efficient Exploration (RE3) (ICML 2021) Code for State Entropy Maximization with Random Encoders f

Younggyo Seo 47 Nov 29, 2022
Final project code: Implementing MAE with downscaled encoders and datasets, for ESE546 FA21 at University of Pennsylvania

546 Final Project: Masked Autoencoder Haoran Tang, Qirui Wu 1. Training To train the network, please run mae_pretraining.py. Please modify folder path

Haoran Tang 0 Apr 22, 2022
[ICLR 2022] Pretraining Text Encoders with Adversarial Mixture of Training Signal Generators

AMOS This repository contains the scripts for fine-tuning AMOS pretrained models on GLUE and SQuAD 2.0 benchmarks. Paper: Pretraining Text Encoders wi

Microsoft 22 Sep 15, 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
official Pytorch implementation of ICCV 2021 paper FuseFormer: Fusing Fine-Grained Information in Transformers for Video Inpainting.

FuseFormer: Fusing Fine-Grained Information in Transformers for Video Inpainting By Rui Liu, Hanming Deng, Yangyi Huang, Xiaoyu Shi, Lewei Lu, Wenxiu

null 77 Dec 27, 2022
Unofficial pytorch implementation of 'Image Inpainting for Irregular Holes Using Partial Convolutions'

pytorch-inpainting-with-partial-conv Official implementation is released by the authors. Note that this is an ongoing re-implementation and I cannot f

Naoto Inoue 525 Jan 1, 2023
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
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
Implementation for "Seamless Manga Inpainting with Semantics Awareness" (SIGGRAPH 2021 issue)

Seamless Manga Inpainting with Semantics Awareness [SIGGRAPH 2021](To appear) | Project Website | BibTex Introduction: Manga inpainting fills up the d

null 101 Jan 1, 2023
Probabilistic Tracklet Scoring and Inpainting for Multiple Object Tracking

Probabilistic Tracklet Scoring and Inpainting for Multiple Object Tracking (CVPR 2021) Pytorch implementation of the ArTIST motion model. In this repo

Fatemeh 38 Dec 12, 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
[ICCV'2021] Image Inpainting via Conditional Texture and Structure Dual Generation

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

Xiefan Guo 122 Dec 11, 2022