File size: 716 Bytes
a309064
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
35
36
37
38
39
40
41
42
43
from transformers import pipeline

import gradio as gr

 

# Load sentiment analysis pipeline

# classifier_pipeline = pipeline("text-classification", model="tabularisai/multilingual-sentiment-analysis")

classifier_pipeline = ("sentiment-analysis")

 

# Define classification function

def classify_text(text):

    output = classifier_pipeline(text)

    return output[0]  # Extract the first result from the list

 

# Define Gradio interface

interface = gr.Interface(

    fn=classify_text,

    inputs=gr.Textbox(label="Enter sentence here"),

    outputs=gr.Label(),

    examples=["I am hungry", "I love this product!", "This is the worst experience ever."]

)

 

# Launch the interface

interface.launch()