Spaces:
Runtime error
Runtime error
File size: 1,271 Bytes
cf160e1 |
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 32 33 34 35 36 37 38 39 |
import gradio as gr
import re
from transformers import pipeline
sp_model = "SineTheta/Spam_and_bully_detection"
ca_model = "SineTheta/Spam_and_bully_detection"
sp_analysis = pipeline("text-classification", model=sp_model, tokenizer=sp_model)
ca_analysis = pipeline("text-classification", model=ca_model, tokenizer=ca_model)
def bullying_analysis(language, text):
if language == 'English':
results = sp_analysis(text)
elif language == 'French':
results = ca_analysis(text)
return results[0]["label"], round(results[0]["score"], 5)
gradio_ui = gr.Interface(
fn=bullying_analysis,
title="CyberBullying Detector (Spanish/Catalan)",
description="Enter some text and check if the model detects bullying.",
inputs=[
gr.inputs.Radio(['Spanish','Catalan'],label='Language',),
gr.inputs.Textbox(lines=5, label="Paste some text here"),
],
outputs=[
gr.outputs.Textbox(label="Label"),
gr.outputs.Textbox(label="Score"),
],
examples=[
['Spanish', "Eres mas alto que un pino y mas tonto que un pepino!"],
['Catalan', "Ets un barrufet!"],
['Spanish', "Estas mas gordo que una foca!"],
['Catalan', "Ets mes lleig que un pecat!"],
],
)
gradio_ui.launch() |