https://github.com/sonhm3029/neural-style-transfer-pytorch
This project is basic neural style transfer implement with pytorch
https://github.com/sonhm3029/neural-style-transfer-pytorch
Last synced: 3 months ago
JSON representation
This project is basic neural style transfer implement with pytorch
- Host: GitHub
- URL: https://github.com/sonhm3029/neural-style-transfer-pytorch
- Owner: sonhm3029
- Created: 2023-03-26T10:16:53.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2023-09-04T08:48:48.000Z (almost 2 years ago)
- Last Synced: 2025-01-17T01:24:08.763Z (5 months ago)
- Language: Jupyter Notebook
- Size: 12.8 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Neural-style-transfer-pytorch
## Overview
### 1. Build model to extract features
- Using pretrained VGG19 model
- Using only layer index 0, 5, 10, 19, 28### 2. Load images
- Load content image
- Load style image
- Generate random white noise target image=> Resize style and target image to size of content image

### 3. Init hyperparameters and optimizer:
- style_weight: 1000,
- content_weight: 1,
- learning_rate: 0.001
- epochs: 6000Using Adam optimizer with parameters is target_images
### 4. Training:
- Calculate content loss
$$content\_loss = \frac{1}{2}(content\_img - target\_img)^2$$
- Calculate style loss:
Gram matrix:
$$G = \frac{1}{c*h*w}(target\_img.target\_img^T)$$
$$A = \frac{1}{c*h*w}(style\_img.style\_img^T)$$
$$style\_loss = \frac{1}{2*c*h*w}.(G - A)^2$$