GithubHelp home page GithubHelp logo

zhaoyi-yan / shift-net_pytorch Goto Github PK

View Code? Open in Web Editor NEW
362.0 13.0 83.0 5.86 MB

Pytorch implementation of Shift-Net: Image Inpainting via Deep Feature Rearrangement (ECCV, 2018)

Home Page: http://openaccess.thecvf.com/content_ECCV_2018/papers/Zhaoyi_Yan_Shift-Net_Image_Inpainting_ECCV_2018_paper.pdf

License: MIT License

Python 63.44% Jupyter Notebook 36.43% Shell 0.13%

shift-net_pytorch's Introduction

New training strategy

I release a new training strategy that helps deal with random mask training by reducing color shifting at the cost of about extra 30% training time. It is quite useful when we perform face inpainiting. Set --which_model_netG='face_unet_shift_triple' and --model='face_shiftnet' and --batchSize=1to carry out the strategy.

See some examples below, many approaches suffer from such color shifting when training with random masks on face datasets.

 
Input Navie Shift Flip Shift Ground-truth

Note: When you use face_flip training strategy, it suffers some minor drawbacks:

  1. It is not fully-parallel compared with original shift.
  2. It can only be trained on the 'cpu' or on a single gpu, the batch size must be 1, or it occurs an error.

If you want to conquer these drawbacks, you can optimize it by referring to original shift. It is not difficult, however, I do not have time to do it.

Architecutre

Shift layer

Prerequisites

  • Linux or Windows.
  • Python 2 or Python 3.
  • CPU or NVIDIA GPU + CUDA CuDNN.
  • Tested on pytorch >= 1.2

Getting Started

Installation

pip install visdom
pip install dominate
  • Clone this repo:
git clone https://github.com/Zhaoyi-Yan/Shift-Net_pytorch
cd Shift-Net_pytorch

Trained models

Usually, I would like to suggest you just pull the latest code and train by following the instructions.

However, for now, several models have been trained and uploaded.

Mask Paris CelebaHQ_256
center-mask ok ok
random mask(from partial conv) ok ok

For CelebaHQ_256 dataset: I select the first 2k images in CelebaHQ_256 for testing, the rest are for training.

python train.py --loadSize=256 --batchSize=1 --model='face_shiftnet' --name='celeb256' --which_model_netG='face_unet_shift_triple' --niter=30 --datarooot='./datasets/celeba-256/train'

Mention: loadSize should be 256 for face datasets, meaning direct resize the input image to 256x256.

The following some results on celebaHQ-256 and Paris.

Specially, for training models of random masks, we adopt the masks of partial conv(only the masks of which the ratio of masked region is 20~30% are used.)

 
Input Results Ground-truth

For testing, please read the documnent carefully.

Pretrained model for face center inpainting are available:

bash download_models.sh

Rename face_center_mask.pth to 30_net_G.pth, and put it in the folder ./log/face_center_mask_20_30(if not existed, create it)

python test.py --which_model_netG='unet_shift_triple' --model='shiftnet' --name='face_center_mask_20_30' --which_epoch=30 --dataroot='./datasets/celeba-256/test'

For face random inpainting, it is trained with --which_model_netG='face_unet_shift_triple' and --model='face_shiftnet'. Rename face_flip_random.pth to 30_net_G.pth and set which_model_netG='face_unet_shift_triple' and --model='face_shiftnet' when testing.

Similarity, for paris random inpainting, rename paris_random_mask_20_30.pth to 30_net_G.pth, and put it in the folder ./log/paris_random_mask_20_30(if not existed, create it) Then test the model:

python test.py --which_epoch=30 --name='paris_random_mask_20_30' --offline_loading_mask=1 --testing_mask_folder='masks' --dataroot='./datasets/celeba-256/test' --norm='instance'

Mention, your own masks should be prepared in the folder testing_mask_folder in advance.

For other models, I think you know how to evaluate them. For models trained with center mask, make sure --mask_type='center' --offline_loading_mask=0.

Train models

  • Download your own inpainting datasets. Just put all the train/test images in some folder (eg, ./xx/train/ , ./xx/test/), change dataroot in options/base_options.py to the that path, that is all.

  • Train a model: Please read this paragraph carefully before running the code.

Usually, we train/test navie shift-net with center mask.

python train.py --batchsize=1 --use_spectral_norm_D=1 --which_model_netD='basic' --mask_type='center' --which_model_netG='unet_shift_triple' --model='shiftnet' --shift_sz=1 --mask_thred=1 

For some datasets, such as CelebA, some images are smaller than 256*256, so you need add --loadSize=256 when training, it is important.

  • To view training results and loss plots, run python -m visdom.server and click the URL http://localhost:8097. The checkpoints will be saved in ./log by default.

DO NOT set batchsize larger than 1 for square mask training, the performance degrades a lot(I don't know why...) For random mask(mask_sub_type is NOT rect or your own random masks), the training batchsize can be larger than 1 without hurt of performance.

Random mask training(both online and offline) are also supported.

Personally, I would like to suggest you to loading the masks offline(similar as partial conv). Please refer to section Masks.

Test the model

Keep the same settings as those during training phase to avoid errors or bad performance

For example, if you train patch soft shift-net, then the following testing command is appropriate.

python test.py --fuse=1/0 --which_model_netG='patch_soft_unet_shift_triple' --model='patch_soft_shiftnet' --shift_sz=3 --mask_thred=4 

The test results will be saved to a html file here: ./results/.

Masks

Usually, Keep the same setting of masks of between training and testing. It is because the performance is highly-related to the masks your applied in training. The consistency of training and testing masks is crucial to achieve good performance.

training testing
center-mask center-mask
random-square All
random All
your own masks your own masks

It means that if you train a model with center-mask, then you need test it using center-mask(even without one pixel offset). For more info, you may refer to #125

Training by online-generating marks

We offer three types of online-generating masks: center-mask, random_square and random_mask. If you want to train on your own masks silimar like partial conv, ref to Training on your own masks.

Training on your own masks

It now supports both online-generating and offline-loading for training and testing. We generate masks online by default, however, set --offline_loading_mask=1 when you want to train/test with your own prepared masks. The prepared masks should be put in the folder --training_mask_folder and --testing_mask_folder.

Masks when training

For each batch, then:

  • Generating online: masks are the same for each image in a batch.(To save computation)
  • Loading offline: masks are loaded randomly for each image in a batch.

Using Switchable Norm instead of Instance/Batch Norm

For fixed mask training, Switchable Norm delivers better stableness when batchSize > 1. Please use switchable norm when you want to training with batchsize is large, much more stable than instance norm or batchnorm!

Extra variants

These 3 models are just for fun

For res patch soft shift-net:

python train.py --batchSize=1 --which_model_netG='res_patch_soft_unet_shift_triple' --model='res_patch_soft_shiftnet' --shift_sz=3 --mask_thred=4

For res navie shift-net:

python train.py --which_model_netG='res_unet_shift_triple' --model='res_shiftnet' --shift_sz=1 --mask_thred=1

For patch soft shift-net:

python train.py --which_model_netG='patch_soft_unet_shift_triple' --model='patch_soft_shiftnet' --shift_sz=3 --mask_thred=4

DO NOT change the shift_sz and mask_thred. Otherwise, it errors with a high probability.

For patch soft shift-net or res patch soft shift-net. You may set fuse=1 to see whether it delivers better results(Mention, you need keep the same setting between training and testing).

New things that I want to add

  • Make U-Net handle with inputs of any sizes.
  • Add more GANs, like spectural norm and relativelistic GAN.
  • Boost the efficiency of shift layer.
  • Directly resize the global_mask to get the mask in feature space.
  • Visualization of flow. It is still experimental now.
  • Extensions of Shift-Net. Still active in absorbing new features.
  • Fix bug in guidance loss when adopting it in multi-gpu.
  • Add composit L1 loss between mask loss and non-mask loss.
  • Finish optimizing soft-shift.
  • Add mask varaint in a batch.
  • Support Online-generating/Offline-loading prepared masks for training/testing.
  • Add VGG loss and TV loss
  • Fix performance degradance when batchsize is larger than 1.
  • Make it compatible for Pytorch 1.2
  • Training with mixed type of masks.
  • Try amp training
  • Try self-attn discriminator(maybe it helps)

Somethings extra I have tried

Gated Conv: I have tried gated conv(by replacing the normal convs of UNet with gated conv, expect the innermost/outermost layer). However, I obtained no benifits. Maybe I should try replacing all layers with gated conv. I will try again when I am free.

Non local block: I added, but seems worse. Maybe I haven't added the blocks on the proper postion. (It makes the training time increase a lot. So I am not in favor of it.)

Citation

If you find this work useful or gives you some insights, please cite:

@InProceedings{Yan_2018_Shift,
author = {Yan, Zhaoyi and Li, Xiaoming and Li, Mu and Zuo, Wangmeng and Shan, Shiguang},
title = {Shift-Net: Image Inpainting via Deep Feature Rearrangement},
booktitle = {The European Conference on Computer Vision (ECCV)},
month = {September},
year = {2018}
}

Acknowledgments

We benefit a lot from pytorch-CycleGAN-and-pix2pix

shift-net_pytorch's People

Contributors

lambdawill avatar naruto-sasuke avatar zhaoyi-yan 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

shift-net_pytorch's Issues

Epoches needed to converge

Hello. At first, thank you for the great idea and the code release.

I'm training the Shift-Net, but I'm not sure if it is converged or not since the logs do not say about the metrics (PSNR, SSIM, and Mean L2 Loss) reported in the paper.

So, can you please tell me how many epochs do I need for training to get the performances reported in the paper? Or if you have a script that calculates those metrics, I'd be happy if you can share with us.

Thanks!

Some questions about Places2 dataset.

Hello, I wonder when training the Places2 dataset, whether part of the data set is used or the whole data set? And how long it takes for the training? Thanks.

TypeError: initialize() takes exactly 1 argument (2 given)

Traceback (most recent call last):
  File "test.py", line 9, in <module>
    opt = TestOptions().parse()
  File "/home/Shift_Net/options/base_options.py", line 97, in parse
    opt = self.gather_options()
  File "/home/Shift_Net/options/base_options.py", line 69, in gather_options
    parser = self.initialize(parser)
TypeError: initialize() takes exactly 1 argument (2 given)

I miss something in test_options.py, it causes this error.

Planned Extensions on Shift-Net

  • High priority:
  • Update the code for pytorch >= 0.4.
  • Soft assignment instead of hard assignment.
  • Combine the shifted feature with original feature in a more elegant way. Eg. Residual, complicated residual.
  • Medium priority:
  • Relativistic discriminator.
  • Inception Module ?
  • Partial Conv ?

What's your opinion on this ? @tchaton

Inference with images not 256x256

Hey,
thank you for publishing the code for your project.

I am trying to run inference on images that are not 256x256 pixels, but of an arbitrary size.
It seems like if I do that the program automatically crops a 256x256 image out and uses that.

Is it possible by tweaking some code to run inference for images of arbitrary size?

Thank you and best regards
ThJOD

Making Shift-Net better for irregular face inpainting

About 2 years ago, we find a new novel training strategy that boosts the peformance of face inpainting a lot. This strategy was originally taken as the second novelty of Shift-Net v2 as the journel version. However, for some reason, I do not write the paper until now. Unfortuatelly, I do not think Shift-Net v2 will come out in the furture. So I will release the code. It surpasses normal Shift-Net in the irregular face inpainting a lot!

some questions about variants

Hello, Mr. Yan.When I read your code, I found that you created several variants on the basis of the original, which really made me admire. But I don't understand the difference between them and shift-net. Could you briefly introduce them?Thank you

Guidance loss is not compatible for multi-gpu

It is not easy to solve, in fact.

I have no idea on how to solve it.

I once write another kind of InnerCos.py which only works on multi-gpu but not suitable for single-gpu.

I do not know how to solve it by now.

Some questions

Hello,

I am going to concentrate next week reading and learning about your code.
I have several questions I would like to discuss with you.

My email adress is [email protected].

Best,
Thomas Chaton.

Optimization PB

Hello there,

The training was very slow.
I started to look into the code (You can find the notebook for the optimization on my repo).

At my big surprise, it takes 0.5 s to forward with a square centered mask. I was expecting way more.

I checked with your random mask generator.
while True:
x = random.randint(1, MAX_SIZE-fineSize)
y = random.randint(1, MAX_SIZE-fineSize)
mask = pattern[y:y+fineSize, x:x+fineSize] # need check
area = mask.sum()100./(fineSizefineSize)
if area>20 and area<maxPartition:
break
wastedIter += 1

You have a while True that sometines never finishes. It took between 6 sec to 400 sec.
I am going to remove it.

InnerCos Bug using soft_shift

(epoch: 1, iters: 800, time: 0.027, data: 0.521) G_GAN: 2.870 G_L1: 31.211 D: 0.407
(epoch: 1, iters: 1600, time: 0.027, data: 0.009) G_GAN: 5.973 G_L1: 25.281 D: 0.072
(epoch: 1, iters: 2400, time: 0.029, data: 0.010) G_GAN: 6.557 G_L1: 21.723 D: 0.005
(epoch: 1, iters: 3200, time: 0.029, data: 0.010) G_GAN: 5.861 G_L1: 17.568 D: 0.006
(epoch: 1, iters: 4000, time: 0.028, data: 0.011) G_GAN: 5.291 G_L1: 16.388 D: 0.061
(epoch: 1, iters: 4800, time: 0.029, data: 0.014) G_GAN: 5.334 G_L1: 15.123 D: 0.006
(epoch: 1, iters: 5600, time: 0.028, data: 0.010) G_GAN: 5.188 G_L1: 16.427 D: 0.219
Traceback (most recent call last):
File "train.py", line 33, in
model.set_gt_latent()
File "/home/tchaton/projects/original/Shift-Net_pytorch/models/shift_net/shiftnet_model.py", line 169, in set_gt_latent
self.netG(real_B) # input ground truth
File "/home/tchaton/virtualenvs/labelbox/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/tchaton/virtualenvs/labelbox/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py", line 121, in forward
return self.module(*inputs[0], **kwargs[0])
File "/home/tchaton/virtualenvs/labelbox/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/tchaton/projects/original/Shift-Net_pytorch/models/modules/shift_unet.py", line 59, in forward
return self.model(input)
File "/home/tchaton/virtualenvs/labelbox/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/tchaton/projects/original/Shift-Net_pytorch/models/modules/unet.py", line 83, in forward
return self.model(x)
File "/home/tchaton/virtualenvs/labelbox/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/tchaton/virtualenvs/labelbox/lib/python3.6/site-packages/torch/nn/modules/container.py", line 91, in forward
input = module(input)
File "/home/tchaton/virtualenvs/labelbox/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/tchaton/projects/original/Shift-Net_pytorch/models/modules/unet.py", line 85, in forward
x_latter = self.model(x)
File "/home/tchaton/virtualenvs/labelbox/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/tchaton/virtualenvs/labelbox/lib/python3.6/site-packages/torch/nn/modules/container.py", line 91, in forward
input = module(input)
File "/home/tchaton/virtualenvs/labelbox/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/tchaton/projects/original/Shift-Net_pytorch/models/modules/shift_unet.py", line 134, in forward
x_latter = self.model(x)
File "/home/tchaton/virtualenvs/labelbox/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/tchaton/virtualenvs/labelbox/lib/python3.6/site-packages/torch/nn/modules/container.py", line 91, in forward
input = module(input)
File "/home/tchaton/virtualenvs/labelbox/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/tchaton/projects/original/Shift-Net_pytorch/models/shift_net/InnerCos.py", line 39, in forward
self.loss = self.criterion(self.former_in_mask, self.target.expand_as(self.former_in_mask).type_as(self.former_in_mask))
RuntimeError: The expanded size of the tensor (8) must match the existing size (32) at non-singleton dimension 0

The batch_size don't match.

one error

There might be one error in the 238 line of models/shiftnet_model.py ,there no object called self.ng_loss

Increased time for each epoch

Hello @Zhaoyi-Yan ,

I have been running speed tests.
And visualizer.display_current_results time is growing due to the increases in images.
Therefore, I removed it from the main loop.
However, we should have a version which just change one elements and not all of them.

Best,
T.C

Dataset

Hwllo,I am currently working on image inpainting work and trying to train several model architectures. I saw that you used paris dataset in the experiments, I have been looking for it.Can you share the dataset through a private link in my email address?
Thank you very much
Email:[email protected]

how to run with CPU only

I want to run this project with CPU only.And what changes should I make about the code?
Thanks for your reading!

Warnings flood the screen

Hi @Zhaoyi-Yan! I'm training your model in Google Colab. When starting it floods the screen with user warnings during all training. Like this:
1 It is overloading the memory. How can I remove it? Or at least shut it down.

Multi-gpu training break again

When I pushed this commit #81 , it makes multi-gpu training broken.
I have known how to solve it, will push a commit when I am free.

Issue related to --dataroot='./datasets/celeba-256/test'

Hello, could you explain why I have the following problem when I have tried to execute -
python test.py --which_epoch=30 --name='paris_random_mask_20_30' --offline_loading_mask=1 --testing_mask_folder='masks' --dataroot='./datasets/celeba-256/test' --norm='instance'
AssertionError: ./datasets/Paris/train is not a valid directory.
Do I need to download the dataset to make the inference, if so where can I do it?

Guidance loss

gt_latent = self.ng_innerCos_list[0].get_target() # then get gt_latent(should be variable require_grad=False)
self.ng_innerCos_list[0].set_target(gt_latent)

I can not find these codes in set_gt_latent(self) function, so confused

Dataset

Hello,Regarding the dataset, do I put all the data directly in opt.dataroot, then the code will automatically divide the data set into a training set, a validation set, a test set? Or do I only put the training set into opt.dataroot?

acceleration for shift seems wrong.

When I run test_m.py,

(1, 4, 4)
torch.FloatTensor
cosine
tensor([[1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000,    nan,
         1.0000, 1.0000, 1.0000],
        [1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000,    nan,
         1.0000, 1.0000, 1.0000],
        [1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000,    nan,
         1.0000, 1.0000, 1.0000],
        [1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000,    nan,
         1.0000, 1.0000, 1.0000]])
index
tensor([8, 8, 8, 8])
former
tensor([[[29., 19.,  5., 38.],
         [49.,  7., 33., 38.],
         [ 2., 22., 10., 25.],
         [39., 43., 33., 36.]]])
latter
tensor([[[ 7.,  6., 11., 35.],
         [30., 18., 14., 30.],
         [14.,  1., 24., 27.],
         [ 0., 15.,  7., 12.]]])
flag
tensor([[0, 0, 0, 0],
        [0, 1, 1, 0],
        [0, 1, 1, 0],
        [0, 0, 0, 0]], dtype=torch.uint8)
ind_lst
tensor([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
        [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
        [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
        [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
        [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
        [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0.],
        [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0.],
        [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
        [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
        [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0.],
        [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0.],
        [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
        [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
        [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
        [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
        [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]])
tensor([[[[0., 0., 0., 0.],
          [0., 0., 0., 0.],
          [0., 0., 0., 0.],
          [0., 0., 0., 0.]]]])

Another test

(1, 4, 4)
torch.FloatTensor
cosine
tensor([[1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.],
        [1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.],
        [1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.],
        [1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.]])
index
tensor([0, 0, 0, 0])
former
tensor([[[48., 27., 47., 18.],
         [40., 38., 13., 32.],
         [26., 16., 40., 14.],
         [31., 29.,  2., 36.]]])
latter
tensor([[[34., 38., 39., 29.],
         [14., 49.,  9.,  5.],
         [18., 49., 21., 10.],
         [20., 26., 21.,  1.]]])
flag
tensor([[0, 0, 0, 0],
        [0, 1, 1, 0],
        [0, 1, 1, 0],
        [0, 0, 0, 0]], dtype=torch.uint8)
ind_lst
tensor([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
        [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
        [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
        [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
        [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
        [1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
        [1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
        [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
        [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
        [1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
        [1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
        [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
        [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
        [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
        [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
        [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]])
tensor([[[[ 0.,  0.,  0.,  0.],
          [ 0., 34., 34.,  0.],
          [ 0., 34., 34.,  0.],
          [ 0.,  0.,  0.,  0.]]]])

@tchaton

A bug: batchsize>1 it goes wrong!

@tchaton
I DO NOT when it goes like it.
When set batchSize=8 and run acc_unet_shift.
When batchsize>1, x_latter.size() is (8, 128, 64, 64), while x.size() is (1, 128, 64, 64)

  File "/home/yan/github/Shift-Net_pytorch/models/modules/shift_unet.py", line 236, in forward
    return torch.cat([x_latter, x], 1)  # cat in the C channel
RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 1. Got 8 and 1 in dimension 0 at /opt/conda/conda-bld/pytorch_1535488076166/work/aten/src/THC/generic/THCTensorMath.cu:87

AttributeError: 'Namespace' object has no attribute 'suffix'

After I ran the train.py error comes up

Traceback (most recent call last):
File "train.py", line 8, in
opt = TrainOptions().parse()
File "/Users//Shift-Net_pytorch/options/base_options.py", line 99, in parse
if opt.suffix:
AttributeError: 'Namespace' object has no attribute 'suffix'

BUG: SoftShift is broken

As the Nonparametric is modified, _paste is no long what it means before. Need a fix, when the final Nonparametric is decided.

The gap between two versions

Hello,I just run the PyTorch code training with Paris StreetView(30 epochs) ,but I found PSNR is much lower than that in your paper.Why?

Add another type of UNet construction.

For now, the construction of UNet is complicated and not flexible enough. Especially, when we need to adding other components to UNet, such type of model construction is surely horrible. So we need to construct the model in another way(More lines of code, yet more flexible)

training stop

I have a 1080Ti GPU ,and when I'm training,the training stops at third epoch.And I have tried again,it stopped at third epoch too,have you met this question?Why?Thanks.

How to understand the role of the parameter 'mask_thred'

Hello, Mr. Yan. Can you tell me how to understand parameter ‘mask_thred’,How can I choose a suitable value?。
in util.py,What is the function of mm = m.gt(mask_thred/(1.*patch_size**2 + 1e-4)).long()
Why is the value of eps selected as 1e-4?

pretrain model?

It would be helpful if you provide pretained model.
Thank you.

Issues with mask size

Hello, I was studying your work and during some tests I found that the current approach has issues with the size of masks: if there is no mask at all, the shift will try to find a mask in the latent space, and as it does not have a case to no mask in the latent space, the code it will crash. This case can be expanded to a case where the mask is small enough to be compressed, generating no mask in some reduction, during the compression phase, crashing again.

What modifications can be done to remove that issue? Currently I am inserting a mask with 8x8 pixels in a irrelevant part of the image, but it is not optimal. As I still have not thought in a better solution, I am asking you a better approach. I am open to develop that and make a pull request in your repo.

`re_avg_gan` is broken.

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.

I will refine the code in these aspects.

  • Simplify the code of networks.py. It is redundant and a little bit complex for now.
  • Add init_gain option.
  • Make it multi-gpu compatibility.
    Two more aspects:
  • Printing information of InnerCos and Shift layer.
  • Add Skip to InnerCos as a workaround.

The main difficulty lies in the implementationInnerCos. The target of InnerCos is not on the same GPU as that of its input. Multi-gpu support counts for a great deal when handling enormous datasets.

Batch shift operation

Will investigate how to change shift operation to batch shift, it is a bottleneck for higher gpu ultilization.

Performance of square masks is much better

Hi! Thanks a lot for your work! I downloaded 2 pretrained face models and noticed that results of the model with square masks are much better than that with random masks despite that random masks are smaller than squares. Below is the example. Why do you think this is? Also do you think that model can be trained with higher resolutions?
Untitled-1

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.