leeyeehoo / CSRNet-pytorch

CSRNet: Dilated Convolutional Neural Networks for Understanding the Highly Congested Scenes
642 stars 259 forks source link

High inference time in comparison to keras implementation #52

Open Pipoderoso opened 5 years ago

Pipoderoso commented 5 years ago

As stated by the issue title. The CSRNet-keras implementation is a lot faster than this implementation. In my case, one single inference on a Full HD image required ~6100 ms. On the other hand using the keras implementation it required ~460ms

Is there any way to make this implementation faster?

My machine:

ttpro1995 commented 5 years ago

As I noted, the dilation_rate CNN (after custom VGG16) in keras implementation does not use BatchNormalization

            #Conv2D
            model.add(Conv2D(512, (3, 3), activation='relu', dilation_rate = 2, kernel_initializer = init, padding = 'same'))
            model.add(Conv2D(512, (3, 3), activation='relu', dilation_rate = 2, kernel_initializer = init, padding = 'same'))
            model.add(Conv2D(512, (3, 3), activation='relu', dilation_rate = 2, kernel_initializer = init, padding = 'same'))
            model.add(Conv2D(256, (3, 3), activation='relu', dilation_rate = 2, kernel_initializer = init, padding = 'same'))
            model.add(Conv2D(128, (3, 3), activation='relu', dilation_rate = 2, kernel_initializer = init, padding = 'same'))
            model.add(Conv2D(64, (3, 3), activation='relu', dilation_rate = 2, kernel_initializer = init, padding = 'same'))
            model.add(Conv2D(1, (1, 1), activation='relu', dilation_rate = 1, kernel_initializer = init, padding = 'same'))

So, I think that is why it calculate faster pytorch implementation