Neural Style Transfer
Content | Style | Output |
---|---|---|
Description:
This script runs neural style transfer against the provided content image. The content image must be present in the src/data/content
directory. All style images, that are in the directory src/data/style
will be applied against it. The outputs will be saved in generated/
directory as .png
files. By default, the input images (both style and content images, as they must be of the same dimensionality) will be transformed to the 512x512
size for the algorithm, and output image will be of size 512x512
as well. To change that, please use additional script arguments.
The neural networks architecture is based on the documentation provided by PyTorch, which itself uses Neural-Style algorithm developed by Leon A. Gatys, Alexander S. Ecker and Matthias Bethge.
Usage examples:
./main.py -i
./main.py --image
python3 main.py -i
python3 main.py --image
./main.py -i
-he 1024 -wi 1024 ./main.py --image
-height 1024 -width 1024
Script arguments:
Required arguments:
-i IMAGE, --image IMAGE
Content image to be taken as input. The file must be present in src/data/content.
Optional arguments:
-h, --help Show help message and exit.
-he HEIGHT, --height HEIGHT
Sets the height of the input and output images. The default value is 512.
-wi WIDTH, --width WIDTH
Sets the width of the input and output images. The default value is 512.
Setup
Python 3.9 must be installed on the operating system. To install the needed python dependencies run:
pip3 install -r requirements.txt
To run the script as ./main.py -i
or to run the linter script, one might need to give executable permissions:
chmod -x main.py
chmod -x ./scripts/lint.sh
To run the black
formatter and pylint
linter, please run:
./scripts/lint.sh
The script ./scripts/lint_check.sh
will be run as GitHub action, and will fail if any possible changes are detected.