VerifiedPrompts commited on
Commit
8d6f754
·
verified ·
1 Parent(s): c357882

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -1,13 +1,17 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
 
4
  model = "VerifiedPrompts/CNTXT-Filter-Prompt-Opt"
5
- classifier = pipeline("text-classification", model=model)
6
 
7
  def classify(prompt):
8
- result = classifier(prompt)[0]
9
- return f"{result['label']} (score: {round(result['score'], 3)})"
 
 
10
 
 
11
  demo = gr.Interface(
12
  fn=classify,
13
  inputs="textbox",
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # Load your model with full label scoring
5
  model = "VerifiedPrompts/CNTXT-Filter-Prompt-Opt"
6
+ classifier = pipeline("text-classification", model=model, return_all_scores=True)
7
 
8
  def classify(prompt):
9
+ results = classifier(prompt)[0] # list of all label scores
10
+ for r in results:
11
+ print(f"{r['label']} → {round(r['score'], 3)}") # optional log
12
+ return "\n".join([f"{r['label']}: {round(r['score'], 3)}" for r in results])
13
 
14
+ # Gradio UI
15
  demo = gr.Interface(
16
  fn=classify,
17
  inputs="textbox",