Spaces:
Runtime error
Runtime error
Tirath5504
commited on
Commit
•
28ad0c2
1
Parent(s):
e16a35a
Update app.py
Browse files
app.py
CHANGED
@@ -32,7 +32,7 @@ def predict(image):
|
|
32 |
|
33 |
engResult = clientEngText.predict(
|
34 |
text=ocr_text,
|
35 |
-
api_name="/
|
36 |
)
|
37 |
|
38 |
hingResult = clientHingText.predict(
|
@@ -44,9 +44,9 @@ def predict(image):
|
|
44 |
|
45 |
if profanityFound:
|
46 |
return ["hate", "Profanity Found"]
|
47 |
-
elif engResult[0] != "NEITHER":
|
48 |
return ["hate", f"Result: {engResult}, Text: {ocr_text}"]
|
49 |
-
elif hingResult[0] != "NAG":
|
50 |
return ["hate", f"Result: {hingResult}, Text: {ocr_text}"]
|
51 |
else:
|
52 |
return ["not_hate", "No hate found, yay!"]
|
@@ -58,7 +58,7 @@ def predict(image):
|
|
58 |
|
59 |
iface = gr.Interface(fn=predict,
|
60 |
inputs = gr.Image(type='filepath'),
|
61 |
-
outputs=[gr.Label(label = "Class (
|
62 |
title = "Hate Speech Detection in Image",
|
63 |
description = "Detect hateful symbols or text in Image"
|
64 |
)
|
|
|
32 |
|
33 |
engResult = clientEngText.predict(
|
34 |
text=ocr_text,
|
35 |
+
api_name="/predict"
|
36 |
)
|
37 |
|
38 |
hingResult = clientHingText.predict(
|
|
|
44 |
|
45 |
if profanityFound:
|
46 |
return ["hate", "Profanity Found"]
|
47 |
+
elif engResult[0] != "NEITHER" or engResult[1] < 0.9:
|
48 |
return ["hate", f"Result: {engResult}, Text: {ocr_text}"]
|
49 |
+
elif hingResult[0] != "NAG" or hingResult:
|
50 |
return ["hate", f"Result: {hingResult}, Text: {ocr_text}"]
|
51 |
else:
|
52 |
return ["not_hate", "No hate found, yay!"]
|
|
|
58 |
|
59 |
iface = gr.Interface(fn=predict,
|
60 |
inputs = gr.Image(type='filepath'),
|
61 |
+
outputs=[gr.Label(label = "Class (hate or not_hate)") , gr.Label(label = "Explanation")],
|
62 |
title = "Hate Speech Detection in Image",
|
63 |
description = "Detect hateful symbols or text in Image"
|
64 |
)
|