Spaces:
Running
Running
Import spacy model as module
Browse files- app/gui.py +2 -2
- app/model.py +2 -2
app/gui.py
CHANGED
@@ -8,7 +8,7 @@ import gradio as gr
|
|
8 |
import joblib
|
9 |
|
10 |
if TYPE_CHECKING:
|
11 |
-
from sklearn.
|
12 |
|
13 |
__all__ = ["launch_gui"]
|
14 |
|
@@ -19,7 +19,7 @@ NEGATIVE_LABEL = "Negative 😤"
|
|
19 |
|
20 |
|
21 |
@lru_cache(maxsize=1)
|
22 |
-
def load_model() ->
|
23 |
"""Load the trained model and cache it."""
|
24 |
model_path = os.environ.get("MODEL_PATH", None)
|
25 |
if model_path is None:
|
|
|
8 |
import joblib
|
9 |
|
10 |
if TYPE_CHECKING:
|
11 |
+
from sklearn.base import BaseEstimator
|
12 |
|
13 |
__all__ = ["launch_gui"]
|
14 |
|
|
|
19 |
|
20 |
|
21 |
@lru_cache(maxsize=1)
|
22 |
+
def load_model() -> BaseEstimator:
|
23 |
"""Load the trained model and cache it."""
|
24 |
model_path = os.environ.get("MODEL_PATH", None)
|
25 |
if model_path is None:
|
app/model.py
CHANGED
@@ -2,8 +2,8 @@ from __future__ import annotations
|
|
2 |
|
3 |
import warnings
|
4 |
|
|
|
5 |
import numpy as np
|
6 |
-
import spacy
|
7 |
from joblib import Memory
|
8 |
from sklearn.base import BaseEstimator, TransformerMixin
|
9 |
from sklearn.feature_extraction.text import TfidfVectorizer
|
@@ -16,7 +16,7 @@ from app.constants import CACHE_DIR
|
|
16 |
|
17 |
__all__ = ["create_model", "train_model", "evaluate_model"]
|
18 |
|
19 |
-
nlp =
|
20 |
|
21 |
|
22 |
class TextTokenizer(BaseEstimator, TransformerMixin):
|
|
|
2 |
|
3 |
import warnings
|
4 |
|
5 |
+
import en_core_web_sm
|
6 |
import numpy as np
|
|
|
7 |
from joblib import Memory
|
8 |
from sklearn.base import BaseEstimator, TransformerMixin
|
9 |
from sklearn.feature_extraction.text import TfidfVectorizer
|
|
|
16 |
|
17 |
__all__ = ["create_model", "train_model", "evaluate_model"]
|
18 |
|
19 |
+
nlp = en_core_web_sm.load(disable=["tok2vec", "parser", "ner"])
|
20 |
|
21 |
|
22 |
class TextTokenizer(BaseEstimator, TransformerMixin):
|