moritztng / prism

High Resolution Style Transfer in PyTorch with Color Control and Mixed Precision :art:
MIT License
108 stars 19 forks source link
controlling-perceptual-factors high-resolution mixed-precision pytorch style-transfer

Installation

pip install git+https://github.com/moritztng/prism.git

Quickstart

Open in Colab Read the Docs

Minimal Example

style-transfer content.jpg style.jpg

Complex Example

style-transfer content.jpg style.jpg --artwork artwork.png --style_weight 1000 --lr 1 --iter 500
Content Style
Artwork

Features

High Resolution

# Create low-resolution artwork with area of 512 * 512. 
style-transfer content.jpg style.jpg
# Initialize with low-resolution artwork to create artwork with area of 1024 * 1024. 
style-transfer content.jpg style.jpg --init_img artwork.png --area 1024 --iter 200

Mixed Precision

Faster training, less memory, same quality on GPUs.

style-transfer content.jpg style.jpg --use_amp

Preserve Content Color

style-transfer content.jpg style.jpg --preserve_color content

Python Object

from PIL import Image
from style_transfer.learn import StyleTransfer

style_transfer = StyleTransfer()
artwork = style_transfer(Image.open('content.jpg'), Image.open('style.jpg'))
artwork.save('artwork.png')

Shop

The shop was based on this implementation and customers ordered canvas prints there.

https://user-images.githubusercontent.com/19519902/182423297-f9fa1e12-691a-43f3-ab5a-6f51c24161af.mp4

Canvas Prints

Moritz Max

References