albarji / neural-style-docker

A dockerized version of neural style transfer algorithms
MIT License
112 stars 34 forks source link

Infinite loop #31

Closed asmarcz closed 4 years ago

asmarcz commented 4 years ago

Hello, I have run the following command:

nvidia-docker run --rm -v $(pwd):/images albarji/neural-style --content a.jpg --style starry_night.jpg
INFO:__main__:Running neural style transfer with
INFO:__main__:  Contents = ['/images/a.jpg']
INFO:__main__:  Style = ['/images/starry_night.jpg']
INFO:__main__:  Algorithm = gatys
INFO:__main__:  Style weights = None
INFO:__main__:  Style scales = None
INFO:__main__:  Size = None
INFO:__main__:  Tile overlap = None
WARNING:neuralstyle.algorithms:Unknown GPU model GeForce GT 740M, will use default tiling parameters
INFO:neuralstyle.algorithms:Starting tiling strategy

But I noticed that even after an hour, I just keep getting the same snippet below again and again. What am I doing wrong? Thanks.

Capturing style target 1    
Running optimization with L-BFGS    
<optim.lbfgs>   creating recyclable direction/step/history buffers  
Iteration 50 / 500  
  Content 1 loss: 29657681.250000   
  Style 1 loss: 144376.129150   
  Style 2 loss: 1487927.246094  
  Style 3 loss: 190458.267212   
  Style 4 loss: 1219033.325195  
  Style 5 loss: 1532.736421 
  Total loss: 32701008.954072   
Iteration 100 / 500 
  Content 1 loss: 31124437.500000   
  Style 1 loss: 94640.571594    
  Style 2 loss: 1027202.392578  
  Style 3 loss: 108359.451294   
  Style 4 loss: 576966.369629   
  Style 5 loss: 1136.814833 
  Total loss: 32932743.099928   
Iteration 150 / 500 
  Content 1 loss: 31253296.875000   
  Style 1 loss: 76798.995972    
  Style 2 loss: 905816.040039   
  Style 3 loss: 87324.279785    
  Style 4 loss: 452157.165527   
  Style 5 loss: 1016.887546 
  Total loss: 32776410.243869   
Iteration 200 / 500 
  Content 1 loss: 31234756.250000   
  Style 1 loss: 64344.253540    
  Style 2 loss: 822931.945801   
  Style 3 loss: 73042.816162    
  Style 4 loss: 430686.553955   
  Style 5 loss: 952.963293  
  Total loss: 32626714.782751   
Iteration 250 / 500 
  Content 1 loss: 31371515.625000   
  Style 1 loss: 53600.486755    
  Style 2 loss: 756833.923340   
  Style 3 loss: 61470.520020    
  Style 4 loss: 350649.505615   
  Style 5 loss: 912.382960  
  Total loss: 32594982.443690   
Iteration 300 / 500 
  Content 1 loss: 70149740953600.000000 
  Style 1 loss: 267245733281792000.000000   
  Style 2 loss: 112462266946813952000.000000    
  Style 3 loss: 89906988493832192000.000000 
  Style 4 loss: 2284352504692998144000.000000   
  Style 5 loss: 17663113822208000.000000    
  Total loss: 2487006739130488979456.000000 
Iteration 350 / 500 
  Content 1 loss: 53824475.000000   
  Style 1 loss: 285575.195312   
  Style 2 loss: 4403482.910156  
  Style 3 loss: 1467386.352539  
  Style 4 loss: 34660351.562500 
  Style 5 loss: 6897.786140 
  Total loss: 94648168.806648   
Iteration 400 / 500 
  Content 1 loss: 44946846.875000   
  Style 1 loss: 50263.446808    
  Style 2 loss: 572598.754883   
  Style 3 loss: 98170.982361    
  Style 4 loss: 665762.390137   
  Style 5 loss: 1197.893023 
  Total loss: 46334840.342212   
Iteration 450 / 500 
  Content 1 loss: 42118831.250000   
  Style 1 loss: 32140.338898    
  Style 2 loss: 541359.375000   
  Style 3 loss: 62662.532806    
  Style 4 loss: 392539.367676   
  Style 5 loss: 934.317052  
  Total loss: 43148467.181432   
Iteration 500 / 500 
  Content 1 loss: 40941896.875000   
  Style 1 loss: 24490.972519    
  Style 2 loss: 549065.734863   
  Style 3 loss: 50130.981445    
  Style 4 loss: 295060.028076   
  Style 5 loss: 837.709486  
  Total loss: 41861482.301390   
<optim.lbfgs>   reached max number of iterations    
INFO:neuralstyle.algorithms:Running command: cd /app/neural-style; th neural_style.lua -backend cudnn -cudnn_autotune -normalize_gradients -init image -content_weight 100 -save_iter 10000 -proto_file /app/neural-style/models/VGG_ILSVRC_19_layers_deploy.prototxt -model_file /app/neural-style/models/VGG_ILSVRC_19_layers.caffemodel -num_iterations 500 -content_image /tmp/tmpw8hhbycw/rgb.png -style_image /tmp/tmpw8hhbycw/style.png -style_weight 500.0 -style_scale 1.0 -output_image /tmp/tmpzst_vto1.png -image_size 474
tput: No value for $TERM and no -T specified
[libprotobuf WARNING google/protobuf/io/coded_stream.cc:537] Reading dangerously large protocol message.  If the message turns out to be larger than 1073741824 bytes, parsing will be halted for security reasons.  To increase the limit (or to disable these warnings), see CodedInputStream::SetTotalBytesLimit() in google/protobuf/io/coded_stream.h.
[libprotobuf WARNING google/protobuf/io/coded_stream.cc:78] The total number of bytes read was 574671192
Successfully loaded /app/neural-style/models/VGG_ILSVRC_19_layers.caffemodel
conv1_1: 64 3 3 3
conv1_2: 64 64 3 3
conv2_1: 128 64 3 3
conv2_2: 128 128 3 3
conv3_1: 256 128 3 3
conv3_2: 256 256 3 3
conv3_3: 256 256 3 3
conv3_4: 256 256 3 3
conv4_1: 512 256 3 3
conv4_2: 512 512 3 3
conv4_3: 512 512 3 3
conv4_4: 512 512 3 3
conv5_1: 512 512 3 3
conv5_2: 512 512 3 3
conv5_3: 512 512 3 3
conv5_4: 512 512 3 3
fc6: 1 1 25088 4096
fc7: 1 1 4096 4096
fc8: 1 1 4096 1000
Setting up style layer      2   :   relu1_1 
Setting up style layer      7   :   relu2_1 
Setting up style layer      12  :   relu3_1 
Setting up style layer      21  :   relu4_1 
Setting up content layer    23  :   relu4_2 
Setting up style layer      30  :   relu5_1 
Capturing content targets   
nn.Sequential {
  [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> (10) -> (11) -> (12) -> (13) -> (14) -> (15) -> (16) -> (17) -> (18) -> (19) -> (20) -> (21) -> (22) -> (23) -> (24) -> (25) -> (26) -> (27) -> (28) -> (29) -> (30) -> (31) -> (32) -> (33) -> (34) -> (35) -> (36) -> (37) -> output]
  (1): nn.TVLoss
  (2): cudnn.SpatialConvolution(3 -> 64, 3x3, 1,1, 1,1)
  (3): cudnn.ReLU
  (4): nn.StyleLoss
  (5): cudnn.SpatialConvolution(64 -> 64, 3x3, 1,1, 1,1)
  (6): cudnn.ReLU
  (7): cudnn.SpatialMaxPooling(2x2, 2,2)
  (8): cudnn.SpatialConvolution(64 -> 128, 3x3, 1,1, 1,1)
  (9): cudnn.ReLU
  (10): nn.StyleLoss
  (11): cudnn.SpatialConvolution(128 -> 128, 3x3, 1,1, 1,1)
  (12): cudnn.ReLU
  (13): cudnn.SpatialMaxPooling(2x2, 2,2)
  (14): cudnn.SpatialConvolution(128 -> 256, 3x3, 1,1, 1,1)
  (15): cudnn.ReLU
  (16): nn.StyleLoss
  (17): cudnn.SpatialConvolution(256 -> 256, 3x3, 1,1, 1,1)
  (18): cudnn.ReLU
  (19): cudnn.SpatialConvolution(256 -> 256, 3x3, 1,1, 1,1)
  (20): cudnn.ReLU
  (21): cudnn.SpatialConvolution(256 -> 256, 3x3, 1,1, 1,1)
  (22): cudnn.ReLU
  (23): cudnn.SpatialMaxPooling(2x2, 2,2)
  (24): cudnn.SpatialConvolution(256 -> 512, 3x3, 1,1, 1,1)
  (25): cudnn.ReLU
  (26): nn.StyleLoss
  (27): cudnn.SpatialConvolution(512 -> 512, 3x3, 1,1, 1,1)
  (28): cudnn.ReLU
  (29): nn.ContentLoss
  (30): cudnn.SpatialConvolution(512 -> 512, 3x3, 1,1, 1,1)
  (31): cudnn.ReLU
  (32): cudnn.SpatialConvolution(512 -> 512, 3x3, 1,1, 1,1)
  (33): cudnn.ReLU
  (34): cudnn.SpatialMaxPooling(2x2, 2,2)
  (35): cudnn.SpatialConvolution(512 -> 512, 3x3, 1,1, 1,1)
  (36): cudnn.ReLU
  (37): nn.StyleLoss
}
albarji commented 4 years ago

Hi there! You are probably not doing anything wrong... it's just the algorithm is quite slow.

Since you are using a GPU model that the code wasn't prepared for, it's using some pretty conservative tiling parameters. So probably your image is being split into many small tiles, and the style transfer algorithm is being run over each one of those tiles.

I would recommend trying again with a smaller image and see if everything works out. If it does, then you know the algorithm is working fine, you will just need to wait longer for the larger image.

asmarcz commented 4 years ago

It indeed was just slow. :) It may have occurred to me that processing two 4K images is not going to perform well. (: Thank you.