File size: 735 Bytes
57a03f1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
import gradio as gr
from transformers import pipeline
detection = pipeline('comment detection')
def score_comment(comment):
vectorized_comment = vectorizer([comment])
results = model.predict(vectorized_comment)
text = ''
for idx, col in enumerate(df.columns[2:]):
text += '{}: {}\n'.format(col, results[0][idx]>0.5)
return text
demo = gr.Interface(
fn=score_comment,
inputs=gr.inputs.Textbox(lines=2, placeholder='Comment to score'),
outputs='text',
title='Hate Comment Detector',
description='Enter comment to verify',
theme='compact',
layout='vertical',
width=600,
height=400,
allow_flagging=True,
bgcolor='#f2f2f2',
)
demo.launch(share=False) |