Spaces:
Paused
Paused
model testing
Browse files
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
|
| 3 |
+
pipe = pipeline("text-classification", model="jazbarr/jazbarr-toxicidad")
|
| 4 |
+
|
| 5 |
+
def analizar_texto(texto):
|
| 6 |
+
resultado = pipe(texto)[0]
|
| 7 |
+
label = resultado['label']
|
| 8 |
+
score = resultado['score']
|
| 9 |
+
if label == 'LABEL_1':
|
| 10 |
+
return f'This comment is toxic (score: {score})'
|
| 11 |
+
else:
|
| 12 |
+
return f'This comment is not toxic (score: {score}'
|
| 13 |
+
|
| 14 |
+
import gradio as gr
|
| 15 |
+
|
| 16 |
+
demo = gr.Interface(
|
| 17 |
+
fn=analizar_texto,
|
| 18 |
+
inputs=gr.Textbox(label='write a comment'),
|
| 19 |
+
outputs=gr.Textbox(label='result')
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
demo.launch()
|