import gradio as gr from transformers import pipeline # Load pre-trained sentiment-analysis pipeline classifier = pipeline('text-classification', model="wcyat/roberta-suicide-detection-hk") def classify_text(text): # Get predictions results = classifier(text) # Extract and format the results output = {result['label']: result['score'] for result in results} return output import gradio as gr # Define Gradio interface iface = gr.Interface( fn=classify_text, # function to use for prediction inputs="text", # input type outputs="label", # output type title="Text Classification with BERT", description="Enter a sentence to classify whether it is suicidal." ) # Launch the interface iface.launch()