sadeepj / crfasrnn_keras

CRF-RNN Keras/Tensorflow version
http://crfasrnn.torr.vision
MIT License
603 stars 169 forks source link

processing time on machine is thrice of web demo #10

Closed akashdexati closed 7 years ago

akashdexati commented 7 years ago

@sadeepj Thanks for making this available for others learning

I setup everything asper the instructions on a Ubuntu 16.04 machine. And the processing timing is almost 3 times of the online demo - http://crfasrnn.torr.vision/

Any suggestion what I could be missing here ?

sadeepj commented 7 years ago

@akashdexati

I haven't really timed the Keras implementation vs the Caffe implementation (which is driving the web demo and available at https://github.com/torrvision/crfasrnn). But it's very unlikely that Keras implementation will the three times slower. Are you sure the warming-up time was not included when you timed the Keras version? In the web demo, model has already been initialized and only the forward pass is run when a user uploads an image.

To get a fair comparison between the Keras version and the Caffe version, modify line 40 of https://github.com/sadeepj/crfasrnn_keras/blob/master/run_demo.py as shown below:

probs = model.predict(img_data, verbose=False)[0, :, :, :]  # Warm-up
probs = model.predict(img_data, verbose=False)[0, :, :, :]  # Warm-up
start_time = time.time()  # You'd have to do 'import time' at the start of the module
probs = model.predict(img_data, verbose=False)[0, :, :, :]
end_time = time.time()
print("Time spent on the forward pass: {:.3f} s".format(end_time - start_time))

In any case, there are some performance improvements that can be done to the Keras implementation. I'll do some of them when I have some free time. I'm also hoping to complete the GPU implementation of CrfRnnLayer sometime soon.

akashdexati commented 7 years ago

@sadeepj Thanks for the reply. I switched to the the caffe implementation and now I get much better timing. Not exactly the same as your web demo but better than what I had earlier.

Thanks