Update model path in app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,6 @@ import sys
|
|
3 |
|
4 |
import gradio as gr
|
5 |
import html
|
6 |
-
from tqdm import tqdm
|
7 |
import torch
|
8 |
|
9 |
from transformers import MBartForConditionalGeneration, AutoTokenizer, AutoModel, AutoModelForQuestionAnswering, AutoModelForTokenClassification, pipeline
|
@@ -103,21 +102,21 @@ class CustomModel(nn.Module):
|
|
103 |
phobert_sa = AutoModel.from_pretrained("vinai/phobert-base", output_hidden_states=True)
|
104 |
phobert_sa_tokenizer = AutoTokenizer.from_pretrained("vinai/phobert-base")
|
105 |
phobert_sa = CustomModel(phobert_sa)
|
106 |
-
phobert_sa.load_state_dict(torch.load('
|
107 |
phobert_sa.to(device)
|
108 |
|
109 |
## PhoBERTv2
|
110 |
phobertv2_sa = AutoModel.from_pretrained("vinai/phobert-base-v2", output_hidden_states=True)
|
111 |
phobertv2_sa_tokenizer = AutoTokenizer.from_pretrained("vinai/phobert-base-v2")
|
112 |
phobertv2_sa = CustomModel(phobertv2_sa)
|
113 |
-
phobertv2_sa.load_state_dict(torch.load('
|
114 |
phobertv2_sa.to(device)
|
115 |
|
116 |
## Multilingual BERT
|
117 |
m_bert_sa = AutoModel.from_pretrained("google-bert/bert-base-multilingual-cased", output_hidden_states=True)
|
118 |
m_bert_sa_tokenizer = AutoTokenizer.from_pretrained("google-bert/bert-base-multilingual-cased")
|
119 |
m_bert_sa = CustomModel(m_bert_sa)
|
120 |
-
m_bert_sa.load_state_dict(torch.load('
|
121 |
m_bert_sa.to(device)
|
122 |
|
123 |
# Load Q&A model
|
|
|
3 |
|
4 |
import gradio as gr
|
5 |
import html
|
|
|
6 |
import torch
|
7 |
|
8 |
from transformers import MBartForConditionalGeneration, AutoTokenizer, AutoModel, AutoModelForQuestionAnswering, AutoModelForTokenClassification, pipeline
|
|
|
102 |
phobert_sa = AutoModel.from_pretrained("vinai/phobert-base", output_hidden_states=True)
|
103 |
phobert_sa_tokenizer = AutoTokenizer.from_pretrained("vinai/phobert-base")
|
104 |
phobert_sa = CustomModel(phobert_sa)
|
105 |
+
phobert_sa.load_state_dict(torch.load('phobert_sentiment_analysis.pth', map_location=device))
|
106 |
phobert_sa.to(device)
|
107 |
|
108 |
## PhoBERTv2
|
109 |
phobertv2_sa = AutoModel.from_pretrained("vinai/phobert-base-v2", output_hidden_states=True)
|
110 |
phobertv2_sa_tokenizer = AutoTokenizer.from_pretrained("vinai/phobert-base-v2")
|
111 |
phobertv2_sa = CustomModel(phobertv2_sa)
|
112 |
+
phobertv2_sa.load_state_dict(torch.load('phobertv2_sentiment_analysis.pth', map_location=device))
|
113 |
phobertv2_sa.to(device)
|
114 |
|
115 |
## Multilingual BERT
|
116 |
m_bert_sa = AutoModel.from_pretrained("google-bert/bert-base-multilingual-cased", output_hidden_states=True)
|
117 |
m_bert_sa_tokenizer = AutoTokenizer.from_pretrained("google-bert/bert-base-multilingual-cased")
|
118 |
m_bert_sa = CustomModel(m_bert_sa)
|
119 |
+
m_bert_sa.load_state_dict(torch.load('bert_model_sentiment_analysis.pth', map_location=device))
|
120 |
m_bert_sa.to(device)
|
121 |
|
122 |
# Load Q&A model
|