Spaces:
Runtime error
Runtime error
Create inference.py
Browse files- inference.py +11 -0
inference.py
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
from torchtext.data.utils import get_tokenizer
|
3 |
+
from model_arch import TextClassifierModel
|
4 |
+
|
5 |
+
model_loaded = torch.load('model_checkpoint.pth')
|
6 |
+
vocab = torch.load('vocab.pt')
|
7 |
+
tokenizer = get_tokenizer("spacy", language="es")
|
8 |
+
|
9 |
+
text_pipeline = lambda x: vocab(tokenizer(x))
|
10 |
+
|
11 |
+
|