Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from transformers import AutoModelForSequenceClassification, AutoTokenizer | |
| # Load the model and tokenizer | |
| model = AutoModelForSequenceClassification.from_pretrained("willco-afk/my-model-name") | |
| tokenizer = AutoTokenizer.from_pretrained("willco-afk/my-model-name") | |
| # Define inference function | |
| def classify_text(text): | |
| inputs = tokenizer(text, return_tensors="pt") | |
| logits = model(**inputs).logits | |
| predictions = logits.argmax(dim=-1) | |
| return predictions.item() | |
| # Define Gradio interface | |
| iface = gr.Interface(fn=classify_text, | |
| inputs="text", | |
| outputs="text", | |
| live=True) | |
| iface.launch() |