I have this code: NNModel.py
import pickle
from keras.models import load_model
def load_obj(name):
with open('/home/user/' + name + '.pkl', 'rb') as f:
return pickle.load(f)
def load_stuff():
model = load_model("/home/user/model2.h5")
voc = load_obj('voc')
return (model,voc)
It loads my files when I use this function, I'd like to load them to some static or singleton ?class? on the first time and then access that file. How can I achieve that in Python/django?
This file is fairly big and right now I belive every request loads it into memory which is not efficient I guess...