Neural Style Transfer using VGG19
Project description
NST_VGG19
Neural Style Transfer using VGG19.
Original paper https://www.cv-foundation.org/openaccess/content_cvpr_2016/papers/Gatys_Image_Style_Transfer_CVPR_2016_paper.pdf
VGG19 weights from torchvision.
Installation
pip install nst_vgg19
Usage
from nst_vgg19 import NST_VGG19
import cv2
def load_image(path):
img = cv2.imread(path)
return cv.cvtColor(style_image, cv2.COLOR_BGR2RGB) # cv2 loads BGR by default so we convert
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)
cv2.imwrite('result1.png', cv2.cvtColor(result_1, cv2.COLOR_RGB2BGR))
cv2.imwrite('result2.png', cv2.cvtColor(result_2, cv2.COLOR_RGB2BGR))
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
delta_loss_threshold=1
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
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.2.tar.gz.
File metadata
- Download URL: nst_vgg19-0.1.2.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e19b447f184d934274d603cfdbb5bbf780c9596ed6c3b39f36bb4cc7fc7593c
|
|
| MD5 |
40e93f17ff93805e8ce54b752c5f5d17
|
|
| BLAKE2b-256 |
f412d19e37a9f4018737634580efa02bb589229e86a3c61de7e1dbf98bb63cfe
|
File details
Details for the file nst_vgg19-0.1.2-py3-none-any.whl.
File metadata
- Download URL: nst_vgg19-0.1.2-py3-none-any.whl
- Upload date:
- Size: 5.8 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 |
021672bb55f6fd158dd65be4fa753505ba68851229997ab34706844a4cb1cb2c
|
|
| MD5 |
b781812b97c2a12f3e1ac33b165b8cee
|
|
| BLAKE2b-256 |
5ee4de462ac882480d179e66849db4708b8b79d30e535ea8cade59cd2b1af891
|