Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,22 +7,22 @@ from transformers import (
|
|
| 7 |
)
|
| 8 |
import torch
|
| 9 |
import os
|
| 10 |
-
from huggingface_hub import login
|
| 11 |
|
| 12 |
hf_token = os.getenv("HF_TOKEN")
|
| 13 |
-
if hf_token:
|
| 14 |
-
login(token=hf_token)
|
| 15 |
-
|
| 16 |
-
app = FastAPI()
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
| 23 |
|
| 24 |
-
sentiment_tokenizer = AutoTokenizer.from_pretrained(
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
pl_to_en = pipeline("translation", model="Helsinki-NLP/opus-mt-pl-en", device=0 if device == "cuda" else -1)
|
| 28 |
en_to_pl = pipeline("translation", model="gsarti/opus-mt-tc-en-pl", device=0 if device == "cuda" else -1)
|
|
|
|
| 7 |
)
|
| 8 |
import torch
|
| 9 |
import os
|
|
|
|
| 10 |
|
| 11 |
hf_token = os.getenv("HF_TOKEN")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
aspect_tokenizer = AutoTokenizer.from_pretrained(
|
| 14 |
+
"EfektMotyla/bert-aspect-ner", token=hf_token
|
| 15 |
+
)
|
| 16 |
+
aspect_model = AutoModelForTokenClassification.from_pretrained(
|
| 17 |
+
"EfektMotyla/bert-aspect-ner", token=hf_token
|
| 18 |
+
).to(device)
|
| 19 |
|
| 20 |
+
sentiment_tokenizer = AutoTokenizer.from_pretrained(
|
| 21 |
+
"EfektMotyla/absa-roberta", token=hf_token
|
| 22 |
+
)
|
| 23 |
+
sentiment_model = AutoModelForSequenceClassification.from_pretrained(
|
| 24 |
+
"EfektMotyla/absa-roberta", token=hf_token
|
| 25 |
+
).to(device)
|
| 26 |
|
| 27 |
pl_to_en = pipeline("translation", model="Helsinki-NLP/opus-mt-pl-en", device=0 if device == "cuda" else -1)
|
| 28 |
en_to_pl = pipeline("translation", model="gsarti/opus-mt-tc-en-pl", device=0 if device == "cuda" else -1)
|