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?
Asked
Active
Viewed 819 times
1 Answers
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