File size: 383 Bytes
da3aba1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import gradio as gr
from joblib import load


model = load('model.pkl')


def predict_sentiment(text: str)-> str:

    
    sentiment_map = {
        -1: 'Negative',
        0: 'Neutral',
        1: 'Positive'
    }

    prediction = model.predict([text])[0]
    return sentiment_map[prediction]

demo = gr.Interface(fn=predict_sentiment, inputs="text", outputs="text")
demo.launch()