app.py
CHANGED
@@ -2,7 +2,6 @@ import gradio as gr
|
|
2 |
import torch
|
3 |
from transformers import BertTokenizer, BertModel
|
4 |
import torch.nn.functional as F
|
5 |
-
import os
|
6 |
|
7 |
# Load model and tokenizer from Hugging Face
|
8 |
model_name = "shobrunjb/mtl-indoBERT-product-review"
|
@@ -26,18 +25,13 @@ class IndoBERTMultiTaskClassifier(torch.nn.Module):
|
|
26 |
|
27 |
return logits_task1, logits_task2
|
28 |
|
29 |
-
#
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
)
|
37 |
-
model.load_state_dict(torch.load(model_path, map_location=torch.device('cpu')))
|
38 |
-
model.eval()
|
39 |
-
else:
|
40 |
-
raise FileNotFoundError(f"Model file '{model_path}' not found. Please ensure the file is available.")
|
41 |
|
42 |
# Define label mappings
|
43 |
label_mapping_task1 = ["trusted", "fake", "non"] # Adjust with your task1 labels
|
|
|
2 |
import torch
|
3 |
from transformers import BertTokenizer, BertModel
|
4 |
import torch.nn.functional as F
|
|
|
5 |
|
6 |
# Load model and tokenizer from Hugging Face
|
7 |
model_name = "shobrunjb/mtl-indoBERT-product-review"
|
|
|
25 |
|
26 |
return logits_task1, logits_task2
|
27 |
|
28 |
+
# Load model directly from Hugging Face
|
29 |
+
model = IndoBERTMultiTaskClassifier(
|
30 |
+
bert_model_name=model_name,
|
31 |
+
num_labels_task1=3, # Adjust with your task1 classes
|
32 |
+
num_labels_task2=3 # Adjust with your task2 classes
|
33 |
+
)
|
34 |
+
model.eval()
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
# Define label mappings
|
37 |
label_mapping_task1 = ["trusted", "fake", "non"] # Adjust with your task1 labels
|