1

I am building an application in python using pre-trained ml models. Currently for each file upload i am loading models and it takes lot of time. I need to load these models only once while starting the flask . How can i do that?

Anjaly Vijayan
  • 237
  • 2
  • 9

1 Answers1

0

You can use "flask.g", it creates a global variable for all requests.

https://flask.palletsprojects.com/en/1.1.x/api/#flask.g

In this case you initialize the model only once.

Claudio
  • 96
  • 1
  • 4