Spaces:
Runtime error
Runtime error
siddhantuniyal
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -18,12 +18,14 @@ def extract_text(image):
|
|
18 |
def predict(image):
|
19 |
|
20 |
imgResult = clientImg.predict(
|
21 |
-
image,
|
22 |
api_name="/predict"
|
23 |
)
|
24 |
|
25 |
-
|
26 |
-
|
|
|
|
|
27 |
else:
|
28 |
|
29 |
ocr_text = extract_text(image)
|
@@ -39,9 +41,9 @@ def predict(image):
|
|
39 |
)
|
40 |
|
41 |
if engResult[0] == "NEITHER" or hingResult[0] == "NAG":
|
42 |
-
return ["not_hate" ,
|
43 |
else:
|
44 |
-
return ["hate" ,
|
45 |
|
46 |
iface = gr.Interface(fn=predict,
|
47 |
inputs = gr.Image(type='filepath'),
|
@@ -52,4 +54,3 @@ iface = gr.Interface(fn=predict,
|
|
52 |
|
53 |
if __name__ == "__main__":
|
54 |
iface.launch()
|
55 |
-
|
|
|
18 |
def predict(image):
|
19 |
|
20 |
imgResult = clientImg.predict(
|
21 |
+
image=handle_file(image),
|
22 |
api_name="/predict"
|
23 |
)
|
24 |
|
25 |
+
label , confidence = imgResult[0]['label'] , float(imgResult[1]['label'])
|
26 |
+
|
27 |
+
if confidence > 0.95:
|
28 |
+
return ["hate" , label]
|
29 |
else:
|
30 |
|
31 |
ocr_text = extract_text(image)
|
|
|
41 |
)
|
42 |
|
43 |
if engResult[0] == "NEITHER" or hingResult[0] == "NAG":
|
44 |
+
return ["not_hate" , "No Hate Symbols Detected"]
|
45 |
else:
|
46 |
+
return ["hate" , "No Hate Symbols Detected"]
|
47 |
|
48 |
iface = gr.Interface(fn=predict,
|
49 |
inputs = gr.Image(type='filepath'),
|
|
|
54 |
|
55 |
if __name__ == "__main__":
|
56 |
iface.launch()
|
|