Git Product home page Git Product logo

phdnet-painterly-image-harmonization's Introduction

PHDNet: Painterly Image Harmonization in Dual Domains

This is the official repository for the following paper:

Painterly Image Harmonization in Dual Domains [arXiv]

Junyan Cao, Yan Hong, Li Niu
Accepted by AAAI 2023.

Painterly image harmonization aims to adjust the foreground style of the painterly composite image to make it compatible with the background. A painterly composite image contains a photographic foreground object and a painterly background image.

Our PHDNet is the first feed-forward painterly image harmonization method with released code.

Datesets

Paniterly image harmonization requires two types of images: photographic image and painterly image. We cut a certain object from a photographic image by the corresponding instance mask, and then paste it onto a painterly image, generating a composite image.

Photographic image

We apply images from COCO to produce the foreground objects. For each image, We select the object with foreground ratio in [0.05, 0.3] and generate the forefround mask. The selected foreground masks are provided in selected_masks (access code: ww1t). The training set can be downloaded from COCO_train (alternative: Baidu Cloud (access code: nfsh)) and the test set from COCO_test (alternative: Baidu Cloud (access code: nsvj)).

Painterly image

We apply images from WikiArt to be the backgrounds. The dataset can be downloaded from WikiArt (access code: sc0c). The training/test data list are provided in wikiart_split.

The example dataset dirs:

your_dir
│
└───MS-COCO
│   └───SegmentationClass_select
│   │   │   XXX.png
│   │   │  ...
│   │   
│   └───train2014
│   │   │   XXX.jpg
│   │   │  ...
│   │   
│   └───val2014
│       │   XXX.jpg
│       │  ...
│   
└───wikiart
    └───WikiArt_Split
    │   │   style_class.txt
    │   │   style_train.csv
    │   │   style_val.csv
    │       
    └───unzipped_subfolders

Prerequisites

  • Linux
  • Python 3
  • PyTorch 1.10
  • NVIDIA GPU + CUDA

Getting Started

Installation

  • Clone this repo:
git clone https://github.com/bcmi/PHDNet-Painterly-Image-Harmonization.git
# cd to this repo's root dir
  • Prepare the datasets.

  • Install PyTorch and dependencies from http://pytorch.org.

  • Install python requirements:

pip install -r requirements.txt

PHDNet train/test

  • Train PHDNet:
cd PHDNet/scripts
bash train_phd.sh

The trained model would be saved under ./<checkpoints_dir>/<name>/.

If you want to load a model then continue to train it, add --continue_train and set the --epoch XX in train_phd.sh. It would load the model ./<checkpoints_dir>/<name>/<epoch>_net_G.pth. For example, if the model is saved in ./AA/BB/latest_net_G.pth, the checkpoints_dir should be ../AA/ and the name should be BB. And the epoch should be latest.

Remember to modify the content_dir and style_dir to the corresponding path of each dataset in train_phd.sh.

  • Test PHDNet:
cd PHDNet/scripts
bash test_phd.sh

It would load the model ./<checkpoints_dir>/<name>/<epoch>_net_G.pth then save the visualization under ./<checkpoints_dir>/<name>/web/TestImages/

Our pre-trained model is available on Baidu Cloud (access code: po7q) or Google Drive.

  • Note: <...> means modifiable parameters.

Experimental results

Our method is especially good at handling the background paintings with periodic textures and patterns, because we leverage the information from both spatial domain and frequency domain.

Other Resources

phdnet-painterly-image-harmonization's People

Contributors

cjy-4 avatar ustcnewly 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

phdnet-painterly-image-harmonization's Issues

复现不能达到文章的效果

用项目提供的预训练模型的到的图像,效果很差,带有蓝绿色的噪声纹理,例如:
15971a62a370f6f2b10ee7db5903534
5bd0370da91409d9840157888c992db
不知道问题出现在哪里,能否给予指导

must be fix requirements.txt

  1. py3.10 don't have torch 1.10.2+cu113
  2. remove skimage=0.0 (fixed type)
  3. numpy 1.19.5 is conflicted skimage
  4. there is no pytorch 1.10.2.

i fixed as below and it works

$ pip install numpy
$ pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 torchaudio==0.11.0 --extra-index-url https://download.pytorch.org/whl/cu113
$ pip install -r requirements.txt
dominate==2.6.0
numpy
opencv_python_headless==4.5.5.64
Pillow==9.3.0
PyYAML==6.0
scikit_image==0.17.2
tensorboardX==2.5.1
tqdm==4.64.0
visdom==0.1.8.9
yacs==0.1.8

请问作者们有尝试过增大和谐化图片的尺寸吗?

作者你好,想请问下你们有尝试过增大和谐化图片的尺寸吗?我想在和谐化问题后面接识别和分割的应用,发现大多数的和谐化工作都在256×256的尺寸上进行,实验后resize或者简单超分会导致图片质量非常差,对下游应用来说还不太够用。想请教下作者,这块可以有什么处理思路呢?单纯改卷积尺寸可行吗?

本地图像和谐

作者您好,感谢您的工作,请问是否可以提供用于本地图片和谐的demo呢

Questions regarding download link and input size

Hi,

Thanks for the great work and the results look amazing!

For the pre-trained model here, is it possible to also share it on other platforms such as Google Drive? The Baidu Cloud keeps asking me to download its own app instead of the actual pre-trained model. Much appreaciated!

Also does the code strictly requires square images as input? Or does it work on any arbitrary input image resolutions? Thanks a lot!

downsample method comes from where

Hello, may I ask which part of the code DAT for Paintery Image Harmonization in Dual Domains in the paper comes from or inherits the downsample method in DAT's networks.py? I couldn't find the answer in the code. If you are willing to answer, I would greatly appreciate it.

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.