Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,18 +9,19 @@ import torch
|
|
| 9 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 10 |
|
| 11 |
# === Tokenizery i modele ABSA ===
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
aspect_model = AutoModelForTokenClassification.from_pretrained("EfektMotyla/bert-aspect-ner").to(device)
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
en_to_pl_tokenizer = MarianTokenizer.from_pretrained("gsarti/opus-mt-tc-en-pl")
|
| 20 |
-
en_to_pl_model = MarianMTModel.from_pretrained("gsarti/opus-mt-tc-en-pl").to(device)
|
| 21 |
|
| 22 |
-
pl_to_en_tokenizer = MarianTokenizer.from_pretrained("Helsinki-NLP/opus-mt-pl-en")
|
| 23 |
-
pl_to_en_model = MarianMTModel.from_pretrained("Helsinki-NLP/opus-mt-pl-en").to(device)
|
| 24 |
|
| 25 |
def translate(texts, tokenizer, model):
|
| 26 |
inputs = tokenizer(texts, return_tensors="pt", padding=True, truncation=True).to(device)
|
|
|
|
| 9 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 10 |
|
| 11 |
# === Tokenizery i modele ABSA ===
|
| 12 |
+
aspect_tokenizer = AutoTokenizer.from_pretrained("EfektMotyla/bert-aspect-ner")
|
| 13 |
+
aspect_model = AutoModelForTokenClassification.from_pretrained("EfektMotyla/bert-aspect-ner").to(device)
|
|
|
|
| 14 |
|
| 15 |
+
sentiment_tokenizer = AutoTokenizer.from_pretrained("EfektMotyla/absa-roberta")
|
| 16 |
+
sentiment_model = AutoModelForSequenceClassification.from_pretrained("EfektMotyla/absa-roberta").to(device)
|
| 17 |
+
|
| 18 |
+
en_to_pl_tokenizer = MarianTokenizer.from_pretrained("gsarti/opus-mt-tc-en-pl")
|
| 19 |
+
en_to_pl_model = MarianMTModel.from_pretrained("gsarti/opus-mt-tc-en-pl").to(device)
|
| 20 |
+
|
| 21 |
+
pl_to_en_tokenizer = MarianTokenizer.from_pretrained("Helsinki-NLP/opus-mt-pl-en")
|
| 22 |
+
pl_to_en_model = MarianMTModel.from_pretrained("Helsinki-NLP/opus-mt-pl-en").to(device)
|
| 23 |
|
|
|
|
|
|
|
| 24 |
|
|
|
|
|
|
|
| 25 |
|
| 26 |
def translate(texts, tokenizer, model):
|
| 27 |
inputs = tokenizer(texts, return_tensors="pt", padding=True, truncation=True).to(device)
|