Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/matthias-wright/siamese_architecture
PyTorch implementation of the siamese architecture for style transfer I developed for my master's thesis.
https://github.com/matthias-wright/siamese_architecture
autoencoder deep-learning generative-adversarial-network python pytorch style-transfer
Last synced: 3 days ago
JSON representation
PyTorch implementation of the siamese architecture for style transfer I developed for my master's thesis.
- Host: GitHub
- URL: https://github.com/matthias-wright/siamese_architecture
- Owner: matthias-wright
- Created: 2019-11-23T12:33:30.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-05-12T11:56:21.000Z (almost 4 years ago)
- Last Synced: 2024-12-14T20:07:50.811Z (about 2 months ago)
- Topics: autoencoder, deep-learning, generative-adversarial-network, python, pytorch, style-transfer
- Language: Python
- Homepage:
- Size: 27.1 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# A Siamese Architecture for Neural Style Transfer
The implementation of the siamese architecture that I developed for my master's thesis.## Dependencies
* Python 3.5.2+
* NumPy 1.11.0+
* PyTorch 0.4.1+
* PIL 1.1.7+
* Matplotlib 3.0.1+## Example
![]()
## Instructions
### Training
```python
import siamesedata_photo = '...' # file path to the photograph images (RGB) folder
data_oil = '...' # file path to the oil images (RGB) folder
siam_model = siamese.Siamese(in_path_photo=data_photo,
in_path_oil=data_oil,
autoencoder_path='saves/autoencoders',
num_epochs=100, batch_size=50,
learning_rate=0.0002,
recon_loss_weight=10,
penalty_coef=10, verbose=True)
siam_model.train()
```### Load Pretrained Model
```python
import siamesedata_photo = '...' # file path to the photograph images (RGB) folder
data_oil = '...' # file path to the oil images (RGB) folder
siam_model = siamese.Siamese(in_path_photo=data_photo,
in_path_oil=data_oil,
autoencoder_path='saves/autoencoders',
num_epochs=100, batch_size=50,
learning_rate=0.0002,
recon_loss_weight=10,
penalty_coef=10, verbose=True)siam_model.load(epoch=18, path='saves')
```### Style Transfer
```python
import siamese
import utilsiam_model = siamese.Siamese(autoencoder_path='saves/autoencoders')
siam_model.load(epoch=18, path='saves')x_photo = util.image_to_tensor('image.jpg')
x_oil = siam_model.translate_photo_to_oil(x_photo)
x_oil = util.tensor_to_numpy(x_oil)
x_oil = util.numpy_to_image(x_oil)
x_oil.save('stylized_image.png')
```## License
This project is licensed under the [MIT Licence](https://choosealicense.com/licenses/mit/)