Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,18 +4,18 @@ from transformers import pipeline
|
|
| 4 |
|
| 5 |
pipe = pipeline(task="text-classification", model="TostAI/nsfw-text-detection-large")
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
|
| 18 |
-
gradio_app = gr.Interface.from_pipeline(pipe)
|
| 19 |
|
| 20 |
if __name__ == "__main__":
|
| 21 |
gradio_app.launch()
|
|
|
|
| 4 |
|
| 5 |
pipe = pipeline(task="text-classification", model="TostAI/nsfw-text-detection-large")
|
| 6 |
|
| 7 |
+
def predict(input_txt):
|
| 8 |
+
predictions = pipe(input_txt)
|
| 9 |
+
return {p["label"]: p["score"] for p in predictions[0]}
|
| 10 |
|
| 11 |
+
gradio_app = gr.Interface(
|
| 12 |
+
predict,
|
| 13 |
+
inputs=gr.Textbox(label="Input text"),
|
| 14 |
+
outputs=gr.Label(label="Result"),
|
| 15 |
+
title="NSFW Prediction",
|
| 16 |
+
)
|
| 17 |
|
| 18 |
+
#gradio_app = gr.Interface.from_pipeline(pipe)
|
| 19 |
|
| 20 |
if __name__ == "__main__":
|
| 21 |
gradio_app.launch()
|