Chinese Landscape Painting style transfer by adversarial network.
The code was tested with Anaconda and Python 3.7. After installing the Anaconda environment:
-
Clone the repo:
git clone https://github.com/Robin-WZQ/Chinese-Landscape-Painting-Style-Transfer.git cd Chinese-Landscape-Painting-Style-Transfer
-
Install dependencies:
For PyTorch dependency, see pytorch.org for more details.
For custom dependencies:
pip install -r requirements.txt
-
Download pretrained model from BaiduYun extract code: qls1
I trained the model for 100 epoches.
-
Pre-process the dataset
python canny.py python picture2texture.py python process_all.py
-
Configure your dataset and pretrained model path in opts.py.
To train the model, please do:
python pix2pix.py
To do a style trasfer, please do:
python test.py
-
In the folder UI, I make a simple interactive interface by tkinter.
This is a separate folder. Do not use it in the same directory as other folders!!
To run the DEMO, please do:
python UI/UI.py
I used the dataset from here
Dataset directory tree is shown below
- Alice
Make sure to put the files as the following structure:
Alice ├── Harvard │ ├── Harvard_0.jpg │ └── ... ├── met-1 │ ├── met_0.jpg │ └── ... └── met-2 │ ├── met-221.jpg │ └── ...
Also, I graped some pictures(nearly 800) from website and I added these pictures into the Alice dataset. U can run tools/Web_Spider.py to generate you own dataset. (And modify names in tools/name.txt)
After preprocessing, it will generate 3 dataset:
- processed by canny (I use Histogram Equalization for image enhancement first), like:
These models were trained in machine with NVIDIA TITAN X 11gb GPU. I trained it in 100 epoches and bachsize is 1. More details please see in my code.