Spaces:
Runtime error
Runtime error
File size: 751 Bytes
26961aa f343adf 26961aa f343adf 92836c7 f343adf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import gradio as gr
from transformers import pipeline
# Load pre-trained sentiment-analysis pipeline
classifier = pipeline('text-classification', model="wcyat/bert-suicide-detection-hk-large")
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() |