Comments (18)
- 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. - 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. - π
from fast-neural-style.
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.
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.
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.
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.
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.
@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.
@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.
python2.7 on OSX 0.12.5 The same as you~
from fast-neural-style.
I am also used conda install pytorch ~
from fast-neural-style.
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.
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.
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.
Yes,I am using conda install pytorch torchvision -c soumith ~
from fast-neural-style.
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.
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
from fast-neural-style.
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.
from fast-neural-style.
Closing the issue, please comment if similar problems resurface.
from fast-neural-style.
Related Issues (20)
- Check usage of 'subtract_imagenet_mean', with new version of pytorch inplace subtraction might be different. HOT 1
- About adding Tanh() at the end of the model HOT 5
- Runtime error while trying out the toy example HOT 2
- Time for training a new style HOT 3
- trained model not working HOT 1
- difference with jcjohnson HOT 1
- Problem with training
- download_styling_models.sh error HOT 1
- some question in utils.py HOT 1
- content loss calculation is wrong? HOT 1
- train doesn't run: ValueError: not enough values to unpack (expected 3, got 2) HOT 5
- Query Regarding Transforms used for input image and style image HOT 5
- download_styling_models.sh error
- Could you upload vgg16.weight file? HOT 1
- Python error: <stdin> is a directory, cannot continue HOT 1
- RuntimeError: The expanded size of the tensor (700) must match the existing size (32) at non-singleton dimension 2 HOT 1
- Use Reflection Padding
- Use median filter
- stylize using GPU HOT 19
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fast-neural-style.