siddhantuniyal commited on
Commit
1eff44d
·
verified ·
1 Parent(s): 7a72cd9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -8
app.py CHANGED
@@ -2,8 +2,6 @@ import easyocr
2
  from gradio_client import Client, handle_file
3
  import pandas as pd
4
  import gradio as gr
5
- import io
6
- import base64
7
 
8
  clientImg = Client("dj-dawgs-ipd/IPD-Image-ViT-Finetune")
9
  clientEngText = Client("dj-dawgs-ipd/IPD-Text-English-Finetune")
@@ -18,13 +16,9 @@ def extract_text(image):
18
  return ' '.join([l for l in data])
19
 
20
  def predict(image):
21
-
22
- buffered = io.BytesIO()
23
- image.save(buffered, format="PNG")
24
- img_str = base64.b64encode(buffered.getvalue()).decode()
25
 
26
  imgResult = clientImg.predict(
27
- img_str,
28
  api_name="/predict"
29
  )
30
 
@@ -50,7 +44,7 @@ def predict(image):
50
  return ["hate" , None]
51
 
52
  iface = gr.Interface(fn=predict,
53
- inputs = gr.Image(type='pil'),
54
  outputs=[gr.Label(label = "Class") , gr.Label(label = "Hate Symbol(if any)")],
55
  title = "Hate Speech Detection in Image",
56
  description = "Detect hateful symbols or text in Image"
 
2
  from gradio_client import Client, handle_file
3
  import pandas as pd
4
  import gradio as gr
 
 
5
 
6
  clientImg = Client("dj-dawgs-ipd/IPD-Image-ViT-Finetune")
7
  clientEngText = Client("dj-dawgs-ipd/IPD-Text-English-Finetune")
 
16
  return ' '.join([l for l in data])
17
 
18
  def predict(image):
 
 
 
 
19
 
20
  imgResult = clientImg.predict(
21
+ image,
22
  api_name="/predict"
23
  )
24
 
 
44
  return ["hate" , None]
45
 
46
  iface = gr.Interface(fn=predict,
47
+ inputs = gr.Image(type='filepath'),
48
  outputs=[gr.Label(label = "Class") , gr.Label(label = "Hate Symbol(if any)")],
49
  title = "Hate Speech Detection in Image",
50
  description = "Detect hateful symbols or text in Image"