EfektMotyla commited on
Commit
bc5909d
·
verified ·
1 Parent(s): 977970f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
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
- # === Ładowanie modeli ===
19
- device = "cuda" if torch.cuda.is_available() else "cpu"
20
-
21
- aspect_tokenizer = AutoTokenizer.from_pretrained("EfektMotyla/bert-aspect-ner")
22
- aspect_model = AutoModelForTokenClassification.from_pretrained("EfektMotyla/bert-aspect-ner").to(device)
 
23
 
24
- sentiment_tokenizer = AutoTokenizer.from_pretrained("EfektMotyla/absa-roberta")
25
- sentiment_model = AutoModelForSequenceClassification.from_pretrained("EfektMotyla/absa-roberta").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)
 
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)