Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,16 +4,18 @@ from transformers import pipeline
|
|
| 4 |
|
| 5 |
pipeline = pipeline(task="text-classification", model="TostAI/nsfw-text-detection-large")
|
| 6 |
|
| 7 |
-
def predict(input_txt):
|
| 8 |
-
predictions = pipeline(input_txt)
|
| 9 |
-
return {p["label"]: p["score"] for p in predictions}
|
| 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 |
if __name__ == "__main__":
|
| 19 |
gradio_app.launch()
|
|
|
|
| 4 |
|
| 5 |
pipeline = pipeline(task="text-classification", model="TostAI/nsfw-text-detection-large")
|
| 6 |
|
| 7 |
+
#def predict(input_txt):
|
| 8 |
+
# predictions = pipeline(input_txt)
|
| 9 |
+
# return {p["label"]: p["score"] for p in predictions}
|
| 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(pipeline)
|
| 19 |
|
| 20 |
if __name__ == "__main__":
|
| 21 |
gradio_app.launch()
|