First prediction is too slow
chrystalla opened this issue · 3 comments
May someone knows why the first time I run the inference is too slow and then for the next predictions is ok? It needs like 20s to predict the first picture and the second around ~0.5 s
I think because you load the model into your memory. Try to load it when your app runs as a general object/
@chrystalla you may want to go ahead and create a flask rest API where you go ahead and serve NSFW detection requests, this way you can go ahead and save time to load the model in your memory.
Because every time you go ahead and start your script it's gonna go ahead and load the model into your memory not to mention TensorFlow and other packages take a bit of time to load on their own, therefore the above approach is going to be the best one in your use case.