Amal17 commited on
Commit
4ac1935
·
1 Parent(s): ec1ed73
Files changed (1) hide show
  1. app.py +20 -7
app.py CHANGED
@@ -13,9 +13,17 @@ tokenizer = AutoTokenizer.from_pretrained("LazarusNLP/NusaBERT-large")
13
  bigru_model = BERTBiGRUClassifier.from_pretrained("Amal17/NusaBERT-concate-BiGRU-NusaX-ace")
14
  bigru_model.eval()
15
 
 
 
 
16
  bilstm_model = BERTBiLSTMClassifier.from_pretrained("Amal17/NusaBERT-concate-BiLSTM-NusaX-ace")
17
  bilstm_model.eval()
18
 
 
 
 
 
 
19
  # Inference helper
20
  def predict_with_model(model, text):
21
  inputs = tokenizer(
@@ -38,9 +46,14 @@ def compare_models(text):
38
  pred_a, conf_a = predict_with_model(bigru_model, text)
39
  pred_b, conf_b = predict_with_model(bilstm_model, text)
40
 
 
 
 
41
  return (
42
- f"BiGRU → Class: {pred_a}", f"Confidence: {conf_a:.4f}",
43
- f"BiLSTM → Class: {pred_b}", f"Confidence: {conf_b:.4f}"
 
 
44
  )
45
 
46
  # Build Gradio UI
@@ -48,12 +61,12 @@ interface = gr.Interface(
48
  fn=compare_models,
49
  inputs=gr.Textbox(label="Input Text"),
50
  outputs=[
51
- gr.Textbox(label="BiGRU Prediction"),
52
- gr.Textbox(label="BiGRU Confidence"),
53
- gr.Textbox(label="BiLSTM Prediction"),
54
- gr.Textbox(label="BiLSTM Confidence"),
55
  ],
56
- title="Model Comparison: BiGRU vs BiLSTM"
57
  )
58
 
59
  interface.launch()
 
13
  bigru_model = BERTBiGRUClassifier.from_pretrained("Amal17/NusaBERT-concate-BiGRU-NusaX-ace")
14
  bigru_model.eval()
15
 
16
+ bigru_translate_model = BERTBiGRUClassifier.from_pretrained("Amal17/NusaBERT-concate-BiGRU-NusaTranslate-senti")
17
+ bigru_translate_model.eval()
18
+
19
  bilstm_model = BERTBiLSTMClassifier.from_pretrained("Amal17/NusaBERT-concate-BiLSTM-NusaX-ace")
20
  bilstm_model.eval()
21
 
22
+ bilstm_translate_model = BERTBiLSTMClassifier.from_pretrained("Amal17/NusaBERT-concate-BiLSTM-NusaTranslate-senti")
23
+ bilstm_translate_model.eval()
24
+
25
+
26
+
27
  # Inference helper
28
  def predict_with_model(model, text):
29
  inputs = tokenizer(
 
46
  pred_a, conf_a = predict_with_model(bigru_model, text)
47
  pred_b, conf_b = predict_with_model(bilstm_model, text)
48
 
49
+ pred_c, conf_c = predict_with_model(bigru_translate_model, text)
50
+ pred_d, conf_d = predict_with_model(bilstm_translate_model, text)
51
+
52
  return (
53
+ f"Class: {pred_a} ({CLASS_MAP[pred_a]}) with confidence: {conf_a:.4f}",
54
+ f"Class: {pred_b} ({CLASS_MAP[pred_b]}) with confidence: {conf_b:.4f}",
55
+ f"Class: {pred_c} ({CLASS_MAP[pred_c]}) with confidence: {conf_c:.4f}",
56
+ f"Class: {pred_d} ({CLASS_MAP[pred_d]}) with confidence: {conf_d:.4f}",
57
  )
58
 
59
  # Build Gradio UI
 
61
  fn=compare_models,
62
  inputs=gr.Textbox(label="Input Text"),
63
  outputs=[
64
+ gr.Textbox(label="NusaBERT-BiGRU-ace"),
65
+ gr.Textbox(label="NusaBERT-BiLSTM-ace"),
66
+ gr.Textbox(label="NusaBERT-BiGRU-translate"),
67
+ gr.Textbox(label="NusaBERT-BiLSRM-translate"),
68
  ],
69
+ title="Hybrid Model NusaBERT + RNN"
70
  )
71
 
72
  interface.launch()