ThirdFourthFifth commited on
Commit
338a141
·
verified ·
1 Parent(s): b3cb78d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
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
- #def predict(input_txt):
8
- # predictions = pipe(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(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()