Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,16 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
demo = gr.load("models/meta-llama/Prompt-Guard-86M")
|
4 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
def classify_text(text):
|
5 |
+
pipe = pipeline("text-classification", model="meta-llama/Prompt-Guard-86M")
|
6 |
+
result = pipe(text)[0]
|
7 |
+
return {result['label']: result['score']}
|
8 |
+
|
9 |
+
demo = gr.Interface(
|
10 |
+
fn=classify_text,
|
11 |
+
inputs="text",
|
12 |
+
outputs="label",
|
13 |
+
title="Prompt-Guard-86M Text Classification"
|
14 |
+
)
|
15 |
|
|
|
16 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|