Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
| 9 |
-
|
|
|
|
|
|
|
| 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",
|