Spaces:
Sleeping
Sleeping
Update app.py
Browse files123456789101112131415161718import gradio as grfrom transformers import pipeline, AutoTokenizer, AutoModelForSequenceClassificationtokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased")model = AutoModelForSequenceClassification.from_pretrained("King-8/interview_statements")classifier = pipeline("text-classification", model=model, tokenizer=tokenizer)def classify_statement(statement):prediction = classifier(statement)[0]label = prediction["label"]return f"Predicted Category: {label}"gr.Interface(fn=classify_statement,123456789101112131415161718192021222324252627import gradio as grfrom transformers import pipeline, AutoTokenizer, AutoModelForSequenceClassificationtokenizer = 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 foundreturn f"Predicted Category: {predicted_category}"gr.Interface(fn=classify_statement,
app.py+11-2