Spaces:
Sleeping
Sleeping
import gradio as gr | |
from transformers import AutoTokenizer, AutoModelForSequenceClassification | |
# Load model and tokenizer | |
model_name = "castorini/afriberta_large" | |
tokenizer = AutoTokenizer.from_pretrained(model_name) | |
model = AutoModelForSequenceClassification.from_pretrained(model_name) | |
# Define prediction function | |
def predict(text): | |
inputs = tokenizer(text, return_tensors="pt") | |
outputs = model(**inputs) | |
return outputs.logits.argmax(-1).item() | |
# Gradio Interface | |
iface = gr.Interface(fn=predict, inputs="text", outputs="label", title="AfriBERTa Demo") | |
iface.launch() | |