Code Monkey home page Code Monkey logo

Comments (13)

titu1994 avatar titu1994 commented on July 28, 2024

@7yl4r The last commit did change the behaviour of the maintain_aspect_ratio parameter, but I made it so that the image that is generated at the end of the script will always maintain the aspect ratio of the original content image. The parameter now acts as a flag to load a 400x640 image (if set to 1) or else a 400x400 image as the content and style image (assuming that image_size = 400)

The replacement of if maintain_aspect_ratio and (not rescale_image) with if not rescale_image basically means that if you aren't going to upscale the image to the original dimensions (say 1080p using bicubic upsampling), then at least maintain the aspect ratio (say 400x640)

Simply put, as long as you aren't providing a square image and aren't upscaling to full size of the original image, it should maintain the aspect ratio in the generated image. Can you provide me with some sample content images on which I can test this?

from neural-style-transfer.

7yl4r avatar 7yl4r commented on July 28, 2024

Here is what I get from the first iteration of

python INetwork.py --image_size 200 ./images/inputs/content/tubingen.jpg ./images/inputs/style/starry_night.jpg ./test

test_at_iteration_1

from neural-style-transfer.

titu1994 avatar titu1994 commented on July 28, 2024

Can you see if there is a line such as "Rescaling Image to (400, 640)" after each iteration ?

from neural-style-transfer.

titu1994 avatar titu1994 commented on July 28, 2024

Try with the argument : --rescale_image "False"

from neural-style-transfer.

7yl4r avatar 7yl4r commented on July 28, 2024

from neural-style-transfer.

titu1994 avatar titu1994 commented on July 28, 2024

Can you copy paste the Network.py and INetwork.py code from the repo into your local copies and run it again? Because this is the results I am getting :

"D:/Users/Yue/PycharmProjects/Neural Style Transfer/INetwork.py" D:\Yue\Pictures\hoovertowernight.jpg D:\Yue\Pictures\Art\starry_night.jpg "D:\Yue\Desktop\Neural Art\test" --image_size 200

Model loaded.
Starting iteration 1 of 10
Current loss value: 135229216.0  Improvement : 0.000 %
Rescaling Image to (200, 380)
Image saved as D:\Yue\Desktop\Neural Art\test_at_iteration_1.png

test_at_iteration_1

from neural-style-transfer.

7yl4r avatar 7yl4r commented on July 28, 2024

I have cloned the repo through git, and git status shows no changes from master. Adding --rescale_image "False" didn't have an effect.

from neural-style-transfer.

titu1994 avatar titu1994 commented on July 28, 2024

Well that is weird. The same code having different results ? What is your python version? 2.7 ?

There shouldn't be any difference in calculating the aspect ratio between python 3 and 2 though

from neural-style-transfer.

7yl4r avatar 7yl4r commented on July 28, 2024

Python version 2.7.12. I'm going to add some print statements and see if I can find what is going on and I'll get back to you.

from neural-style-transfer.

titu1994 avatar titu1994 commented on July 28, 2024

Yes thanks for that. Also, try adding the original line if maintain_aspect_ratio and (not rescale_image) to see if it makes any difference.

from neural-style-transfer.

7yl4r avatar 7yl4r commented on July 28, 2024

I believe I've identified the issue and suggested a fix. aspect_ratio was being calculated using integer math, so I've suggested a cast to force floating point computation. I'm guessing the difference has to do with how command line vars are evaluated on windows vs linux.

from neural-style-transfer.

titu1994 avatar titu1994 commented on July 28, 2024

Oh ! Nice catch. If you wish to be credited for the fix, could you create a pull request ?

from neural-style-transfer.

titu1994 avatar titu1994 commented on July 28, 2024

Thanks for the fix !

from neural-style-transfer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.