EfektMotyla commited on
Commit
f2c174e
·
verified ·
1 Parent(s): d9095b6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -7,14 +7,19 @@ from transformers import (
7
  )
8
  import torch
9
  import os
 
 
 
 
 
10
  device = "cuda" if torch.cuda.is_available() else "cpu"
11
 
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
  pl_to_en = pipeline(
19
  "translation",
20
  model="Helsinki-NLP/opus-mt-pl-en",
 
7
  )
8
  import torch
9
  import os
10
+ from pathlib import Path
11
+ ROOT = Path(__file__).parent
12
+ aspect_path = ROOT / "models/bert-aspect-ner"
13
+ sentiment_path = ROOT / "models/absa-roberta"
14
+
15
  device = "cuda" if torch.cuda.is_available() else "cpu"
16
 
 
 
17
 
18
+ aspect_tok = AutoTokenizer.from_pretrained(aspect_path, local_files_only=True)
19
+ aspect_model= AutoModelForTokenClassification.from_pretrained(aspect_path, local_files_only=True).to(device)
20
 
21
+ sent_tok = AutoTokenizer.from_pretrained(sentiment_path, local_files_only=True)
22
+ sent_model= AutoModelForSequenceClassification.from_pretrained(sentiment_path, local_files_only=True).to(device)
23
  pl_to_en = pipeline(
24
  "translation",
25
  model="Helsinki-NLP/opus-mt-pl-en",