Neural Style Transfer using VGG19
Project description
NST_VGG19
Neural Style Transfer using VGG19.
Original paper link.
VGG19 weights from torchvision.
Installation
pip install nst_vgg19
Usage
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:
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.
nst = NST_VGG19(style_image, style_layers_weights=my_weights, delta_loss_threshold=0.001)
result = nst(content_image) # no params except of image
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
nst_vgg19-0.1.9.tar.gz
(6.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nst_vgg19-0.1.9.tar.gz.
File metadata
- Download URL: nst_vgg19-0.1.9.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8fc79451709efe244e6c3ff1c44d5a1036f5d9cdbb7b1e8be4029795900c93d4
|
|
| MD5 |
da07931bf17fd0ac7cc1a51cda89d877
|
|
| BLAKE2b-256 |
11b1a421e85f5e90bd0d4f4e8b7301e4a8640cd7f48d0f30edddc9b541f6fffa
|
File details
Details for the file nst_vgg19-0.1.9-py3-none-any.whl.
File metadata
- Download URL: nst_vgg19-0.1.9-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8df25a64ee24466d857ef6255807403f4af78de5c4e38d734324677f231e30bf
|
|
| MD5 |
4b53dd7e5e5b98154c0e0cff5416f174
|
|
| BLAKE2b-256 |
da876fe23b898bbffb67129774b6bd1775484256abda20386a84267b9d79672e
|