openeventdata / mordecai

Full text geoparsing as a Python library
MIT License
742 stars 97 forks source link

error when initializing the Geoparser #87

Open ZhendongLiu opened 3 years ago

ZhendongLiu commented 3 years ago

Hi

I get the following error when initializing the Geoparser:

Traceback (most recent call last): File "", line 1, in File "/Users/ZhendongLiu/Desktop/CSC440/Project/mordecai-env/lib/python3.6/site-packages/mordecai/geoparse.py", line 53, in init self.country_model = keras.models.load_model(models_path + "country_model.h5") File "/Users/ZhendongLiu/Desktop/CSC440/Project/mordecai-env/lib/python3.6/site-packages/tensorflow/python/keras/saving/save.py", line 182, in load_model return hdf5_format.load_model_from_hdf5(filepath, custom_objects, compile) File "/Users/ZhendongLiu/Desktop/CSC440/Project/mordecai-env/lib/python3.6/site-packages/tensorflow/python/keras/saving/hdf5_format.py", line 176, in load_model_from_hdf5 model_config = json.loads(model_config.decode('utf-8')) AttributeError: 'str' object has no attribute 'decode'

do you have any idea what's going on?

ahalterman commented 3 years ago

It look like the error is coming from trying to decode a string that's already decoded (Stackoverflow link). Mordecai only works with Python 3, so you shouldn't have to do any string encoding/decoding.

bdevore17 commented 3 years ago

@ahalterman I am having the same issue as @ZhendongLiu while using python 3.7. Any idea what could be going on here? Or how to fix it?

ahalterman commented 3 years ago

This looks like a h5py and Keras incompatibility: https://github.com/tensorflow/tensorflow/issues/44467. Changing the requirements file to h5py<3.0.0 should resolve it. I'll take a look over the weekend and push an update to pypi if that resolves it, but in the meantime, changing requirements.txt and installing from source should probably fix it (let me know either way!).

And @ZhendongLiu, I missed that you were using 3.6 already. Sorry about that.

simonepstein commented 3 years ago

As a workaround I installed an earlier version of h5py after installin mordecai from pip.

pip install -I h5py==2.10.0

The eiffel tower example works fine now.