File size: 820 Bytes
f4c7831
00f8b37
f4c7831
00f8b37
f4c7831
7fb0561
 
60fe13c
d357fb7
 
 
 
d263e6c
 
d357fb7
 
02a67dd
250452d
 
 
 
00f8b37
 
 
 
 
250452d
 
00f8b37
f4c7831
 
cd96437
20ea08b
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
26
27
28
29
30
31
32
33
34
import gradio as gr
from transformers import pipeline

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

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

description = """
The Bot was trained to answer questions based on Clothing. Ask anything!
"""

gradio_app = gr.Interface(
    predict,
    inputs="textbox",
    outputs="text",
    title="Sentiment- good or bad?",
    description=description,
    examples=[["Loved it!!"], ["Bad quality"]],
)

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