Spaces:
Sleeping
Sleeping
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 | |
) | |
# model_name = | |
# tokenizer = AutoTokenizer.from_pretrained(model_name) | |
# config = AutoConfig.from_pretrained(model_name) | |
# pipe = pipeline("text-classification") | |
# pipe("This restaurant is awesome") | |
label2id = { | |
"LABEL_0": "negative", | |
"LABEL_1": "neutral", | |
"LABEL_2": "positive" | |
} | |
analyzer = pipeline( | |
"sentiment-analysis", model="thak123/Cro-Frida", tokenizer="EMBEDDIA/crosloengual-bert" | |
) | |
def predict_sentiment(x): | |
return label2id[analyzer(x)[0]["label"]] | |
interface = gr.Interface( | |
fn=predict_sentiment, | |
inputs='text', | |
outputs=['text'], | |
title='Croatian Movie reviews Sentiment Analysis', | |
examples= ["Volim kavu","Ne volim kavu"], | |
description='Get the positive/neutral/negative sentiment for the given input.' | |
) | |
interface.launch(inline = False) | |