anishathalye / neural-style

Neural style in TensorFlow! 🎨
https://anishathalye.com/an-ai-that-can-mimic-any-artist/
GNU General Public License v3.0
5.54k stars 1.52k forks source link

Can't reproduce the same nice result for Example1 #105

Closed ghost closed 6 years ago

ghost commented 6 years ago

After reading the code and readme in this repo, I tried to reproduce the nice result in the readme Example 1

with the simplest command and with all the default parameters as the example 1 told us: python neural_style.py --content examples/1-content.jpg --styles examples/1-style.jpg --output output.jpg

default CONTENT_WEIGHT = 5e0 default STYLE_WEIGHT = 5e2 default ITERATIONS = 1000 , same as exmple 1 used

but I got a very bad result.... and here is it

image

I am using

system & hardware:

python dependencies:

anishathalye commented 6 years ago

How many iterations did you run it for? Is this the result after the 1000 iterations?

anishathalye commented 6 years ago

I just checked out commit b7461815c8fee73199709273c76daf69982db3ec and ran:

python neural_style.py --content examples/1-content.jpg --styles examples/1-style.jpg --output output.jpg

On completion, the resulting losses were:

  content loss: 753232
    style loss: 249069
       tv loss: 51529.7
    total loss: 1.05383e+06

And the resulting image was:

output

ghost commented 6 years ago

I found that it is because my optimization process wasn't going well....... And I tried to cut down my learning rate from 1 to 0.5 but it still didn't work. The content loss is exploding.... the style loss is dropping as we expected. But I used the code at commit b746181 exactly...

Optimization started...
  content loss: 2.13976e+06
    style loss: 1.69467e+10
       tv loss: 26.2307
    total loss: 1.69488e+10
Iteration    1/1000
  content loss: 2.04499e+06
    style loss: 1.68075e+10
       tv loss: 23626.3
    total loss: 1.68096e+10
Iteration    2/1000
  content loss: 2.14448e+06
    style loss: 1.62887e+10
       tv loss: 51806.2
    total loss: 1.62909e+10
Iteration    3/1000
  content loss: 2.71498e+06
    style loss: 1.53005e+10
       tv loss: 87189
    total loss: 1.53033e+10
Iteration    4/1000
  content loss: 3.94074e+06
    style loss: 1.38743e+10
       tv loss: 133313
    total loss: 1.38784e+10
Iteration    5/1000
  content loss: 5.92366e+06
    style loss: 1.21259e+10
       tv loss: 193598
    total loss: 1.2132e+10
Iteration    6/1000
  content loss: 8.7247e+06
    style loss: 1.02663e+10
       tv loss: 270708
    total loss: 1.02753e+10
Iteration    7/1000
  content loss: 1.23115e+07
    style loss: 8.62048e+09
       tv loss: 366224
    total loss: 8.63315e+09
Iteration    8/1000
  content loss: 1.63399e+07
    style loss: 7.49406e+09
       tv loss: 477425
    total loss: 7.51088e+09
Iteration    9/1000
  content loss: 1.98463e+07
    style loss: 6.81471e+09
       tv loss: 592838
    total loss: 6.83515e+09
Iteration   10/1000
  content loss: 2.18546e+07
    style loss: 6.17265e+09
       tv loss: 700191
    total loss: 6.19521e+09

...

Iteration  416/1000
  content loss: 3.46257e+07
    style loss: 6.53368e+07
       tv loss: 2.13957e+06
    total loss: 1.02102e+08
Iteration  417/1000
  content loss: 3.46229e+07
    style loss: 6.52204e+07
       tv loss: 2.13945e+06
    total loss: 1.01983e+08
Iteration  418/1000
  content loss: 3.46203e+07
    style loss: 6.51046e+07
       tv loss: 2.13933e+06
    total loss: 1.01864e+08
Iteration  419/1000
  content loss: 3.46179e+07
    style loss: 6.49893e+07
       tv loss: 2.13921e+06
    total loss: 1.01746e+08

...

Iteration  998/1000
  content loss: 3.34906e+07
    style loss: 3.75992e+07
       tv loss: 2.02291e+06
    total loss: 7.31128e+07
Iteration  999/1000
  content loss: 3.3701e+07
    style loss: 3.77428e+07
       tv loss: 2.0236e+06
    total loss: 7.34674e+07
Iteration 1000/1000
  content loss: 3.33861e+07
    style loss: 3.83473e+07
       tv loss: 2.02196e+06
    total loss: 7.37553e+07
ghost commented 6 years ago

After I upgraded my tensorflow-gpu from version 1.3 to version 1.4. Everything went ok...

So I don't know the reason.........

Many thanks to you!!! Maybe someday I have free hands I would figure out if tensorflow 1.3 has something wrong (at least within this repo's usage)

anishathalye commented 6 years ago

Strange. Glad it's working now though!

On Nov 24, 2017, at 8:26 AM, FredZhang notifications@github.com wrote:

After I upgraded my tensorflow-gpu from version 1.3 to version 1.4. Everything went ok...

So I don't know the reason.........

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.