Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

PITI: Pretraining is All You Need for Image-to-Image Translation

License

NotificationsYou must be signed in to change notification settings

PITI-Synthesis/PITI

Repository files navigation

Official PyTorch implementation

Pretraining is All You Need for Image-to-Image Translation
Tengfei Wang,Ting Zhang,Bo Zhang,Hao Ouyang,Dong Chen,Qifeng Chen,Fang Wen
2022

paper |project website |video |online demo

Introduction

We present a simple and universal framework that brings the power of the pretraining to variousimage-to-image translation tasks. You may try ouronline demo if interested.

Diverse samples synthesized by our approach.

Set up

Installation

git clone https://github.com/PITI-Synthesis/PITI.gitcd PITI

Environment

conda env create -f environment.yml

Quick Start

Pretrained Models

Please download our pre-trained models for bothBase model andUpsample model, and put them in./ckpt.

ModelTaskDataset
Base-64x64Mask-to-ImageTrained on COCO.
Upsample-64-256Mask-to-ImageTrained on COCO.
Base-64x64Sketch-to-ImageTrained on COCO.
Upsample-64-256Sketch-to-ImageTrained on COCO.

If you fail to access to these links, you may alternatively find our pretrained modelshere.

Prepare Images

We put some example images in./test_imgs, and you can quickly try them.

COCO

For COCO dataset, download the images and annotations from theCOCO webpage.

For mask-to-image synthesis, we use the semantic maps in RGB format as inputs. To obtain such semantic maps, run./preprocess/preprocess_mask.py (an example of the raw mask and the processed mask is given inpreprocess/example). Note that we do not need instant masks like previous works.

For sketch-to-image synthesis, we use sketch maps extracted by HED as inputs. To obtain such sketch maps, run./preprocess/preprocess_sketch.py.

Inference

Interactive Inference

Run the following script, and it would create an interactive GUI built by gradio. You can upload input masks or sketches and generate images.

pip install gradiopython inference.py

Batch Inference

Modifysample.sh according to the follwing instructions, and run:

bash sample.sh
ArgsDescription
--model_paththe path of ckpt for base model.
--sr_model_paththe path of ckpt for upsample model.
--val_data_dirthe path of a txt file that contains the paths for images.
--num_samplesnumber of images that you want to sample.
--sample_cStrength of classifier-free guidance.
--modeThe input type.

Training

Preparation

  1. Download and preprocess datasets. For COCO dataset, download the images and annotations from theCOCO webpage. Run./preprocess/preprocess_mask.py or./preprocess/preprocess_sketch.py
  2. Download pretrained models bypython preprocess/download.py.

Start Training

Taking mask-to-image synthesis as an example: (sketch-to-image is the same)

Finetune the Base Model

Modifymask_finetune_base.sh and run:

bash mask_finetune_base.sh

Finetune the Upsample Model

Modifymask_finetune_upsample.sh and run:

bash mask_finetune_upsample.sh

Citation

If you find this work useful for your research, please cite:

@article{wang2022pretraining, title = {Pretraining is All You Need for Image-to-Image Translation},  author = {Wang, Tengfei and Zhang, Ting and Zhang, Bo and Ouyang, Hao and Chen, Dong and Chen, Qifeng and Wen, Fang},  journal={arXiv:2205.12952},  year = {2022},}

Acknowledgement

Thanks forGLIDE for sharing their code.

About

PITI: Pretraining is All You Need for Image-to-Image Translation

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors4

  •  
  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp