Peking University 2023 Fall Computer Vision Course Final Assignment Project
We recommend you to create your own virtual environment using conda.
pip install -r requirements.txt
Note that you may have to download your corresponding PyTorch version according to your GPU type in order to run our codes on GPUs.
Style images are located in 'styles' folder and content images are located in 'images' folder. The 'goodresults' folder contains some fantastic results generated by our experiments. We welcome you to put your own style and content images into the corresponding folders and make your own creation.
Once you have prepared your own style and content images, change the code snippet below correspondingly in Gatys.py
, Lap.py
or Multi_Style.py
.
Content_Path = "./images/"
Content_Name = "Alps"
Style_Path = './styles/'
Style_Name = "Kandinsky"
Then you can run the code in the shell.
python Gatys.py
python Lap.py
python Multi_Style.py
By the way, if you would like to adjust the blend ratio in multi-style transfer, change the Style_Interpolation
list in Multi_Style.py
.
Content_Path = "./images/"
Content_Name = "pku_snow"
Style_Paths = ['./styles/', './styles/']
Style_Names = ["Kandinsky", 'starry']
Style_Interpolation = [0.9, 0.1]
If you want to check the changing process of the loss function or the synthetic image, you can open the tensorboard tool.
tensorboard --logdir=runs
Paste the url shown in the shell (usually it is http://localhost:6006/
) into your browser and you can see the visual result.