I am able to get mordecai result when used a standalone Python. But, when I integrate with Flask, I get no result
See below for sample code:
from mordecai import Geoparser
geo = Geoparser(es_hosts='***',es_port=80,es_ssl=False,country_threshold = 0.5)
geo.geoparse("Wuhan")
If Ran from Flask
[{'word': 'Wuhan', 'spans': [{'start': 0, 'end': 5}], 'country_predicted': '', 'country_conf': 0}]
or
I get the error
tensorflow.python.framework.errors_impl.InvalidArgumentError: Tensor dense_112_input:0, specified in either feed_devices or fetch_devices was not found in the Graph
I looked for this error in forums, where they suggest to use below line
graph = tf.get_default_graph().
But, still I am not able to resolve it. Need help ! Thanks in advance
This issue is been fixed by upgrading Tensorflow from 1.14 to 2.2.
Also, added "threaded=False" when calling
app.run(host="0.0.0.0", port= 1234, debug=False, threaded=False)
I am able to get mordecai result when used a standalone Python. But, when I integrate with Flask, I get no result
See below for sample code: from mordecai import Geoparser geo = Geoparser(es_hosts='***',es_port=80,es_ssl=False,country_threshold = 0.5) geo.geoparse("Wuhan")
Expected result below if ran as standalone:
[{'word': 'Wuhan', 'spans': [{'start': 0, 'end': 5}], 'country_predicted': 'CHN', 'country_conf': 0.9881995, 'geo': {'admin1': 'Hubei', 'lat': '30.58333', 'lon': '114.26667', 'country_code3': 'CHN', 'geonameid': '1791247', 'place_name': 'Wuhan', 'feature_class': 'P', 'feature_code': 'PPLA'}}]
If Ran from Flask
[{'word': 'Wuhan', 'spans': [{'start': 0, 'end': 5}], 'country_predicted': '', 'country_conf': 0}] or I get the error tensorflow.python.framework.errors_impl.InvalidArgumentError: Tensor dense_112_input:0, specified in either feed_devices or fetch_devices was not found in the Graph
I looked for this error in forums, where they suggest to use below line graph = tf.get_default_graph(). But, still I am not able to resolve it. Need help ! Thanks in advance
Below forum I am referring https://kobkrit.com/tensor-something-is-not-an-element-of-this-graph-error-in-keras-on-flask-web-server-4173a8fe15e1