OPJ-demo / app.py
thak123's picture
Create app.py
990dc13
raw
history blame
1.18 kB
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")
# Question answering pipeline, specifying the checkpoint identifier
model = AutoModelForSequenceClassification.from_pretrained(
pretrained_model_name_or_path= "thak123/Cro-Frida",
num_labels=3,
)
analyzer = pipeline(
"sentiment-analysis", model=model, tokenizer="EMBEDDIA/crosloengual-bert"
)
def predict_sentiment(x):
return analyzer(x)
interface = gr.Interface(
fn=predict_sentiment,
inputs='text',
outputs=['label'],
title='Latvian Twitter Sentiment Analysis',
examples= ["Es mīlu Tevi","Es ienīstu kafiju"],
description='Get the positive/neutral/negative sentiment for the given input.'
)
interface.launch(inline = False)