Commit
·
edec6bb
1
Parent(s):
711ea00
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
from DistilBERT import
|
2 |
import streamlit as st
|
3 |
from transformers import DistilBertTokenizer, DistilBertModel
|
4 |
import logging
|
@@ -9,6 +9,12 @@ MAX_LEN = 100
|
|
9 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
10 |
tokenizer = DistilBertTokenizer.from_pretrained('distilbert-base-uncased', truncation=True, do_lower_case=True)
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
def sentiment_analysis_DB(input):
|
13 |
inputs = tokenizer.encode_plus(
|
14 |
input,
|
|
|
1 |
+
from DistilBERT import DistilBERTClass
|
2 |
import streamlit as st
|
3 |
from transformers import DistilBertTokenizer, DistilBertModel
|
4 |
import logging
|
|
|
9 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
10 |
tokenizer = DistilBertTokenizer.from_pretrained('distilbert-base-uncased', truncation=True, do_lower_case=True)
|
11 |
|
12 |
+
model_DB = DistilBERTClass()
|
13 |
+
loaded_model_path = './model_DB_1.pt'
|
14 |
+
model_DB.load_state_dict(torch.load(loaded_model_path, map_location=torch.device('cpu')))
|
15 |
+
model_DB.to(device)
|
16 |
+
|
17 |
+
|
18 |
def sentiment_analysis_DB(input):
|
19 |
inputs = tokenizer.encode_plus(
|
20 |
input,
|