quocviethere's picture
Update app.py
87375a2
raw
history blame
667 Bytes
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()