|
import numpy as np |
|
import os |
|
import gradio as gr |
|
|
|
os.environ["WANDB_DISABLED"] = "true" |
|
|
|
from datasets import load_dataset, load_metric |
|
from transformers import ( |
|
AutoConfig, |
|
|
|
AutoTokenizer, |
|
TrainingArguments, |
|
logging, |
|
pipeline |
|
) |
|
|
|
|
|
analyzer = pipeline( |
|
"sentiment-analysis", model="FFZG-cleopatra/M2SA-text-only" |
|
) |
|
|
|
def predict_sentiment(x): |
|
print(analyzer(x)) |
|
return analyzer(x)[0]["label"] |
|
|
|
|
|
interface = gr.Interface( |
|
fn=predict_sentiment, |
|
inputs='text', |
|
outputs=['text'], |
|
title='Multilingual Unimodal Sentiment Analysis', |
|
examples= ["I love tea","I hate coffee"], |
|
description='Get the positive/neutral/negative sentiment for the given input.' |
|
) |
|
|
|
interface.launch(inline = False) |
|
|