Closed AlexDut closed 4 years ago
Hi, Thanks for your work, this sounds like a nice speed up !
Regarding the batch inference, not sure why there would be a negative impact on accuracy ? Just pad smaller pictures to the largest pictures size with black or anything else. Or resize images to the same size.
You can open a new PR for the discussion on batch inference
Hi,
I made some improvements concerning the inference time for the
RetinaFace.detect
method. There are 2 significant changes in this PR:RetinaFace.model
attribute was decorated with atf.function
with(None, None, None, 3)
as input signature. Thanks to this, TensorFlow is tracing a Graph and calling the model on inputs is done much faster. The input signature shape prevents TensorFlow from retracing a new graph (which is a costly operation) whenever the function is called with a new input shape. This is very useful for RetinaFace as input images can have arbitrary shapes.transpose
operations that were not necessary.Considering that the model was instantiated with default parameters and processing images 1-by-1, the inference time on 475 images was reduced by 3 (from 342s to 115s - tested on a 1080Ti).
I am also considering to develop a
detect_batch
method withRetinaFace.pixel_means
padding. This might have a small negative impact on accuracy as noise (padding) is added but could provide another boost in terms of inference time. What do you think ?