Code Monkey home page Code Monkey logo

knazeri / edge-connect Goto Github PK

View Code? Open in Web Editor NEW
2.5K 71.0 530.0 1.34 MB

EdgeConnect: Structure Guided Image Inpainting using Edge Prediction, ICCV 2019 https://arxiv.org/abs/1901.00212

Home Page: http://openaccess.thecvf.com/content_ICCVW_2019/html/AIM/Nazeri_EdgeConnect_Structure_Guided_Image_Inpainting_using_Edge_Prediction_ICCVW_2019_paper.html

License: Other

Python 99.42% Shell 0.58%
edgeconnect image-inpainting generative-adversarial-network gans canny-edge-detection deep-learning pytorch

edge-connect's Introduction

EdgeConnect: Generative Image Inpainting with Adversarial Edge Learning

ArXiv | BibTex

Introduction:

We develop a new approach for image inpainting that does a better job of reproducing filled regions exhibiting fine details inspired by our understanding of how artists work: lines first, color next. We propose a two-stage adversarial model EdgeConnect that comprises of an edge generator followed by an image completion network. The edge generator hallucinates edges of the missing region (both regular and irregular) of the image, and the image completion network fills in the missing regions using hallucinated edges as a priori. Detailed description of the system can be found in our paper.

(a) Input images with missing regions. The missing regions are depicted in white. (b) Computed edge masks. Edges drawn in black are computed (for the available regions) using Canny edge detector; whereas edges shown in blue are hallucinated by the edge generator network. (c) Image inpainting results of the proposed approach.

Prerequisites

  • Python 3
  • PyTorch 1.0
  • NVIDIA GPU + CUDA cuDNN

Installation

  • Clone this repo:
git clone https://github.com/knazeri/edge-connect.git
cd edge-connect
pip install -r requirements.txt

Datasets

1) Images

We use Places2, CelebA and Paris Street-View datasets. To train a model on the full dataset, download datasets from official websites.

After downloading, run scripts/flist.py to generate train, test and validation set file lists. For example, to generate the training set file list on Places2 dataset run:

mkdir datasets
python ./scripts/flist.py --path path_to_places2_train_set --output ./datasets/places_train.flist

2) Irregular Masks

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.

Alternatively, you can download Quick Draw Irregular Mask Dataset by Karim Iskakov which is combination of 50 million strokes drawn by human hand.

Please use scripts/flist.py to generate train, test and validation set masks file lists as explained above.

Getting Started

Download the pre-trained models using the following links and copy them under ./checkpoints directory.

Places2 | CelebA | Paris-StreetView

Alternatively, you can run the following script to automatically download the pre-trained models:

bash ./scripts/download_model.sh

1) Training

To train the model, create a config.yaml file similar to the example config file and copy it under your checkpoints directory. Read the configuration guide for more information on model configuration.

EdgeConnect is trained in three stages: 1) training the edge model, 2) training the inpaint model and 3) training the joint model. To train the model:

python train.py --model [stage] --checkpoints [path to checkpoints]

For example to train the edge model on Places2 dataset under ./checkpoints/places2 directory:

python train.py --model 1 --checkpoints ./checkpoints/places2

Convergence of the model differs from dataset to dataset. For example Places2 dataset converges in one of two epochs, while smaller datasets like CelebA require almost 40 epochs to converge. You can set the number of training iterations by changing MAX_ITERS value in the configuration file.

2) Testing

To test the model, create a config.yaml file similar to the example config file and copy it under your checkpoints directory. Read the configuration guide for more information on model configuration.

You can test the model on all three stages: 1) edge model, 2) inpaint model and 3) joint model. In each case, you need to provide an input image (image with a mask) and a grayscale mask file. Please make sure that the mask file covers the entire mask region in the input image. To test the model:

python test.py \
  --model [stage] \
  --checkpoints [path to checkpoints] \
  --input [path to input directory or file] \
  --mask [path to masks directory or mask file] \
  --output [path to the output directory]

We provide some test examples under ./examples directory. Please download the pre-trained models and run:

python test.py \
  --checkpoints ./checkpoints/places2 
  --input ./examples/places2/images 
  --mask ./examples/places2/masks
  --output ./checkpoints/results

This script will inpaint all images in ./examples/places2/images using their corresponding masks in ./examples/places2/mask directory and saves the results in ./checkpoints/results directory. By default test.py script is run on stage 3 (--model=3).

3) Evaluating

To evaluate the model, you need to first run the model in test mode against your validation set and save the results on disk. We provide a utility ./scripts/metrics.py to evaluate the model using PSNR, SSIM and Mean Absolute Error:

python ./scripts/metrics.py --data-path [path to validation set] --output-path [path to model output]

To measure the Fréchet Inception Distance (FID score) run ./scripts/fid_score.py. We utilize the PyTorch implementation of FID from here which uses the pretrained weights from PyTorch's Inception model.

python ./scripts/fid_score.py --path [path to validation, path to model output] --gpu [GPU id to use]

Alternative Edge Detection

By default, we use Canny edge detector to extract edge information from the input images. If you want to train the model with an external edge detection (Holistically-Nested Edge Detection for example), you need to generate edge maps for the entire training/test sets as a pre-processing and their corresponding file lists using scripts/flist.py as explained above. Please make sure the file names and directory structure match your training/test sets. You can switch to external edge detection by specifying EDGE=2 in the config file.

Model Configuration

The model configuration is stored in a config.yaml file under your checkpoints directory. The following tables provide the documentation for all the options available in the configuration file:

General Model Configurations

Option Description
MODE 1: train, 2: test, 3: eval
MODEL 1: edge model, 2: inpaint model, 3: edge-inpaint model, 4: joint model
MASK 1: random block, 2: half, 3: external, 4: external + random block, 5: external + random block + half
EDGE 1: canny, 2: external
NMS 0: no non-max-suppression, 1: non-max-suppression on the external edges
SEED random number generator seed
GPU list of gpu ids, comma separated list e.g. [0,1]
DEBUG 0: no debug, 1: debugging mode
VERBOSE 0: no verbose, 1: output detailed statistics in the output console

Loading Train, Test and Validation Sets Configurations

Option Description
TRAIN_FLIST text file containing training set files list
VAL_FLIST text file containing validation set files list
TEST_FLIST text file containing test set files list
TRAIN_EDGE_FLIST text file containing training set external edges files list (only with EDGE=2)
VAL_EDGE_FLIST text file containing validation set external edges files list (only with EDGE=2)
TEST_EDGE_FLIST text file containing test set external edges files list (only with EDGE=2)
TRAIN_MASK_FLIST text file containing training set masks files list (only with MASK=3, 4, 5)
VAL_MASK_FLIST text file containing validation set masks files list (only with MASK=3, 4, 5)
TEST_MASK_FLIST text file containing test set masks files list (only with MASK=3, 4, 5)

Training Mode Configurations

Option Default Description
LR 0.0001 learning rate
D2G_LR 0.1 discriminator/generator learning rate ratio
BETA1 0.0 adam optimizer beta1
BETA2 0.9 adam optimizer beta2
BATCH_SIZE 8 input batch size
INPUT_SIZE 256 input image size for training. (0 for original size)
SIGMA 2 standard deviation of the Gaussian filter used in Canny edge detector
(0: random, -1: no edge)
MAX_ITERS 2e6 maximum number of iterations to train the model
EDGE_THRESHOLD 0.5 edge detection threshold (0-1)
L1_LOSS_WEIGHT 1 l1 loss weight
FM_LOSS_WEIGHT 10 feature-matching loss weight
STYLE_LOSS_WEIGHT 1 style loss weight
CONTENT_LOSS_WEIGHT 1 perceptual loss weight
INPAINT_ADV_LOSS_WEIGHT 0.01 adversarial loss weight
GAN_LOSS nsgan nsgan: non-saturating gan, lsgan: least squares GAN, hinge: hinge loss GAN
GAN_POOL_SIZE 0 fake images pool size
SAVE_INTERVAL 1000 how many iterations to wait before saving model (0: never)
EVAL_INTERVAL 0 how many iterations to wait before evaluating the model (0: never)
LOG_INTERVAL 10 how many iterations to wait before logging training loss (0: never)
SAMPLE_INTERVAL 1000 how many iterations to wait before saving sample (0: never)
SAMPLE_SIZE 12 number of images to sample on each samling interval

License

Licensed under a Creative Commons Attribution-NonCommercial 4.0 International.

Except where otherwise noted, this content is published under a CC BY-NC license, which means that you can copy, remix, transform and build upon the content as long as you do not use the material for commercial purposes and give appropriate credit and provide a link to the license.

Citation

If you use this code for your research, please cite our papers EdgeConnect: Generative Image Inpainting with Adversarial Edge Learning or EdgeConnect: Structure Guided Image Inpainting using Edge Prediction:

@inproceedings{nazeri2019edgeconnect,
  title={EdgeConnect: Generative Image Inpainting with Adversarial Edge Learning},
  author={Nazeri, Kamyar and Ng, Eric and Joseph, Tony and Qureshi, Faisal and Ebrahimi, Mehran},
  journal={arXiv preprint},
  year={2019},
}

@InProceedings{Nazeri_2019_ICCV,
  title = {EdgeConnect: Structure Guided Image Inpainting using Edge Prediction},
  author = {Nazeri, Kamyar and Ng, Eric and Joseph, Tony and Qureshi, Faisal and Ebrahimi, Mehran},
  booktitle = {The IEEE International Conference on Computer Vision (ICCV) Workshops},
  month = {Oct},
  year = {2019}
}

edge-connect's People

Contributors

0xflotus avatar c9o avatar knazeri avatar youyuge34 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

edge-connect's Issues

win7 cpu python test.py

RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_loc
ation='cpu' to map your storages to the CPU.

src/model.py
line 26 data = torch.load(self.gen_weights_path)
change
data = torch.load(self.gen_weights_path, map_location=lambda storage, loc: storage)
Loading EdgeModel generator...
Loading InpaintingModel generator...

start testing...

1 places2_01.png
2 places2_02.png
3 places2_03.png
4 places2_04.png
5 places2_05.png

End test....

OK

some questions about the irregular mask?

thanks for your work!I have some questions about the code in edge-connect.py. In your
coder, the input=(images * (1 - masks)) + masks, that means the white pixel in the irregular mask is the holes,that is different from Image Inpainting for Irregular Holes Using Partial Convolutions. I observed the most irregular masks have large white regions that result in most inputs only a little regions remains,and the edge predict are not perfect.

768000
I think may be change the input=(images * (1 - masks)) + masks to input=(images * masks + masks
is better?

Error when load my dataset

I want to train the model by ImageNet dataset. I organize these training images path into ImageNet_train.flist,and I set the MODEL=1, MASK=1. I have the follow bug when load the dataset, but I test the size of inputed images as follows. Is it necessary to define the collate_fn function in the DataLoader? Could you help me? Thank you very much!
image

image

typing mistake in "Readme.md"

When I am trying test example in Getting Started -> 2) Testing, I found that the command

python test.py \
  --checkpoints ./checkpoints/places2 
  --input ./examples/places2/images 
  --mask ./examples/places2/mask
  --output ./checkpoints/results

raise an error when reading the mask image, after checking the paths in this command, the --mask directory should be './examples/places2/masks', everything runs well after modification.

Performance

I tested some instances by places2 model, appeared some ambiguous shadows.Do you trained the model setting MASK=3?
image
image

Sigma config of Canny edge detector

Hi @knazeri ,
Thanks for your great job!
I have two question about canny edge detections.

  1. I wonder if I should use same sigma in config for training stage and test stage.
    For example can I use sigma = 3 when training but use sigma = 1 when testing?
  2. Another question, is it possible to use different sigma values automatically for different images?
    Using fixed sigma, sometimes too less edges are detected and sometimes too more.

Strange white points in filling content?

When I using the pre-trained Places2 model to inpaint, there are always some white points in the output?
Do I miss something or this is normal?
How can I remove this white points? The inpainting result is pretty good if without these white points.

Masked Image:
image
Output with default mode:
image

A bug that edge image size will change after `EdgeModel`

In the testing phase, I found a new cryptic bug that the edge output size of EdgeModel will dismatch with the input image size.
For instance, sizes of input images and masks are both [256,265], but handled by the EdgeModel, the edges output size will turn into [256,264], which I guess the odd number 265 is the key of problem. Maybe we can add a resize() in the test() function.

  • Below is some debug prints:
images size is torch.Size([1, 3, 256, 265]),
 edges size is torch.Size([1, 1, 256, 265]),
 masks size is torch.Size([1, 1, 256, 265])

images_masked size torch.Size([1, 3, 256, 265])
 edges size after `EdgeModel` is torch.Size([1, 1, 256, 264])

when i run the model 4 the error occur

Training epoch: 1
Traceback (most recent call last):
File "train.py", line 2, in
main(mode=1)
File "/code/edge-connect-master/main.py", line 56, in main
model.train()
File "/code/edge-connect-master/src/edge_connect.py", line 179, in train
self.edge_model.backward(e_gen_loss, e_dis_loss)
File "/code/edge-connect-master/src/models.py", line 152, in backward
gen_loss.backward()
File "/usr/local/lib/python3.5/dist-packages/torch/tensor.py", line 102, in backward
torch.autograd.backward(self, gradient, retain_graph, create_graph)
File "/usr/local/lib/python3.5/dist-packages/torch/autograd/init.py", line 90, in backward
allow_unreachable=True) # allow_unreachable flag
RuntimeError: Trying to backward through the graph a second time, but the buffers have already been freed. Specify retain_graph=True when calling backward the first time.

in other model , it does not have this error

loading error.

file:///home/skj/%E6%A1%8C%E9%9D%A2/2019-02-27%2012-32-52%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE.png I have encountered a dataset loading error, can you help?

Question about Places2 Dataset

Hi, thanks you for your amazing work and contribution to the field.
I'm very interested in your work and I'm currently trying to reproduce the result in places2 dataset.
I noticed that there exists 2 parts in places2 which is the standard one and the places2 challenge one.
So I would like to know which part(s) did you use for training your model. :)

how to get the trainset on places2?

Thank you for your excellent work. In your paper, you introduced how to get 256x256 images from original
images on celebA and Paris StreetView. but for places2, how do you get the 256x256 images?

effectiveness for pretraining

Hi @knazeri ,
Thank you for your contributions to this field!
My concern is that it takes too long(2-3 days) to train a model on celcebA/psv.
I wonder, whether pretraining on a larger dataset (eg., Places2), then fine-tune on celebA/psv can speed up training as other filed usually do (eg., classification)?

But the image distribution of CelebA (human face) is very different from Places2 (natural images) .

Thanks,

About the value of style loss weight

Hi,
Thanks a lot for the brilliant work. :)
I just wonder why the default weight of style loss is 1. I noticed that in the paper you are using 250 as style loss weight.
So if I want to train a model on my own dataset, should I set the value to 250?

about test

Why do I get the following error when I use the pre-trained model to test the image you provided?

RuntimeError: Error(s) in loading state_dict for EdgeGenerator:
Missing key(s) in state_dict: "encoder.1.weight", "encoder.4.weight", "encoder.7.weight", "middle.0.conv_block.1.weight", "middle.0.conv_block.5.weight", "middle.1.conv_block.1.weight", "middle.1.conv_block.5.weight", "middle.2.conv_block.1.weight", "middle.2.conv_block.5.weight", "middle.3.conv_block.1.weight", "middle.3.conv_block.5.weight", "middle.4.conv_block.1.weight", "middle.4.conv_block.5.weight", "middle.5.conv_block.1.weight", "middle.5.conv_block.5.weight", "middle.6.conv_block.1.weight", "middle.6.conv_block.5.weight", "middle.7.conv_block.1.weight", "middle.7.conv_block.5.weight", "decoder.0.weight", "decoder.3.weight".
Unexpected key(s) in state_dict: "encoder.1.weight_v", "encoder.4.weight_v", "encoder.7.weight_v", "middle.0.conv_block.1.weight_v", "middle.0.conv_block.5.weight_v", "middle.1.conv_block.1.weight_v", "middle.1.conv_block.5.weight_v", "middle.2.conv_block.1.weight_v", "middle.2.conv_block.5.weight_v", "middle.3.conv_block.1.weight_v", "middle.3.conv_block.5.weight_v", "middle.4.conv_block.1.weight_v", "middle.4.conv_block.5.weight_v", "middle.5.conv_block.1.weight_v", "middle.5.conv_block.5.weight_v", "middle.6.conv_block.1.weight_v", "middle.6.conv_block.5.weight_v", "middle.7.conv_block.1.weight_v", "middle.7.conv_block.5.weight_v", "decoder.0.weight_v", "decoder.3.weight_v".

question about celeba

hello!
There are 'img_celeba.7z' 'img_align_celeba_png.7z' 'img_align_celeba.zip',which did you use?

results of model1

Uploading image.png…
Uploading image.png…

This is some of the results I got with the edge model test. I cant get the edge map.Can you help
me.

question about my own images

Hello!
I have some questions.When I use your examples, I can achieve the same effect.But when I use my own images.There are some problems.Can you tell me that how can I get the corresponding mask images

About the results

Hi @knazeri ,
Just test with places2 pre-trained models and model 4. But the results are not very good.
Did I do something wrong? Or how can I improve the performance? Thanks!
Image
soccer
Mask
soccer_mask
Result
soccer

training data used in the paper

Hi @knazeri ,

Would you like to provide the dataset splits (train/val/test) for celeba/psv/places2 used in the paper?
It makes me confused that (section B of the supplemental material), do you use all the images for training? For example, 14900 psv images include test data.

Thanks,
yanhong.

Lacks of `Model.train()` and `torch.no_grad()`

In training phase, the call of model.train() is missed after the call of sample() and eval().
model.train() is only called at the start of each epoch.

self.edge_model.train()

self.inpaint_model.train()

So if sample() is called, the following training iterations are all under eval() model! Though there are no dropout or batchNorm layers in the network, the call of train() is still necessary to avoid some confusing bugs.

And I strongly recommend use with torch.no_grad() to wrap the validation or test phase, such as sample(), eval() or test() functions here, in order to save memory and speed up. Refer to discuss about no_grad()

Time spending on training

Hi.
Thanks for your great work.
I wonder which GPU did u use,and how many time you spend on training each dataset?
Do u have any suggestion on the training sequence of datasets? Should i start with the places2 or others?And why?
THX!

learning rate policy used in image inpainting

Hi @knazeri ,
I have a question that, have you ever tried any learning rate policy in image inpainting model training?
Such as cosine decay, step policy etc.
Do you think these policy can help better convergence in such models' training?

Besides, thank you for your contributions! I have benefited a lot from this repo!

About the discriminator hinge loss formula

return self.criterion(1 + outputs).mean()

Hello, I am wondering if there should be a minus sign on the formula of the discriminator's hinge loss?

According to https://arxiv.org/pdf/1802.05957.pdf equation (17),
V_D = E[min(0, -1+D(real_data))] + E[min(0, -1-D(G(z)))]

But in here, it's
relu(1 + outputs).mean() = max(0, 1 + outputs).mean() ~= E[max(0, 1-D(real_data))] + E[max(0, 1+D(G(z)))]

I guess there a minus sign should be added to achieve the same behaviour?

Train own dataset

I want to train the model for my own dataset,and how can I make the mask file list,edges files list.Could your help me ?Thanks!

Error when train the inpaint with edge model

hello @knazeri
After I have finished training edge and inpaint model, I train the inpaint with edge model as your paper said.But the intermediate results are strange, what is the problem that causes the output to be blank?
Below is one of the sample images:

test

running with an error

when i run it with python3 train.py --model 1 --checkpoints ./checkpoints/places2/
it has an error occur loading error: ./datasets/irregular_mask/disocclusion_img_mask/36173.png
i am true the image in this path so i check the code and find it need data, edge_data, and mask_data, but in Places2 we have only one? where the data i can get? thank you very much

My Error

I load the pretrained model, have the follow error. I use pytorch0.4.0
image

About the results of CelebA: Some repaired images are similar to the original one

Hello @knazeri , thanks for your code!

In your paper, some inpainting results are shown. They are really cool, but the results in the pictures have different style. That is, some results are nearly same with the original pic while others not (but still visually perfect). For example, in Fig 15, the following results:
image
In all of the three images, eyes (or mouth) are missing. For the first image, it is recovered with a synthesized person, while for the 2-3 lines, the recovered images are actually the same as the original image.
My questions are:
Q1: Are the images selected from a test (validation) set, which is not used for training? Or only mask is seperated into training/val/test?
Q2: Are there any overlapping person between the train/val/test set? Intuitively, the results in the above 2-3 lines is due to the existing of the same person in the train/test set.

Thanks!

The Problem of training Edge model

Hello, I meet some trouble when training the edge model as follows use the code parameters('LR':0.0001, 'D2G_LR':0.1), and I dont' understand the difference of LR and D2G_LR.
image
And the gen_loss has been turbulent.

image
image
image
For the edge image, the above is the output of edge model, and the down is the groundtruth.
I think the D2G_LR is too big, could you help me?

Question about training stage

Hi @knazeri ,
To train the model, should I have to train edge model, inpaint model and joint model in sequence?
Can I train the models at the same time?

Thanks for your time!

My training errors

Thank you for your excellent work. I encountered two problems:
First, when I was training on the Places dataset, when the training went to 1000 iter
s, the model was not saved, and the training did not continue to go down any more.
qq 20190224203021
The second problem is that when I use my own data set, there are some problems, like the picture loading is not successful, but my flist file is generated correctly and the path of the picture is correct.This error will not occur when using the data set in your paper at that time.
_20190224203033
I hope you can help me.

Training epoch

Hi Knazeri,
I am trying out your code, it's just that no matter for place2 or celeba dataset in examples folder, the training procedure ends in one epoch.
image
Just like what says on the screenshot. And of course, no models were saved in /checkpoints folder.
Have you run into this problem before?
Really appreciate your help!

Questions about the adversarial loss

Thanks for your interesting work for image inpainting! (star)
I have a few questions about the discriminator:

  1. What's the pros and cons for the three GAN loss functions (nsgan, lsgan and hinge) for edge-connect? Is there any visual/numerical comparison or reason to use them?

  2. The default GAN loss is nsgan. Are the pretrained models all trained with nsgan?

  3. I like your implementation of the adversarial loss

    edge-connect/src/loss.py

    Lines 31 to 43 in 698509d

    def __call__(self, outputs, is_real, is_disc=None):
    if self.type == 'hinge':
    if is_disc:
    if is_real:
    outputs = -outputs
    return self.criterion(1 + outputs).mean()
    else:
    return (-outputs).mean()
    else:
    labels = (self.real_label if is_real else self.fake_label).expand_as(outputs)
    loss = self.criterion(outputs, labels)
    return loss

    However, when I use it for my discriminator, the Loss_D and Loss_G always stay in a very small range (e.g., for hinge loss, Loss_D will stay in 1 while Loss_G will stay in -1; for lsgan, Loss_D will stay in 0.25 +- 0.001 and Loss_G 0.25 +-0.02; nsgan 0.693 +- 0.01).
    The image quality does improve though, but I wonder if that is normal? What does a normal training curve look like?
    FYI, I use spectral normalization for both the generator and discriminator.

I have some questions about the code?

hi, I am new in deep learning and Pytorch. so i have some difficult in reading code. So I have some questions.
in edgeconnect.py
after load the edgeconnect (“self.train_dataset = Dataset(config, config.TRAIN_FLIST, config.TRAIN_EDGE_FLIST,config.TRAIN_MASK_FLIST,augment=True, training=True)”,self.train_dataset will have train and edge and mask files' path)
but then it begin training,and i see that ,in after“ for items in train_loader”,it will become four kinds of data(images, images_gray, edges, masks)?
Can you sovle my problems? Thanks!

multi-gpu training

Hi,
I can not use multi GPUs to train the model... there are no DataParallel called in codes.
Do you have plan to support multi-gpu training?

Thank you.

Can not set GPU id

Setting GPU ids in "main.py" has no any effectiveness on choosing the GPU,while setting it in "edge_connect.py" can be effecitve.

Future work - quality, high resolution, bigger masks

Thank you for the great work and the inspiration for inpainting research! 👍

I've been experimenting with you model on imagenet and I can basically confirm that your model is perfect for inpainting images in which edges are crucial (e.g. buildings) but sometimes do poorly on general scenes such as examples provided in paper (page 8, Figure 9).

Q1: Do you think that training/finetuning on ImageNet could resolve this issue to some extent? Have you tried other approaches to resolve this issue (e.g. modified adversarial loss, additional discriminator, modified edge detection etc)?

Since your model is applicable to higher resolutions I tried to continue training on 512x512 using your pretrained model.

Q2: Do you think that this approach is valid or it is better to train whole model from scratch.
Q3: I'm curious about your thoughts about using edge-connect in higher resolutions and bigger masks. Do you have any suggestions for architectural modifications or can think of any other steps that probably should be taken besides provided code?

Thanks!

how to test fid?

when I run the command
python ./scripts/fid_score.py --path /userhome/inpaint_bord/data/places2_gt_1000/ /userhome/edge-connect-master/checkpoints/results/ (the /userhome/inpaint_bord/data/places2_gt_1000/ contains 1000 really images and /userhome/edge-connect-master/checkpoints/results/ contains 1000 inpainted images), the process is seized up and stopped.
the log is like :
calculate path1 statistics...
calculate path2 statistics...
./scripts/fid_score.py:86: UserWarning: volatile was removed and now has no effect. Use with torch.no_grad(): instead.
batch = Variable(batch, volatile=True)
/usr/local/lib/python3.6/dist-packages/torch/nn/functional.py:2351: UserWarning: nn.functional.upsample is deprecated. Use nn.functional.interpolate instead.
warnings.warn("nn.functional.upsample is deprecated. Use nn.functional.interpolate instead.")
/usr/local/lib/python3.6/dist-packages/torch/nn/functional.py:2423: UserWarning: Default upsampling behavior when mode=bil inear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details.
"See the documentation of nn.Upsample for details.".format(mode))

is it used correct to test fid? and if i want to test fid about celebA faces, is it also use the inception model trained on imagenet or retrain the model on celebA faces?

Question about default image color values in hole area

Hi Knazeri, the code of getting images_masked is as follows:

  • in EdgeModel:
images_masked = (images * (1 - masks).float()) + masks
  • in InpaintingModel:
images_masked = (images * (1 - masks).float()) + masks

the hole areas in the image are filled with 1. I also read some other inpainting code and find that some code filled holes with 0. Is the inpainting result affected by filling hole areas with 1 or 0?

Using the pre-trained model to continue training

Hi Kamyar,

I am wondering if it is possible to use the trained model by you as pre-trained model and continue to train with my data. if so, how to update the pre-trained model? Is it same as the training part in your instruction document? Because now I still can't tackle that 1000 iterations problem. (it just got stuck there and would not go beyond the 1001st iteration. I'm thinking that using your existing model and then use my data to continue to train for 999 iterations may work better).

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.