| 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) |