Code Monkey home page Code Monkey logo

guided-pix2pix's Introduction

Guided Image-to-Image Translation with Bi-Directional Feature Transformation

[Project | Paper]

Official Pytorch implementation for Guided Image-to-Image Translation with Bi-Directional Feature Transformation. Please contact Badour AlBahar ([email protected]) if you have any questions.

Prerequisites

This codebase was developed and tested with:

  • Python2.7
  • Pytorch 0.4.1.post2
  • CUDA 8.0

Datasets: (Due to memory constraints, we no longer maintain the datasets.)

  • Pose transfer:
    We use DeepFashion dataset. We follow the train/test splits provided by Pose guided person image generation.

  • Texture transfer: We use the dataset provided by textureGAN.

  • Depth Upsampling:
    We use the NYU v2 dataset.

Train

1. Pose transfer:

python train.py --dataroot /root/DeepFashion/ --name exp_name --netG bFT_resnet --dataset_mode pose --input_nc 3 --guide_nc 18 --output_nc 3 --lr 0.0002 --niter 100 --niter_decay 0 --batch_size 8 --use_GAN --netD basic --beta1 0.9 --checkpoints_dir ./pose_checkpoints

2. Texture transfer:

python train.py --dataroot /root/training_handbags_pretrain/ --name exp_name --netG bFT_unet --dataset_mode texture --input_nc 1 --guide_nc 4 --output_nc 3 --niter 100 --niter_decay 0 --batch_size 256 --lr 0.0002 --use_GAN --netD basic --n_layers 7 --beta1 .9 --checkpoints_dir ./texture_checkpoints

3. Depth Upsampling:

python train.py --dataroot /root/NYU_RGBD_matfiles/ --name exp_name --netG bFT_resnet --dataset_mode depth --input_nc 1     --guide_nc 3 --output_nc 1 --lr 0.0002 --niter 500 --niter_decay 0 --batch_size 2 --checkpoints_dir ./depth_checkpoints --depthTask_scale [4, 8, or 16]

Test

You can specify which epoch to test by specifying --epoch or use the default which is the latest epoch. Results will be saved in --results_dir.

1. Pose transfer:

python test.py --dataroot /root/DeepFashion/ --name exp_name --netG bFT_resnet --dataset_mode pose --input_nc 3 --guide_nc 18 --output_nc 3 --checkpoints_dir ./pose_checkpoints --task pose --results_dir ./pose_results

2. Texture transfer:

python test.py --dataroot /root/training_handbags_pretrain/ --name exp_name --netG bFT_unet --n_layers 7 --dataset_mode texture --input_nc 1 --guide_nc 4 --output_nc 3 --checkpoints_dir ./texture_checkpoints --task texture --results_dir ./texture_results

3. Depth Upsampling:

python test.py --dataroot /root/NYU_RGBD_matfiles/ --name exp_name --netG bFT_resnet --dataset_mode depth --input_nc 1 --guide_nc 3 --output_nc 1 --checkpoints_dir ./depth_checkpoints --task depth  --depthTask_scale [4, 8, or 16] --results_dir ./depth_results

Pretrained checkpoints

  • Download the pretrained checkpoints here.

  • Test: For example, to test the depth upsampling task with scale 16:

python test.py --dataroot /root/NYU_RGBD_matfiles/ --name depth_16 --netG bFT_resnet --dataset_mode depth --input_nc 1 --guide_nc 3 --output_nc 1 --checkpoints_dir ./checkpoints/pretrained/ --task depth  --depthTask_scale 16 --results_dir ./depth_results

Evaluate

You can specify which epoch to evaluate by specifying --epoch or use the default which is the latest epoch. Results will be saved in --results_dir.

1. Pose transfer:
Please note that the inception score evaluation requires tensorflow. We evaluate with tensorflow 1.4.0.

python evaluate.py --dataroot /root/DeepFashion/ --name pose --netG bFT_resnet --dataset_mode pose --input_nc 3 --guide_nc 18 --output_nc 3 --checkpoints_dir ./checkpoints/pretrained/ --task pose --results_dir ./pose_results

This will save the results in --results_dir and compute both SSIM and IS metrics.

2. Texture transfer: Please download the pretrained model of textureGAN in ./resources from bags, shoes, and clothes. For example, to test the pretrained texture transfer model for the bags dataset:

python evaluate.py --dataroot /root/training_handbags_pretrain/ --name texture_bags --netG bFT_unet --n_layers 7 --dataset_mode texture --input_nc 1 --guide_nc 4 --output_nc 3 --checkpoints_dir ./checkpoints/pretrained/ --task texture --results_dir ./texture_results

This will save the output of bFT and textureGAN in --results_dir for 10 random input texture patches per test image. The results can then be used to compute FID and LPIPS.

3. Depth Upsampling:

python evaluate.py --dataroot /root/NYU_RGBD_matfiles/ --name depth_16 --netG bFT_resnet --dataset_mode depth --input_nc 1 --guide_nc 3 --output_nc 1 --checkpoints_dir ./checkpoints/pretrained/ --task depth  --depthTask_scale 16 --results_dir ./depth_results

This will save the results in --results_dir and compute their RMSE metric.

Acknowledgments

This code is heavily borrowed from CycleGAN and pix2pix in PyTorch. We thank Shih-Yang Su for the code review.

guided-pix2pix's People

Contributors

badouralbahar 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

guided-pix2pix's Issues

About the link of pkl format of pose dataset

Hi, thank you for your wonderful contribution!

I recently found that the link of pkl format of the pose dataset here is failed. Could you please re-share the file and update the link?

Thanks a lot for your help:)

A question about the pre-trained model

Hi, thanks a lot for your awesome work.

I downloaded the data of DeepFashion in pickle format, trained the model with the following script as you suggest.

python train.py --dataroot /root/DeepFashion/ --name exp_name --netG bFT_resnet --dataset_mode pose --input_nc 3 --guide_nc 18 --output_nc 3 --lr 0.0002 --niter 100 --niter_decay 0 --batch_size 8 --use_GAN --netD basic --beta1 0.9 --checkpoints_dir ./pose_checkpoints

However, the test results of the trained model don't agree with those generated by your pre-trained model.

the result generated by my model
8

the result generated by your pre-trained model
8

The pre-trained model you provide seems to generate results that are more clear and sharp.

Could you please give me some suggestions? Thanks.

pre-trained model download fail.

Hi, thanks a lot for your work!
i can't download your pre-trained model from your web, maybe it's the problem of my internet. Could you provide a google driver link for the pre-trained model?
Thanks.

depth test output image

hello!! i want to ask the depth output image look like this is correct?i am confuse that it isn't look like with target. i use the pretrain model image

question about data

Hello~
Did you use paird guiding images and source domain images for training?
I want to use my own data to train this network, but I don't know how to prepare the guieded image.

about pose transfer dataset size

Hi,
I want to train the pose transfer use the dataset you provided( here). But when i unzip the dataset, i find it size about 3T. My server does not have such a large memory. So, when you train the pose transfer task, did you use the entire dataset?

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.