Style Transfer

This is a reimplentation of the paper "A Neural Algorithm of Artistic Style". It also contains code from some tutorials from PyTorch

Here is a description of my model, I basically implemented the model described in the paper exactly execpt for extra convolution layers and differnt weights

/Users/tusharchopra/anaconda3/envs/194/lib/python3.7/site-packages/ipykernel_launcher.py:7: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
  import sys
/Users/tusharchopra/anaconda3/envs/194/lib/python3.7/site-packages/ipykernel_launcher.py:8: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
  
Sequential(
  (0): Normalization()
  (conv_1): Conv2d(3, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
  (style_loss_1): StyleLoss()
  (relu_1): ReLU()
  (conv_2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
  (style_loss_2): StyleLoss()
  (relu_2): ReLU()
  (pool_2): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
  (conv_3): Conv2d(64, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
  (style_loss_3): StyleLoss()
  (relu_3): ReLU()
  (conv_4): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
  (content_loss_4): TargetLoss()
  (style_loss_4): StyleLoss()
  (relu_4): ReLU()
  (pool_4): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
  (conv_5): Conv2d(128, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
  (style_loss_5): StyleLoss()
  (relu_5): ReLU()
  (conv_6): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
  (style_loss_6): StyleLoss()
)

Here is Neckarfront on the paintings talked about in the paper

/Users/tusharchopra/anaconda3/envs/194/lib/python3.7/site-packages/ipykernel_launcher.py:7: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
  import sys
/Users/tusharchopra/anaconda3/envs/194/lib/python3.7/site-packages/ipykernel_launcher.py:8: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
  
Style Loss : 135.719589 Content Loss: 17.124851

Style Loss : 56.439594 Content Loss: 18.594732

Style Loss : 34.259136 Content Loss: 18.232647

Style Loss : 19.369377 Content Loss: 18.143478

Style Loss : 13.454754 Content Loss: 17.163761

Style Loss : 10.997580 Content Loss: 16.296837

/Users/tusharchopra/anaconda3/envs/194/lib/python3.7/site-packages/ipykernel_launcher.py:7: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
  import sys
/Users/tusharchopra/anaconda3/envs/194/lib/python3.7/site-packages/ipykernel_launcher.py:8: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
  
Style Loss : 167.483582 Content Loss: 28.460068

Style Loss : 43.795071 Content Loss: 27.622587

Style Loss : 28.260818 Content Loss: 26.686825

Style Loss : 21.538427 Content Loss: 25.884457

Style Loss : 17.764509 Content Loss: 25.122017

Style Loss : 15.224660 Content Loss: 24.518545

/Users/tusharchopra/anaconda3/envs/194/lib/python3.7/site-packages/ipykernel_launcher.py:7: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
  import sys
/Users/tusharchopra/anaconda3/envs/194/lib/python3.7/site-packages/ipykernel_launcher.py:8: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
  
Style Loss : 777.696350 Content Loss: 34.598766

Style Loss : 268.949463 Content Loss: 36.544167

Style Loss : 143.272858 Content Loss: 37.106102

Style Loss : 91.121971 Content Loss: 37.678352

Style Loss : 62.752705 Content Loss: 37.828018

Style Loss : 47.883003 Content Loss: 37.678883

Here is my chosen source image translated into other styles. The first example is a failure because the jackson pollock painting has too much stuff going on to find a style. But I still don't understand why it wasn't working for these other ones. It might have something to do with my weights but I tried different ones with no luck

/Users/tusharchopra/anaconda3/envs/194/lib/python3.7/site-packages/ipykernel_launcher.py:7: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
  import sys
/Users/tusharchopra/anaconda3/envs/194/lib/python3.7/site-packages/ipykernel_launcher.py:8: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
  
Style Loss : 236.947556 Content Loss: 69.500816

Style Loss : 66.851616 Content Loss: 64.789406

Style Loss : 28.787498 Content Loss: 59.137032

Style Loss : 17.185259 Content Loss: 54.732437

Style Loss : 12.412126 Content Loss: 51.362961

Style Loss : 10.500034 Content Loss: 48.501236

/Users/tusharchopra/anaconda3/envs/194/lib/python3.7/site-packages/ipykernel_launcher.py:7: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
  import sys
/Users/tusharchopra/anaconda3/envs/194/lib/python3.7/site-packages/ipykernel_launcher.py:8: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
  
Style Loss : 1507.909546 Content Loss: 66.588058

Style Loss : 734.536682 Content Loss: 67.429932

Style Loss : 457.026764 Content Loss: 66.930069

Style Loss : 313.690338 Content Loss: 66.628471

Style Loss : 222.429459 Content Loss: 66.008957

Style Loss : 169.844879 Content Loss: 65.509819

/Users/tusharchopra/anaconda3/envs/194/lib/python3.7/site-packages/ipykernel_launcher.py:7: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
  import sys
/Users/tusharchopra/anaconda3/envs/194/lib/python3.7/site-packages/ipykernel_launcher.py:8: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
  
Style Loss : 303.777588 Content Loss: 51.425346

Style Loss : 152.048447 Content Loss: 50.605000

Style Loss : 97.402428 Content Loss: 49.305698

Style Loss : 68.441444 Content Loss: 47.590904

Style Loss : 49.503593 Content Loss: 45.908508

Style Loss : 36.533173 Content Loss: 44.474304

Lightfield Camera

This project takes the specific qualities of perspectives to simulate the changing of apetures as well as refocusing on the depth. Since things that are closer to you move more relative to things further away when you translate the camera side to side we can average those images to create a fake blur in the foreground. We can also use this to simulate different apertures by blurring different sections of the image, ie blurry foreground for larger apertures and pretty sharp for smaller ones.

/Users/tusharchopra/anaconda3/envs/194/lib/python3.7/site-packages/ipykernel_launcher.py:22: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.

Depth Refocusing

Aperture Adjustment

I'm pretty into photography so I knew how apertures worked before coming into this project but implementing a program to fake different apertures is pretty cool I would say. It reinforces what I know about cameras.