Hi, I'm trying to load a simple model to the memory before making any calls/requests. My goal with that is to avoid re-loading the model everytime after recieving a request. The problem is that the script is not working if I define and load the model outside of the request method (hello_world by default). However I was able to run the code locally without any errors.
import cv2
import base64
import numpy as np
from keras.models import load_model
from flask import Flask, request, jsonify
app = Flask(__name__)
model = load_model('full_model.h5') ----> not working
@app.route('/upload', methods=['POST'])
def hello_world():
model = load_model('full_model.h5') ----> working