Closed dovanchan closed 7 years ago
--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.--content-scale
will produce an output image which is half the size of the input image.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
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.
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/WX20170621-141545@2x.png --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
Can you tell me how to fix it
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.
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: https://github.com/pytorch/examples/issues/171
@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/WX20170621-141545@2x.jpg --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
I think this may be come from the Function parameters' error
@dovanchan what environment are you running this on, I just tested this implementation on python 2.7, on OSX and everything works well.
python2.7 on OSX 0.12.5 The same as you~
I am also used conda install pytorch ~
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
.
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?
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
?
Yes,I am using conda install pytorch torchvision -c soumith ~
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.
conda create --name fnstest python=2.7
source activate fnstest
conda install pytorch torchvision -c soumith
git clone https://github.com/abhiskk/fast-neural-style.git
cd fast-neural-style/
./download_styling_models.sh
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
stylized_amber.jpg
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:
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.
Closing the issue, please comment if similar problems resurface.
Hi 1、Can you explain what's different of the image_size of "content and style" when Train and Eval? 2、How to set output_image_size when Eval? (if your default setting is 1080,can you show me where you set in your code?) 3、Really thanks for your work