ksvmuralidhar commited on
Commit
6bf5d09
1 Parent(s): 8b93c35

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -8,6 +8,7 @@ from tensorflow.keras.utils import load_img, save_img, img_to_array
8
  from numpy import array, round
9
  from utils.delete_file import delete_file
10
  from requests import get
 
11
 
12
 
13
  app = Flask(__name__, template_folder='templates', static_folder='static')
@@ -29,12 +30,13 @@ CLASS_INDICES = {'Bean': 0,
29
  'Radish': 13,
30
  'Tomato': 14}
31
 
32
- @st.cache_resource
33
  def load_model():
34
  interpreter = lite.Interpreter(model_path=os.path.join("models", "vegetable_classification_model_mnet.tflite"))
 
35
  return interpreter
36
 
37
- interpreter = load_model()
38
 
39
 
40
  def predict(test_image):
 
8
  from numpy import array, round
9
  from utils.delete_file import delete_file
10
  from requests import get
11
+ from functools import lru_cache
12
 
13
 
14
  app = Flask(__name__, template_folder='templates', static_folder='static')
 
30
  'Radish': 13,
31
  'Tomato': 14}
32
 
33
+ @lru_cache(max_size=1)
34
  def load_model():
35
  interpreter = lite.Interpreter(model_path=os.path.join("models", "vegetable_classification_model_mnet.tflite"))
36
+ print('loaded model')
37
  return interpreter
38
 
39
+ interpreter = load_model(True)
40
 
41
 
42
  def predict(test_image):