TextCategorizer.from_disk unable to load trained model #9315
-
How to reproduce the behaviourI have a spaCy project that trains two separate text classifiers. I'm trying to load both models into a spaCy
Then I try to load the import spacy
nlp = spacy.load('blank:en')
textcat = nlp.create_pipe('textcat')
textcat.from_disk('training/model-best/textcat/') Resulting in this traceback:
I've been looking at the docs and the source code and am surprised because this seems to be the exact what that this is documented but maybe I've overlooked something here? Info about spaCy
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
You want to load it like this: import spacy
nlp = spacy.load("training/model-best")
# usually you just want to run the whole pipeline
doc = nlp("This is a text.")
# if you want to inspect the component for some reason
textcat = nlp.get_pipe("textcat") You don't want to load individual components like this because you're missing the configuration from |
Beta Was this translation helpful? Give feedback.
You want to load it like this:
You don't want to load individual components like this because you're missing the configuration from
config.cfg
and the sharedvocab
from the top-level directory in the saved pipeline (training/model-best
). For more details, have a look at: https://spacy.io/usage/processing-pipelines#pipelines