File size: 616 Bytes
e3128c9
 
 
 
 
 
 
 
b622630
 
 
 
 
4b65d0c
e3128c9
 
 
41c442c
b622630
 
 
 
e3128c9
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import joblib
import gradio as gr


model = joblib.load("model.pkl")


def get_sentiment(input_text):
    predictions = model.predict_proba([input_text])
    label = {
                  "negative":str(predictions[0][0]),
                  "positive":str(predictions[0][1]),
              }
    return label 


iface = gr.Interface(
    fn=get_sentiment,
    inputs=[gr.Text(text="Sijapendezwa na tabia yake")],
    outputs=[gr.Label(label='Sentiment')],
    title="Swahili Sentiment Analysis using",
    description="Swahili sentiment analysis is based on a Bayesian scikit-learn model"
)
iface.launch(inline=False)