import gradio as gr from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline # Load model model_name = "shayeedahmed/psyche-bert-emotion-classifier" tokenizer = AutoTokenizer.from_pretrained(model_name) model = AutoModelForSequenceClassification.from_pretrained(model_name) nlp = pipeline("text-classification", model=model, tokenizer=tokenizer) # Define inference function def classify_text(text): result = nlp(text) return result # Gradio interface iface = gr.Interface( fn=classify_text, inputs=gr.Textbox(label="Enter text here"), outputs=gr.JSON(label="Prediction"), title="Emotion Classifier", description="Classifies text into emotions" ) # Launch the app (this is mandatory!) if __name__ == "__main__": iface.launch()