Spaces:
Sleeping
Sleeping
File size: 1,179 Bytes
990dc13 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
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)
|