|
import sklearn |
|
import gradio as gr |
|
import joblib |
|
|
|
pipe = joblib.load("./pipeline.pkl") |
|
inputs = [gr.Textbox(value = "I love this!")] |
|
outputs = [gr.Label(label = "Sentiment")] |
|
title = "Sentiment Analysis Classifier" |
|
description = "This is a sentiment classifier using longformer model with a logistic regression head. " |
|
def infer(inputs): |
|
predictions = pipe.predict_proba([inputs]) |
|
label = { |
|
"negative":str(predictions[0][0]), |
|
"positive":str(predictions[0][1]), |
|
} |
|
return label |
|
gr.Interface(infer, inputs = inputs, outputs = outputs, title = title, description = description).launch() |