GithubHelp home page GithubHelp logo

Comments (18)

abhiskk avatar abhiskk commented on August 12, 2024
  1. The --image-size --style-size determine the image sizes of content image and style image. They will resize the input images to the value in --image-size and --style-size parameters.
  2. The output image size will be same as the input image size by default, if you are feeding in a really large image then I have added a command line parameter here , using which you can reduce the size of the output styled image, for eg setting --content-scale will produce an output image which is half the size of the input image.
  3. πŸ˜ƒ

from fast-neural-style.

dovanchan avatar dovanchan commented on August 12, 2024

If I wanna use it to make a ios app like prisma in production enviroment,Can you give me some advices for reducing memory usage.I found pytorch's implement is better than tensorflow in fast-neural-style

from fast-neural-style.

abhiskk avatar abhiskk commented on August 12, 2024

I would suggest looking into using Caffe2 for that. You should be able to load the pytorch model in Caffe2 directly, you will have to convert weights to numpy and then load it in Caffe2. Then I think you can follow this tutorial to build an app for that.

from fast-neural-style.

dovanchan avatar dovanchan commented on August 12, 2024

When I try eval,I get a error(python2.7)

Dovan-Rmbp:fast-neural-style DOVAN$ time python neural_style/neural_style.py eval --content-image /Users/DOVAN/Desktop/[email protected] --model /Users/DOVAN/deeprely/fast-neural-style/saved-models/udnie.pth --output-image /Users/DOVAN/Desktop/ --cuda 0
Traceback (most recent call last):
File "neural_style/neural_style.py", line 210, in
main()
File "neural_style/neural_style.py", line 206, in main
stylize(args)
File "neural_style/neural_style.py", line 135, in stylize
content_image = Variable(utils.preprocess_batch(content_image), volatile=True)
File "/Users/DOVAN/deeprely/fast-neural-style/neural_style/utils.py", line 59, in preprocess_batch
(r, g, b) = torch.chunk(batch, 3)
ValueError: need more than 2 values to unpack

Can you tell me how to fix it

from fast-neural-style.

abhiskk avatar abhiskk commented on August 12, 2024

I just tested the implementation again on python 2.7 and it works. Can you try and install pytorch again in a clean environment using conda following the instructions from the pytorch site.

from fast-neural-style.

abhiskk avatar abhiskk commented on August 12, 2024

Actually I think it's an issue with loading .png images, I think it will work well for .jpg images. Similar issue was reported on the pytorch/examples version of this repo.
ref: pytorch/examples#171

from fast-neural-style.

dovanchan avatar dovanchan commented on August 12, 2024

@abhiskk Hi,I have tried the jpg. But I still get this error:

Dovan-Rmbp:fast-neural-style DOVAN$ time python neural_style/neural_style.py eval --content-image /Users/DOVAN/Desktop/[email protected] --model /Users/DOVAN/deeprely/fast-neural-style/saved-models/udnie.pth --output-image /Users/DOVAN/Desktop/ --cuda 0
Traceback (most recent call last):
File "neural_style/neural_style.py", line 210, in
main()
File "neural_style/neural_style.py", line 206, in main
stylize(args)
File "neural_style/neural_style.py", line 135, in stylize
content_image = Variable(utils.preprocess_batch(content_image), volatile=True)
File "/Users/DOVAN/deeprely/fast-neural-style/neural_style/utils.py", line 59, in preprocess_batch
(r, g, b) = torch.chunk(batch, 3)
ValueError: need more than 2 values to unpack

I think this may be come from the Function parameters' error

from fast-neural-style.

abhiskk avatar abhiskk commented on August 12, 2024

@dovanchan what environment are you running this on, I just tested this implementation on python 2.7, on OSX and everything works well.

from fast-neural-style.

dovanchan avatar dovanchan commented on August 12, 2024

python2.7 on OSX 0.12.5 The same as you~

from fast-neural-style.

dovanchan avatar dovanchan commented on August 12, 2024

I am also used conda install pytorch ~

from fast-neural-style.

abhiskk avatar abhiskk commented on August 12, 2024

Are you sure you didn't edit anything, can you try re-cloning the repository and running it again, it should be working. Another option is to try it in python 3, if it fails in that also then something weird is happening. Also are you using --cuda 1 while running the stylizing code, pytorch's GPU version on OSX can misbehave. Try running with --cuda 0.

from fast-neural-style.

dovanchan avatar dovanchan commented on August 12, 2024

image

This is my enviroment,I dont have change any setting,the same as you(python2.7 --cuda 0 ) I think may be because I am using the latest pytorch version?

from fast-neural-style.

abhiskk avatar abhiskk commented on August 12, 2024

yes that could be an issue, don't use the master version of pytorch right now, it's unstable I think because they are implementing numpy type indexing. Are you using this command to install pytorch:
conda install pytorch torchvision -c soumith ?

from fast-neural-style.

dovanchan avatar dovanchan commented on August 12, 2024

Yes,I am using conda install pytorch torchvision -c soumith ~

from fast-neural-style.

abhiskk avatar abhiskk commented on August 12, 2024

Please follow the following steps accurately, use the default image in the repository for stylizing. I just followed the steps listed below one by one and was able to run it successfully.

  • Create new conda environment: conda create --name fnstest python=2.7
  • Activate environment: source activate fnstest
  • Install pytorch on OSX: conda install pytorch torchvision -c soumith
  • Clone repository: git clone https://github.com/abhiskk/fast-neural-style.git
  • Go inside the directory: cd fast-neural-style/
  • Download pre-trained models using the command: ./download_styling_models.sh
  • Run the command:
    python neural_style/neural_style.py eval --content-image images/content-images/amber.jpg --model saved-models/mosaic.pth --output-image stylized_amber.jpg --cuda 0
  • Open image stylized_amber.jpg

from fast-neural-style.

dovanchan avatar dovanchan commented on August 12, 2024

I found the real problem now,
When I run the step that you offer,It will be successful;
But when I try a new content image,I got the error:

(fnstest) Dovan-Rmbp:fast-neural-style DOVAN$ time python neural_style/neural_style.py eval --content-image images/content-images/image1.jpg --model saved-models/mosaic.pth --output-image stylized_amber.jpg --cuda 0
Traceback (most recent call last):
  File "neural_style/neural_style.py", line 210, in <module>
    main()
  File "neural_style/neural_style.py", line 206, in main
    stylize(args)
  File "neural_style/neural_style.py", line 135, in stylize
    content_image = Variable(utils.preprocess_batch(content_image), volatile=True)
  File "/Users/DOVAN/fast-neural-style/neural_style/utils.py", line 59, in preprocess_batch
    (r, g, b) = torch.chunk(batch, 3)
ValueError: need more than 2 values to unpack

Here is the image I used:
image1

from fast-neural-style.

abhiskk avatar abhiskk commented on August 12, 2024

The image that you shared is not in RGB format, you can convert it to RGB format using the following commands:

from PIL import Image
content_image = Image.open('/path/to/image')
content_rgb_image = content_image.convert('RGB')
content_rgb_image.save('/path/to/output/image')

Then you can run the neural style on the new image. I have also attached the udnie styled version of the image.

Apologies for the late reply.
issue_14_udnie

from fast-neural-style.

abhiskk avatar abhiskk commented on August 12, 2024

Closing the issue, please comment if similar problems resurface.

from fast-neural-style.

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.