Forums

Load pickle file as static file in flask

Hi guys,

I put a model as rest api into a flask app. Currently, I load the model with every call. Of course this is not very efficient and I feel it more now that the model complexity grew and the around 200MB model takes now between 20-50 secs to load. Way too slow to actually give this to any user than myself.

I read a bit on the forums and saw this static file section. But I am not sure how to actually set this up. Does anyone have a step by step guide what I need to do to get the model quicker?

Thank you

M

I just took the model loading out of the rest call (which somehow always lead to errors beforehand) and now it is way faster. So actually I don't really need these static files, do I? Or will everything become even faster then? How about ability to download the model as an external user?

Static files are normally used to serve files to users that don't need per-request processing -- that is, they're there for images, JavaScript, CSS -- the stuff that doesn't change from request to request.

Is this pickle file something that you expect users of your website to download and use for themselves?