Spaces:
Runtime error
Runtime error
import gradio as gr | |
from transformers import AutoModelForSequenceClassification, AutoTokenizer | |
# Load the model and tokenizer from Hugging Face model hub | |
model = AutoModelForSequenceClassification.from_pretrained("willco-afk/my-model-name") | |
tokenizer = AutoTokenizer.from_pretrained("willco-afk/my-model-name") | |
# Define the function for prediction | |
def predict(text): | |
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True) | |
outputs = model(**inputs) | |
logits = outputs.logits | |
prediction = logits.argmax(-1).item() | |
return prediction | |
# Create a Gradio interface | |
interface = gr.Interface(fn=predict, inputs="text", outputs="text") | |
interface.launch() |