davidmasip commited on
Commit
39b0cd2
1 Parent(s): 9c2c9e0

racism analysis

Browse files
Files changed (2) hide show
  1. app.py +32 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ from transformers import pipeline
4
+
5
+ RACISM_MODEL = "davidmasip/racism"
6
+ racism_analysis_pipe = pipeline("text-classification",
7
+ model=RACISM_MODEL, tokenizer=RACISM_MODEL)
8
+
9
+
10
+ def racism_analysis(text):
11
+ results = racism_analysis_pipe(text)
12
+ return results[0]["label"], round(results[0]["score"], 5)
13
+
14
+
15
+ gradio_ui = gr.Interface(
16
+ fn=racism_analysis,
17
+ title="Racism Detector (Spanish)",
18
+ description="Enter some text and check if model detects bullying.",
19
+ inputs=[
20
+ gr.inputs.Textbox(lines=5, label="Paste some text here"),
21
+ ],
22
+ outputs=[
23
+ gr.outputs.Textbox(label="Label"),
24
+ gr.outputs.Textbox(label="Score"),
25
+ ],
26
+ examples=[
27
+ ["Eres mas alto que un pino y mas tonto que un pepino!"],
28
+ ["Que divertida"]
29
+ ],
30
+ )
31
+
32
+ gradio_ui.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ transformers
2
+ torch