app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
-
from transformers import BertTokenizer
|
4 |
import torch.nn.functional as F
|
5 |
|
6 |
# Load model and tokenizer from Hugging Face
|
@@ -10,7 +10,7 @@ tokenizer = BertTokenizer.from_pretrained(model_name)
|
|
10 |
class IndoBERTMultiTaskClassifier(torch.nn.Module):
|
11 |
def __init__(self, bert_model_name, num_labels_task1, num_labels_task2, dropout_rate=0.3):
|
12 |
super(IndoBERTMultiTaskClassifier, self).__init__()
|
13 |
-
self.bert = BertModel.from_pretrained(bert_model_name)
|
14 |
self.dropout = torch.nn.Dropout(dropout_rate)
|
15 |
self.classifier_task1 = torch.nn.Linear(self.bert.config.hidden_size, num_labels_task1)
|
16 |
self.classifier_task2 = torch.nn.Linear(self.bert.config.hidden_size, num_labels_task2)
|
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
+
from transformers import BertTokenizer, BertModel # Add BertModel to the imports
|
4 |
import torch.nn.functional as F
|
5 |
|
6 |
# Load model and tokenizer from Hugging Face
|
|
|
10 |
class IndoBERTMultiTaskClassifier(torch.nn.Module):
|
11 |
def __init__(self, bert_model_name, num_labels_task1, num_labels_task2, dropout_rate=0.3):
|
12 |
super(IndoBERTMultiTaskClassifier, self).__init__()
|
13 |
+
self.bert = BertModel.from_pretrained(bert_model_name) # Use BertModel correctly
|
14 |
self.dropout = torch.nn.Dropout(dropout_rate)
|
15 |
self.classifier_task1 = torch.nn.Linear(self.bert.config.hidden_size, num_labels_task1)
|
16 |
self.classifier_task2 = torch.nn.Linear(self.bert.config.hidden_size, num_labels_task2)
|