Comments (19)
I think you're right. The forward() just takes 300-400ms
from fast-neural-style.
@jayavanth are you talking about evaluation phase when you stylize using a trained model?
The implementation currently doesn't use GPU while stylizing, I will add that soon.
from fast-neural-style.
Yes. I just changed lines 153 and 155 to have .cuda()
and it's about 3X faster now. I was wondering if it's possible to get it in the millisecond range
from fast-neural-style.
Okay, actually I have cleaned up the code over the past day so I don't know which version are you using. Can you tell which version you are using, or maybe do a git pull and then add your changes. Feel free to open a pull-request.
As you said I think you just need to do a style_model.cuda()
and content_image = content_image.cuda()
and maybe do a output = output.cpu()
before you call the utils.tensor_save_bgrimage()
function.
from fast-neural-style.
Yes, something like that. Check out PR #10
from fast-neural-style.
Regarding the speed, I guess you can try passing in smaller sized images but it might not make a big difference.
I think you will have to remove layers from TransformerNet
to make better gains but that might result in degradation in quality of the style-transfers.
from fast-neural-style.
I'm passing 300x200 and it still takes about 3s to finish. Have you tried using compressed vgg?
from fast-neural-style.
So vgg is only used while training, the running time during evaluation is only dependent upon the TransformerNet
architecture, I am not sure how this running time compares to other implementations of neural-style, do you have any idea about that?
from fast-neural-style.
The fastest neural-style I've seen so far is this
from fast-neural-style.
Okay, yes I am have come across that implementation, I haven't really benchmarked my implementation for evaluation, I will try and do that soon. Which GPU are you running it on?
from fast-neural-style.
I'm using TitanX
from fast-neural-style.
Okay, I don't have a GPU locally and the queue on the server seems to be long right now, I will test it soon. Can you check the running time only for this line. Were you testing the time taken to run the whole script earlier? I think there is some overhead to reading and writing the image and moving around between numpy and cuda.
from fast-neural-style.
That's good to know, so the actual computations in pytorch are comparable to tensorflow. I guess the 100ms time that implementation reported was also the time for processing.
Actually because the model was saved in CPU format and for GPU you convert it to CUDA it takes a long time as the model size is not small.
In relation to the tensorflow implementation that you mentioned, my network structure is same as that implementation so I think the forward
time is comparable to that implementation. Thanks for the help.
from fast-neural-style.
Yes, it is comparable. The tensorflow implementation takes about 100ms per frame during forward(). It takes an additional ~5s for image i/o and ffmpeg for a 30 frame video.
from fast-neural-style.
Good to know, I guess it's expected pytorch is slower as compared to Tensorflow and I think there are some performance gains that can be made, specially in broadcasting because currently you have to squeeze
and unsqueeze
stuff. There is a broadcasting feature planned soon. Also as pytorch matures things will improve.
from fast-neural-style.
Fixed in 9803eab
from fast-neural-style.
Hey @jayavanth I benchmarked the pytorch implementation against this tensorflow implementation that you had linked earlier on a GTX1080. For the same image pytorch took 600ms and tensorflow took 700ms.
Can you give more details on how you were benchmarking the pytorch implementation, I suspect I am doing something wrong because it seems unlikely that pytorch is faster than tensorflow.
from fast-neural-style.
AFAIK, the performance depends on the image size, and hopefully it will plateau. What image sizes are you using? I also noticed that your implementation crashes for large images e.g. 2557x1704. However, the Tensorflow implementation handles large images with a warning message about memory being full. Maybe, the latter error has something to do with Tensorflow vs PyTorch.
from fast-neural-style.
I was using 1024 x 680 image for my tests. The running times of my implementation and the tensorflow implementation are almost similar so that's good.
Regarding memory yes there are some issues with pytorch right now, for a 2557x1704 the memory requirement will be a lot, around 80GB I guess and pytorch might not be able to work in a smaller memory. Going ahead I think the memory handling of pytorch will become better.
Thanks
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
- How to set output_image_size when Eval HOT 18
- 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
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.