shobrunjb commited on
Commit
7f9bed9
·
verified ·
1 Parent(s): 58ff862
Files changed (1) hide show
  1. app.py +7 -13
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
- # Check if the model file exists
30
- model_path = "pytorch_model.bin"
31
- if os.path.exists(model_path):
32
- model = IndoBERTMultiTaskClassifier(
33
- bert_model_name=model_name,
34
- num_labels_task1=3, # Adjust with your task1 classes
35
- num_labels_task2=3 # Adjust with your task2 classes
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