summaryrefslogtreecommitdiff
path: root/README.md
blob: 936a95aa011d865ad6e6f7c8039c71e74f603edb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# neural-art

Neural Style Transfer done from the CLI using a VGG backbone and presented as an MP4.

Weights can be downloaded from [here](https://files.catbox.moe/wcao20.pth). The downloaded file (renamed to `vgg_conv_weights.pth`) should be placed in `./weights/` and it will be ignored when pushing, as seen in `./.gitignore`. Update: Alternatively, if the `./weights/` directory is empty, `./neuralart.py` will automatically download publicly available VGG19 weights for the user.

More in depth information about Neural Style Transfer ( NST ) can be found in this great [paper](https://arxiv.org/abs/1705.04058). Make sure to check [Requirements](#requirements) and [Usage](#usage).

### Why use this in 2023 ?

Because Style Transfer hasn't changed drastically in terms of actual results in the past years. I personally find a certain beauty in inputting a style and content image rather than a well curated prompt with a dozen of switches. Consider this repo as a quick and simple ***just works*** solution that can run on both CPU and GPU effectively.

I developed this tool as a means to obtain fancy images and visuals for me and my friends. It somehow grew into something bigger that is actually usable, so much so that I got to integrate it in a workflow in conjunction with [Stable Diffusion](https://github.com/CompVis/stable-diffusion) ( see also [here](https://github.com/AUTOMATIC1111/stable-diffusion-webui) ).

## Requirements

Clone the repository:

```bash
git clone https://github.com/xAlpharax/neural-art
```

Create a virtual environment to separate the required packages from system-wide packages:

```bash
virtualenv path/to/neural-art

source path/to/neural-art/bin/activate
```

( ! ) When you're finished with the environment:

```bash
# deactivate
```

All the required packages are listed in `./requirements.txt` as per python etiquette:

```bash
pip install -r requirements.txt
```

## Usage

The main script sits comfortably in `./stylize.sh` so run it from the project's directory:

```bash
./stylize.sh path/to/style_image path/to/content_image
```

A helper script is also available to run `./stylize.sh` for each distinct pair of images present in the `./Images/` directory:

```bash
./all.sh
```

Moreover, `./all.sh` is aware of the already rendered mp4 files and will skip stylizing the combinations that are already present.

### Output videos / images and temporary files

If, at any point, curious of the individual frames that comprise the generated `./content_in_style.mp4` check `./Output/` for PNG images with exactly that. Keep in mind that these files get removed and overwritten each time ./stylize.sh is called ( this is also why running multiple instances of `./stylize.sh` is advised against; if you need to batch/automate the process, try `./all.sh`)

The `./images.npy` file contains raw numpy array data generated by `./neuralart.py` and is manipulated by `./renderer.py` to achieve the `./Output` directory of PNG images.

Considering this workflow, `./clear_dir.sh` removes temporary files each time a new call to `./stylize.sh` is made.

## Contributing

Any sort of help, especially regarding the QoS ( Quality of Service ) of the project, is appreciated. Feel free to open an issue in the **Issues** tab and discuss the possible changes there. As of now, **neural-art** would be in great need of a clean and friendly arguments handler ( i.e. the one the `argparse` python package provides ) in order to accommodate to a cleaner interface for `./neuralart.py` and / or `./stylize.sh`.

Thank you. Happy neural-art-ing !