Spaces:
Running
Running
kovacsvi
commited on
Commit
·
1445684
1
Parent(s):
d68fe8b
utils.py
Browse files- interfaces/cap.py +2 -5
interfaces/cap.py
CHANGED
@@ -12,7 +12,6 @@ from huggingface_hub import HfApi
|
|
12 |
from label_dicts import CAP_NUM_DICT, CAP_LABEL_NAMES
|
13 |
|
14 |
from .utils import is_disk_full, release_model
|
15 |
-
from ..utils import MODELS_PRELOADED, TOKENIZERS_PRELOADED
|
16 |
|
17 |
HF_TOKEN = os.environ["hf_read"]
|
18 |
|
@@ -86,10 +85,8 @@ def build_huggingface_path(language: str, domain: str):
|
|
86 |
|
87 |
def predict(text, model_id, tokenizer_id):
|
88 |
device = torch.device("cpu")
|
89 |
-
|
90 |
-
|
91 |
-
model = MODELS_PRELOADED[model_id].to(device)
|
92 |
-
tokenizer = TOKENIZERS_PRELOADED[tokenizer_id]
|
93 |
|
94 |
inputs = tokenizer(text,
|
95 |
max_length=256,
|
|
|
12 |
from label_dicts import CAP_NUM_DICT, CAP_LABEL_NAMES
|
13 |
|
14 |
from .utils import is_disk_full, release_model
|
|
|
15 |
|
16 |
HF_TOKEN = os.environ["hf_read"]
|
17 |
|
|
|
85 |
|
86 |
def predict(text, model_id, tokenizer_id):
|
87 |
device = torch.device("cpu")
|
88 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_id, device_map="auto", token=HF_TOKEN).to(device)
|
89 |
+
tokenizer = AutoTokenizer.from_pretrained(tokenizer_id)
|
|
|
|
|
90 |
|
91 |
inputs = tokenizer(text,
|
92 |
max_length=256,
|