File size: 622 Bytes
eb958ab
fe717ed
eb958ab
f396334
eb958ab
fe717ed
 
3701013
144af8f
 
 
 
 
 
104aa19
eb958ab
fe717ed
 
 
 
 
eb958ab
 
 
fe717ed
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 gradio as gr
from transformers import pipeline

pipeline = pipeline(task="text-classification", model="Preetham04/sentiment-analysis_tf")

def predict(input_text):
    predictions = pipeline(input_text)
    result = [] 
    for p in predictions:
        review = "POSITIVE" if p["label"] == "LABEL_1" else "NEGATIVE"
        result.append({
            "review": review,
            "score": p["score"]
        })
    return result

gradio_app = gr.Interface(
    predict,
    inputs="textbox",
    outputs="text",
    title="Sentiment- good or bad?",
)

if __name__ == "__main__":
    gradio_app.launch(share=True)