ThirdFourthFifth commited on
Commit
500d27e
·
verified ·
1 Parent(s): 7550195

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -1,7 +1,19 @@
 
1
  import gradio as gr
2
- from transformers import pipeline as hf_pipeline
3
 
 
4
 
5
- gr.Interface.load("TostAI/nsfw-text-detection-large").launch()
 
 
6
 
 
 
 
 
 
 
7
 
 
 
 
1
+
2
  import gradio as gr
3
+ 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 input_txt, {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.Text(label="Processed Text"), gr.Label(label="Result", num_top_classes=3)],
15
+ title="NSFW Prediction",
16
+ )
17
 
18
+ if __name__ == "__main__":
19
+ gradio_app.launch()