thak123's picture
Create app.py
70b16bd verified
raw
history blame
799 Bytes
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,
# AutoModelForSequenceClassification,
AutoTokenizer,
TrainingArguments,
logging,
pipeline
)
analyzer = pipeline(
"sentiment-analysis", model="FFZG-cleopatra/M2SA-text-only"
)
def predict_sentiment(x):
print(label2id[analyzer(x))
return label2id[analyzer(x)[0]["label"]]
interface = gr.Interface(
fn=predict_sentiment,
inputs='text',
outputs=['text'],
title='Multilingual-Multimodal-Sentiment-Analysis',
examples= ["I love tea","I hate coffee"],
description='Get the positive/neutral/negative sentiment for the given input.'
)
interface.launch(inline = False)