import gradio as gr from transformers import AutoModelForSequenceClassification, AutoTokenizer # Load your model and tokenizer model_name = "your-model-name" model = AutoModelForSequenceClassification.from_pretrained(model_name) tokenizer = AutoTokenizer.from_pretrained(model_name) def predict(input_text): # Tokenize and make prediction inputs = tokenizer(input_text, return_tensors="pt", truncation=True, padding=True) outputs = model(**inputs) prediction = outputs.logits.argmax(-1).item() return prediction # Define Gradio interface iface = gr.Interface( fn=predict, inputs=gr.Textbox(lines=2, placeholder="Enter text here..."), outputs="label", title="Your Model Name", description="Enter some text to get a prediction." ) # Launch the interface iface.launch()