Spaces:
Sleeping
Sleeping
import gradio as gr | |
import torch | |
from transformers import AutoModelForSequenceClassification, AutoTokenizer | |
model = AutoModelForSequenceClassification.from_pretrained("gsar78/Greek_Sentiment") | |
tokenizer = AutoTokenizer.from_pretrained("gsar78/Greek_Sentiment") | |
def predict(text): | |
inputs = tokenizer(text, return_tensors="pt") | |
outputs = model(**inputs) | |
scores = torch.nn.functional.softmax(outputs.logits, dim=1) | |
return {"Positive": scores[:, 1].item(), "Negative": scores[:, 0].item()} | |
iface = gr.Interface( | |
fn=predict, | |
inputs="text", | |
outputs="label", | |
title="Hellenic Sentiment AI", | |
description=None, | |
article=None, | |
theme="default", | |
flagging_dir=None, | |
share=True, | |
favicon_path=None, | |
css=None, | |
analytics_script=None, | |
allow_flagging="never", | |
allow_screenshot=True, | |
enable_queue=True, | |
show_input=True, | |
show_output=True, | |
footer="Development by Geo Sar" | |
) | |
iface.launch() |