Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NeuralCoref-3.0 can't load the new spacy model #48

Closed
Praveenabiginfo opened this issue Jun 14, 2018 · 21 comments
Closed

NeuralCoref-3.0 can't load the new spacy model #48

Praveenabiginfo opened this issue Jun 14, 2018 · 21 comments
Labels

Comments

@Praveenabiginfo
Copy link

I couldn't load the spacy model en-coref-sm. I have installed both neuralcoref-3.0 and en-coref-sm by downloading and running the setup.py even I tried the pip install for both. Once the installation completed when tried to load the spacy model it throws the below exception.

Traceback (most recent call last):
File "/home/extraction/CoreferenceResolver.py", line 5, in
from neuralcoref import Coref
File "/usr/local/lib/python2.7/dist-packages/neuralcoref-3.0-py2.7-linux-x86_64.egg/neuralcoref/init.py", line 3, in
from .neuralcoref import NeuralCoref
File "neuralcoref.pyx", line 101, in init neuralcoref.neuralcoref
TypeError: must be char, not unicode

Please provide me the clear steps to begin with the new neuralcoref

@thomwolf
Copy link
Member

hi @Praveenabiginfo, can you give me some information on your setup. Are you under windows, linux or mac and which version of python / environment manager you are using ?

@Praveenabiginfo
Copy link
Author

Praveenabiginfo commented Jun 18, 2018 via email

@theSage21
Copy link

Under neuralcoref 3.0 is from neuralcoref import Coref still working? I was reading your traceback and from there it appears that you're importing it using that statement.
@Praveenabiginfo does

import spacy
nlp = spacy.load('en_coref_sm')

solve your problem/work as expected?

@Praveenabiginfo
Copy link
Author

Praveenabiginfo commented Jun 18, 2018 via email

@thomwolf
Copy link
Member

I am uploading updated versions of the models (en_coref_sm is up, the others are still currently uploading) which should work with the original readme instructions (fixed the install scripts).

@Praveenabiginfo
Copy link
Author

Praveenabiginfo commented Jun 19, 2018 via email

@Praveenabiginfo
Copy link
Author

Praveenabiginfo commented Jun 19, 2018 via email

@thomwolf
Copy link
Member

Hi @Praveenabiginfo, I released a set of updated models just this morning. Can you try them instead of the old ones? I tested them on Python 2.7 and 3.6. See my last post in issue #47 for details.

@Praveenabiginfo
Copy link
Author

Praveenabiginfo commented Jun 19, 2018 via email

@thomwolf
Copy link
Member

thomwolf commented Jun 19, 2018

Try to download them again please (I updated them several times this morning)

@Praveenabiginfo
Copy link
Author

Praveenabiginfo commented Jun 19, 2018 via email

@thomwolf
Copy link
Member

Ok I see, thanks for trying. I have to update the instal script for Ubuntu indeed.
I need to first setup an Ubuntu machine to test it.
I will come back to you when I managed to fix that.

@Praveenabiginfo
Copy link
Author

Today I again tried in a different machine which doesn't even have the spacy.
I installed spacy and then installed spacy model "sm" and then installed this new model of coref "sm" and installed Cython and did that steps from github specified in the document. All went well. But when I tried to load the new coref model again I got the same error.. Below is that error.

import spacy
spacy.load('en_coref_sm')
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/spacy/init.py", line 15, in load
return util.load_model(name, **overrides)
File "/usr/local/lib/python2.7/dist-packages/spacy/util.py", line 114, in load_model
return load_model_from_package(name, **overrides)
File "/usr/local/lib/python2.7/dist-packages/spacy/util.py", line 134, in load_model_from_package
cls = importlib.import_module(name)
File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module
import(name)
File "/usr/local/lib/python2.7/dist-packages/en_coref_sm/init.py", line 6, in
from en_coref_sm.neuralcoref import NeuralCoref
File "/usr/local/lib/python2.7/dist-packages/en_coref_sm/neuralcoref/init.py", line 1, in
from .neuralcoref import NeuralCoref
File "neuralcoref.pyx", line 101, in init en_coref_sm.neuralcoref.neuralcoref
TypeError: must be char, not unicode

@Praveenabiginfo
Copy link
Author

Why this error??

import spacy
spacy.load('en_coref_sm')
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/spacy/init.py", line 19, in load
return util.load_model(name, **overrides)
File "/usr/local/lib/python2.7/dist-packages/spacy/util.py", line 115, in load_model
return load_model_from_package(name, **overrides)
File "/usr/local/lib/python2.7/dist-packages/spacy/util.py", line 138, in load_model_from_package
return cls.load(**overrides)
File "/usr/local/lib/python2.7/dist-packages/en_coref_sm/init.py", line 15, in load
coref = NeuralCoref(nlp.vocab)
File "neuralcoref.pyx", line 529, in en_coref_sm.neuralcoref.neuralcoref.NeuralCoref.init
File "doc.pyx", line 100, in spacy.tokens.doc.Doc.set_extension
AssertionError

@Praveenabiginfo
Copy link
Author

Hi,

The issue is not related to Ubuntu it seems. I was using Python2.7 version before. I tried with Python 3.4. Now it is working fine. Is there any options to make it run on Python2.7 itself??

@thomwolf
Copy link
Member

Well it is working on my mac (OS Sierra) on Python 2.7 so I am a bit puzzled.
Can you try installing a full clean version with

pip install --upgrade --force-reinstall --no-cache-dir MODEL_URL

@Praveenabiginfo
Copy link
Author

Praveenabiginfo commented Jun 28, 2018 via email

@Praveenabiginfo
Copy link
Author

Praveenabiginfo commented Jun 28, 2018 via email

@gonz
Copy link

gonz commented Sep 20, 2018

I'm also having this issue, I'm using python 2.7.6 on a Ubuntu 14.04.

This is the full traceback:

In [1]: import spacy; spacy.load('en_coref_sm')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-1-bd9aa5b27231> in <module>()
----> 1 import spacy; spacy.load('en_coref_sm')

/home/ubuntu/.virtualenvs/apex/local/lib/python2.7/site-packages/spacy/__init__.pyc in load(name, **overrides)
     13     if depr_path not in (True, False, None):
     14         deprecation_warning(Warnings.W001.format(path=depr_path))
---> 15     return util.load_model(name, **overrides)
     16
     17

/home/ubuntu/.virtualenvs/apex/local/lib/python2.7/site-packages/spacy/util.pyc in load_model(name, **overrides)
    112             return load_model_from_link(name, **overrides)
    113         if is_package(name):  # installed as package
--> 114             return load_model_from_package(name, **overrides)
    115         if Path(name).exists():  # path to model data directory
    116             return load_model_from_path(Path(name), **overrides)

/home/ubuntu/.virtualenvs/apex/local/lib/python2.7/site-packages/spacy/util.pyc in load_model_from_package(name, **overrides)
    132 def load_model_from_package(name, **overrides):
    133     """Load a model from an installed package."""
--> 134     cls = importlib.import_module(name)
    135     return cls.load(**overrides)
    136

/usr/lib/python2.7/importlib/__init__.pyc in import_module(name, package)
     35             level += 1
     36         name = _resolve_name(name[level:], package, level)
---> 37     __import__(name)
     38     return sys.modules[name]

/home/ubuntu/.virtualenvs/apex/local/lib/python2.7/site-packages/en_coref_sm/__init__.py in <module>()
      4 from pathlib import Path
      5 from spacy.util import load_model_from_init_py, get_model_meta
----> 6 from en_coref_sm.neuralcoref import NeuralCoref
      7
      8 __version__ = get_model_meta(Path(__file__).parent)['version']

/home/ubuntu/.virtualenvs/apex/local/lib/python2.7/site-packages/en_coref_sm/neuralcoref/__init__.py in <module>()
----> 1 from .neuralcoref import NeuralCoref

neuralcoref.pyx in init en_coref_sm.neuralcoref.neuralcoref()

TypeError: must be char, not unicode

Initially I hit the AssertionError @Praveenabiginfo mentioned on Jun 27th, I fixed that by upgrading spacy from 2.0.7 to 2.0.12. Now I'm stuck with this TypeError when loading the model from spacy.

@thomwolf
Copy link
Member

This should be fixed in the latest release (4.0).

@saurabhhssaurabh
Copy link

Facing same iussue:
neuralcoref 4.0
spacy 2.1.0

/data/saurabh/neuralcoref/neuralcoref/init.py in ()
12 warnings.filterwarnings("ignore", message="spacy.strings.StringStore size changed")
13
---> 14 from .neuralcoref import NeuralCoref
15 from .file_utils import NEURALCOREF_MODEL_URL, NEURALCOREF_MODEL_PATH, NEURALCOREF_CACHE, cached_path
16

neuralcoref.pyx in init neuralcoref.neuralcoref()

TypeError: must be char, not unicode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants