Spaces:
Sleeping
Sleeping
sistudent-at-300100160591
commited on
Commit
Β·
fe164f1
1
Parent(s):
0840bf6
Enhanced with Engish/Tamil message and emojis
Browse files
app.py
CHANGED
@@ -10,8 +10,39 @@ def moderate_text(input_text):
|
|
10 |
result = moderator(input_text)
|
11 |
label = result[0]['label']
|
12 |
score = round(result[0]['score'] * 100, 2)
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
# Gradio interface
|
16 |
-
demo = gr.Interface(fn=moderate_text, inputs="text", outputs="text", title="AISA - Text Moderation")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
demo.launch()
|
|
|
10 |
result = moderator(input_text)
|
11 |
label = result[0]['label']
|
12 |
score = round(result[0]['score'] * 100, 2)
|
13 |
+
|
14 |
+
# Set color and emoji
|
15 |
+
if label == "toxic":
|
16 |
+
color = "#FF4C4C" # Bright red
|
17 |
+
emoji = "π‘"
|
18 |
+
message = "β οΈ Toxic content detected"
|
19 |
+
elif label == "not-toxic":
|
20 |
+
color = "#4CAF50" # Green
|
21 |
+
emoji = "π"
|
22 |
+
message = "β
Content is safe"
|
23 |
+
else:
|
24 |
+
color = "#FFD700" # Gold for unsure
|
25 |
+
emoji = "π"
|
26 |
+
message = "β οΈ Uncertain classification"
|
27 |
+
|
28 |
+
html_output = f"""
|
29 |
+
<div style='padding:1em;border-radius:10px;background-color:{color};color:white;font-weight:bold;font-size:16px'>
|
30 |
+
{emoji} {message} <br>
|
31 |
+
Confidence Score: {score}% <br>
|
32 |
+
<span style='font-size:14px; color:white; font-style:italic;'>Supports analysis in English and Tamil π</span>
|
33 |
+
</div>
|
34 |
+
"""
|
35 |
+
|
36 |
+
return html_output
|
37 |
|
38 |
# Gradio interface
|
39 |
+
#demo = gr.Interface(fn=moderate_text, inputs="text", outputs="text", title="AISA - Text Moderation", description="Enter your message in **English or Tamil** to check if it's safe or toxic. :)")
|
40 |
+
demo = gr.Interface(
|
41 |
+
fn=moderate_text,
|
42 |
+
inputs="text",
|
43 |
+
outputs=gr.HTML(),
|
44 |
+
title="AISA - Text Moderation",
|
45 |
+
description="Enter your message in **English or Tamil** to check if it's safe or toxic. π"
|
46 |
+
)
|
47 |
+
|
48 |
demo.launch()
|