Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
moderate_pipe = pipeline("text-classification", model="KoalaAI/Text-Moderation")
|
5 |
+
|
6 |
+
def moderate(text):
|
7 |
+
results = moderate_pipe(text)
|
8 |
+
return {r["label"]: r["score"] for r in results}
|
9 |
+
|
10 |
+
gr.Interface(fn=moderate, inputs="text", outputs="label").launch()
|