Spaces:
Runtime error
Runtime error
import gradio as gr | |
import os | |
def get_hatespeech_score(text): | |
io = gr.Interface.load("unhcr/hatespeech-detection") | |
return io(text) | |
def text_analysis(text): | |
label_1 = get_hatespeech_score(text) | |
html = '''<!doctype html> | |
<html> | |
<body> | |
<h1>Text Sentiment Analysis</h1> | |
<div style=background-color:#d9eee1> | |
<h2>Overall Sentiment</h2> | |
<p>{}</p> | |
</div> | |
<div style=background-color:#fff4a3> | |
<h2>Adult Content</h2> | |
<p>{}</p> | |
</div> | |
<div style=background-color:#ffc0c7> | |
<h2>Hate Speech</h2> | |
<p>{}</p> | |
</div> | |
<div style=background-color:#cfb0b1> | |
<h2>Text Summary</h2> | |
<p>{}</p> | |
</div> | |
</body> | |
</html> | |
'''.format("Alpha", label_1, "Gamma", "Theta") | |
return html | |
demo = gr.Interface( | |
text_analysis, | |
gr.Textbox(placeholder="Enter sentence here..."), | |
["html"], | |
examples=[ | |
["What a beautiful morning for a walk!"], | |
["It was the best of times, it was the worst of times."], | |
], | |
) | |
demo.launch() | |