File size: 667 Bytes
f6364ae
 
dcf4bbc
 
 
 
 
 
 
 
 
87375a2
 
 
dcf4bbc
 
87375a2
 
 
dcf4bbc
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import gradio as gr

def predict_sentiment(text):
    model_output = gr.load("models/quocviethere/roberta-sentiment-model").process(text)
    # Convert the model output to a more readable format
    if model_output[0] > model_output[1]:  # Assuming index 0 is for negative sentiment
        return "Negative Review", model_output[0]
    else:
        return "Positive Review", model_output[1]

iface = gr.Interface(
    fn=predict_sentiment, 
    inputs=gr.Textbox(lines=2, placeholder="Type your review here"),  # define the text input
    outputs=gr.Label(num_top_classes=2)  # define the output as a label
)

# Launch the interface
iface.launch()

iface.launch()