title: Flask and Keras model Error ''_thread._local' object has no attribute 'value''?
body: <p>I am using the following:
  python 3.6.4</p>
  
  <p>Flask = 1.1.1,</p>
  
  <p>Keras = 2.3.0,</p>
  
  <p>TensorFlow = 1.14.0,
  I have a Flask server that gets pictures from the clients. using Keras model with a TensorFlow back-end I try to get a prediction from a pre-trained model.</p>
  
  <p>I am using the following function to upload the model( as part of a class)</p>
  
  <pre><code>
   model_path = self.conf["model_path"] // path in conf to model
   self.model = load_model(model_path)  // uploading the model
   self.model._make_predict_function()
   p_log.info("model had been upload successfully ")
  </code></pre>
  
  <p>and I use the following line for prediction:</p>
  
  <pre><code>cm_prediction = self.model.predict([face, reye, leye, fg])[0]
  </code></pre>
  
  <p>Until today I didn't have any problem, always got a prediction.
  <strong>now I get the following error</strong>: </p>
  
  <pre><code>Traceback (most recent call last):
    File "D:\code_project\path to project", line 75, in predict
      cm_prediction = self.model.predict([face, reye, leye, fg])[0]
    File "D:\code_project\path to project", line 1462, in predict
      callbacks=callbacks)
    File "D:\code_project\predictserver\venv\lib\site-packages\keras\engine\training_arrays.py", line 276, in predict_loop
      callbacks.model.stop_training = False
    File "D:\code_project\predictserver\venv\lib\site-packages\keras\engine\network.py", line 323, in __setattr__
      super(Network, self).__setattr__(name, value)
    File "D:\code_project\predictserver\venv\lib\site-packages\keras\engine\base_layer.py", line 1215, in __setattr__
      if not _DISABLE_TRACKING.value:
  AttributeError: '_thread._local' object has no attribute 'value'
  </code></pre>
  
  <p>I have a simple Flask server running:</p>
  
  <pre><code>if __name__ == '__main__':
      pre = predictor()
      # app.run(debug=True)
      app.run(host='0.0.0.0', port=12345)
  </code></pre>
  
  <p>The model is always being uploaded.</p>
  
  <p>If I am running the program <strong>without the Flask server</strong>, hence giving manually input, <strong>I get a prediction</strong>, but as soon as the <strong>server is on</strong> the error appears and I <strong>stop getting a predictions</strong></p>
  
  <p>I tried to look on the web for some similar problem but didnt found any, if someone knows what the problem and how to solve it, I will appreciate sharing it.</p>