Spaces:
Sleeping
Sleeping
File size: 1,166 Bytes
e441976 892a4e9 e441976 b4ea96d e441976 b4ea96d 892a4e9 e441976 |
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 27 28 29 30 31 32 33 |
import gradio as gr
from transformers import pipeline, AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased")
model = AutoModelForSequenceClassification.from_pretrained("King-8/interview_statements")
classifier = pipeline("text-classification", model=model, tokenizer=tokenizer)
label_map = {
"LABEL_0": "Education & Innovation",
"LABEL_1": "Community & Health",
"LABEL_2": "Family & History",
"LABEL_3": "Faith & Spirituality",
"LABEL_4": "Business & Finance"
}
def classify_statement(statement):
prediction = classifier(statement)[0]
label = prediction["label"]
predicted_category = label_map.get(label, "Unknown Category") # Default to "Unknown" if not found
return f"Predicted Category: {predicted_category}"
gr.Interface(
fn=classify_statement,
inputs=gr.Textbox(label="Enter a community statement"),
outputs=gr.Textbox(label="Predicted Category"),
title="Interview Statement Categorizer",
description="This app predicts the category of a community statement based on trained data from community interviews."
).launch()
|