jeanetrixsiee commited on
Commit
8191fd3
·
verified ·
1 Parent(s): 22aef0f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -25,21 +25,21 @@ def predict_sentiment(text):
25
  return_tensors='tf'
26
  )
27
 
28
- # Ubah pemanggilan model ke bentuk keyword arguments
29
- outputs = model(
30
- input_ids=inputs["input_ids"],
31
- attention_mask=inputs["attention_mask"]
32
- )
 
 
33
 
34
- # Ambil hasil prediksi
35
  prediction = tf.argmax(outputs["classifier"], axis=1).numpy()[0]
36
  return labels[prediction]
37
 
38
  # UI Gradio
39
- demo = gr.Interface(
40
- fn=predict_sentiment,
41
- inputs=gr.Textbox(label="Masukkan komentar"),
42
- outputs=gr.Textbox(label="Hasil Sentimen")
43
- )
44
 
45
  demo.launch()
 
25
  return_tensors='tf'
26
  )
27
 
28
+ # Gabungkan input_ids dan attention_mask ke dalam 1 dict
29
+ model_inputs = {
30
+ "input_ids": inputs["input_ids"],
31
+ "attention_mask": inputs["attention_mask"]
32
+ }
33
+
34
+ outputs = model(inputs=model_inputs)
35
 
36
+ # Ambil prediksi dari output dict
37
  prediction = tf.argmax(outputs["classifier"], axis=1).numpy()[0]
38
  return labels[prediction]
39
 
40
  # UI Gradio
41
+ demo = gr.Interface(fn=predict_sentiment,
42
+ inputs=gr.Textbox(label="Masukkan komentar"),
43
+ outputs=gr.Textbox(label="Hasil Sentimen"))
 
 
44
 
45
  demo.launch()