King-8 commited on
Commit
892a4e9
·
verified ·
1 Parent(s): b4ea96d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -1,18 +1,27 @@
1
  import gradio as gr
2
  from transformers import pipeline, AutoTokenizer, AutoModelForSequenceClassification
3
 
4
-
5
  tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased")
6
  model = AutoModelForSequenceClassification.from_pretrained("King-8/interview_statements")
7
 
8
  classifier = pipeline("text-classification", model=model, tokenizer=tokenizer)
9
 
 
 
 
 
 
 
 
 
10
  def classify_statement(statement):
11
  prediction = classifier(statement)[0]
12
 
13
  label = prediction["label"]
14
 
15
- return f"Predicted Category: {label}"
 
 
16
 
17
  gr.Interface(
18
  fn=classify_statement,
 
1
  import gradio as gr
2
  from transformers import pipeline, AutoTokenizer, AutoModelForSequenceClassification
3
 
 
4
  tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased")
5
  model = AutoModelForSequenceClassification.from_pretrained("King-8/interview_statements")
6
 
7
  classifier = pipeline("text-classification", model=model, tokenizer=tokenizer)
8
 
9
+ label_map = {
10
+ "LABEL_0": "Education & Innovation",
11
+ "LABEL_1": "Community & Health",
12
+ "LABEL_2": "Family & History",
13
+ "LABEL_3": "Faith & Spirituality",
14
+ "LABEL_4": "Business & Finance"
15
+ }
16
+
17
  def classify_statement(statement):
18
  prediction = classifier(statement)[0]
19
 
20
  label = prediction["label"]
21
 
22
+ predicted_category = label_map.get(label, "Unknown Category") # Default to "Unknown" if not found
23
+
24
+ return f"Predicted Category: {predicted_category}"
25
 
26
  gr.Interface(
27
  fn=classify_statement,