Metadata-Version: 2.1
Name: nst_vgg19
Version: 0.1.7
Summary: Neural Style Transfer using VGG19
Home-page: https://github.com/alexanderbrodko/nst_vgg19
Author: Alexander Brodko
Author-email: xjesus666@yandex.ru
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: torch >=1.13
Requires-Dist: torchvision >=0.14
Requires-Dist: numpy
Requires-Dist: gdown

# NST_VGG19

Neural Style Transfer using VGG19.

Original paper [link](https://www.cv-foundation.org/openaccess/content_cvpr_2016/papers/Gatys_Image_Style_Transfer_CVPR_2016_paper.pdf).

VGG19 weights from `torchvision`.

## Installation

```bash
pip install nst_vgg19
```

## Usage

```python
from nst_vgg19 import NST_VGG19

# images must be Numpy arrays. Use np.array(pil_image)

style_image = load_image('style.png')
content_image_1 = load_image('img1.jpg')
content_image_2 = load_image('img2.png')

nst = NST_VGG19(style_image)

result_1 = nst(content_image_1)
result_2 = nst(content_image_2)
```

## NST_VGG19 constructor options

* style_image_numpy: Numpy array of the style image in format (Heght, Width, Channels). This is a default Numpy image array.
* content_layers_weights: Dictionary of weights for content losses.
* style_layers_weights: Dictionary of weights for style losses.
* quality_loss_weight: Weight for quality loss.
* delta_loss_threshold: Loss change threshold for stopping optimization.

If you do not specify weights of loss, the folowing parameters will be used:

```python
DEFAULT_CONTENT_WEIGHTS = {
    'conv_1': 35000,  # Shape?
    'conv_2': 28000,
    'conv_4': 30000,
}
DEFAULT_STYLE_WEIGHTS = {
    'conv_2': 0.000001,  # Light/shadow?
    'conv_4': 0.000009,  # Contrast?
    'conv_5': 0.000006,  # Volume?
    'conv_7': 0.000003,
    'conv_8': 0.000002,  # Dents?
    'conv_9': 0.000003
}
quality_loss_weight=2e-4
```

If optimization delta becomes less than `delta_loss_threshold` then style transfer stops.


```python
nst = NST_VGG19(style_image, style_layers_weights=my_weights, delta_loss_threshold=0.001)

result = nst(content_image) # no params except of image
```
