Giter VIP home page Giter VIP logo

glanet's Introduction

GLANet

The code for Global and Local Alignment Networks for Unpaired Image-to-Image Translation arxiv

Framework: image visualization results: image

Getting Started

Installation

This code was tested with Pytorch 1.7.0, CUDA 10.2, and Python 3.7

pip install visdom dominate
  • Clone this repo:
git clone https://github.com/ygjwd12345/GLANet.git
cd GLANet

Please refer to the original CUT and CycleGAN to download datasets and learn how to create your own datasets.

    sh ./datasets/download_cyclegan_dataset.sh a2b

Available datasets are: apple2orange, summer2winter_yosemite, horse2zebra, monet2photo, cezanne2photo, ukiyoe2photo, vangogh2photo, maps, facades, iphone2dslr_flower, ae_photos

    sh ./datasets/download_pix2pix_dataset.sh xx

Available datasets are night2day, edges2handbags, edges2shoes, facades, maps

The Cityscapes dataset can be downloaded from https://cityscapes-dataset.com. After that, use the script ./datasets/prepare_cityscapes_dataset.py to prepare the dataset.

Training

  • Train the single-modal I2I translation model. Please check run.sh. For instance:
python train.py  \
--dataroot ./datasets/summer2winter \
--name summer2winter \
--model sc \
--gpu_ids 0 \
--lambda_spatial 10 \
--lambda_gradient 0 \
--attn_layers 4,7,9 \
--loss_mode cos \
--gan_mode lsgan \
--display_port 8093 \
--direction BtoA \
--patch_size 64

Testing

  • Test the FID score for all training epochs, please also check run.sh. For instance:
python test_fid.py \
--dataroot ./datasets/horse2zebra \
--checkpoints_dir ./checkpoints \
--name horse2zebra \
--gpu_ids 0 \
--model sc \
--num_test 0
  • Test the KID, cityscape score, D&C, LPIPS, please check run_dc_lpips.sh in evaluations folder. For instance:
python PerceptualSimilarity/lpips_2dirs.py -d0 /data2/gyang/TAGAN/results/summer2winter-F64-mixer/test_350/images/real_B -d1 /data2/gyang/TAGAN/results/summer2winter-F64-mixer/test_350/images/fake_B -o ./example_dists.txt --use_gpu
python3 segment.py test -d ./datasets/cityscapes -c 19 --arch drn_d_22 \
    --pretrained ./drn_d_22_cityscapes.pth --phase val --batch-size 1

Acknowledge

Our code is developed based on FSeSim and unguided. We also thank pytorch-fid for FID computation, LPIPS for diversity score, and D&C for density and coverage evaluation.

glanet's People

Contributors

ygjwd12345 avatar ha0tang avatar

Stargazers

 avatar LuoJianPing avatar  avatar Beacon_Song avatar James avatar Zhiang Liu avatar  avatar DigitalSpatiality  avatar  avatar  avatar  avatar MingTao(陶明) avatar  avatar Matthew Phelps avatar  avatar Sergey Vakhreev avatar Elena D avatar Tunan avatar  avatar  avatar Jun Lyu avatar Brian Pugh avatar  avatar Lukas avatar Emmanuel Benazera avatar An-zhi WANG avatar  avatar  avatar  avatar Feng Guo avatar  avatar

Watchers

 avatar

Forkers

cv-ip 2805413893

glanet's Issues

Dimensional problems of the test

I want to output large size pictures

train:
python train.py
--dataroot ./datasets/orange2tomato
--name orange2tomato
--model sc
--gpu_ids 0
--lambda_spatial 10
--lambda_gradient 0
--attn_layers 4,7,9
--loss_mode cos
--gan_mode lsgan
--display_port 8093
--patch_size 64

test:
python test_fid.py
--dataroot ./datasets/orange2tomato
--checkpoints_dir ./checkpoints
--name orange2tomato
--gpu_ids 0
--model sc
--num_test 1000
--epoch 400
--load_size 1024
--crop_size 1024 \

issues:
Traceback (most recent call last):
File "/home/jupyter-zhangziyi/zhangziyi/GLANet/test_fid.py", line 71, in
model.data_dependent_initialize(data)
File "/home/jupyter-zhangziyi/zhangziyi/GLANet/models/sc_model.py", line 123, in data_dependent_initialize
self.forward()
File "/home/jupyter-zhangziyi/zhangziyi/GLANet/models/sc_model.py", line 152, in forward
self.fake,self.unguided_mean, self.unguided_sigma, self.posterior_mean, self.posterior_sigma, self.posterior_sample =self.netG(self.real,self.real_B,True)
File "/opt/tljh/user/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/home/jupyter-zhangziyi/zhangziyi/GLANet/models/glanet.py", line 731, in forward
source_style = self.style_encoder(source)
File "/opt/tljh/user/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/opt/tljh/user/lib/python3.9/site-packages/torch/nn/modules/container.py", line 141, in forward
input = module(input)
File "/opt/tljh/user/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/opt/tljh/user/lib/python3.9/site-packages/torch/nn/modules/container.py", line 141, in forward
input = module(input)
File "/opt/tljh/user/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/home/jupyter-zhangziyi/zhangziyi/GLANet/models/glanet.py", line 673, in forward
return self.fn(self.norm(x)) + x
File "/opt/tljh/user/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/opt/tljh/user/lib/python3.9/site-packages/torch/nn/modules/container.py", line 141, in forward
input = module(input)
File "/opt/tljh/user/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/opt/tljh/user/lib/python3.9/site-packages/torch/nn/modules/conv.py", line 301, in forward
return self._conv_forward(input, self.weight, self.bias)
File "/opt/tljh/user/lib/python3.9/site-packages/torch/nn/modules/conv.py", line 297, in _conv_forward
return F.conv1d(input, weight, bias, self.stride,
RuntimeError: Given groups=1, weight of size [1024, 256, 1], expected input[1, 4096, 512] to have 256 channels, but got 4096 channels instead

Ask for supplementary of this paper

Hello, Sorry to bother you.

I have been reading your paper recently and I noticed that you mentioned relevant information about supplementary material in your paper, but I am unable to find relevant supplementary material on the internet. Could you please send me a copy?

Thanks!

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.