ImagineAI-Real commited on
Commit
de18720
·
1 Parent(s): 5f3c0b3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -2,13 +2,12 @@ import gradio as gr
2
  import requests
3
  import base64
4
 
5
- def encode_image(image_path):
6
- with open(image_path, "rb") as image_file:
7
- encoded_string = base64.b64encode(image_file.read()).decode("utf-8")
8
  return encoded_string
9
 
10
- def anti_nsfw(image_path):
11
- encoded_image = encode_image(image_path)
12
  resp = requests.get(
13
  "https://4937ea62-c0b0-414f-afbc-53be1f5b0d06.id.repl.co/scan",
14
  data={"base64": f"data:image/png;base64,{encoded_image}"}
@@ -17,10 +16,10 @@ def anti_nsfw(image_path):
17
 
18
  iface = gr.Interface(
19
  fn=anti_nsfw,
20
- inputs="text",
21
  outputs="text",
22
  title="AntiNSFW",
23
  description="Check if an image is safe for work (SFW) or not safe for work (NSFW)."
24
  )
25
 
26
- iface.launch()
 
2
  import requests
3
  import base64
4
 
5
+ def encode_image(image):
6
+ encoded_string = base64.b64encode(image.read()).decode("utf-8")
 
7
  return encoded_string
8
 
9
+ def anti_nsfw(image):
10
+ encoded_image = encode_image(image)
11
  resp = requests.get(
12
  "https://4937ea62-c0b0-414f-afbc-53be1f5b0d06.id.repl.co/scan",
13
  data={"base64": f"data:image/png;base64,{encoded_image}"}
 
16
 
17
  iface = gr.Interface(
18
  fn=anti_nsfw,
19
+ inputs="file",
20
  outputs="text",
21
  title="AntiNSFW",
22
  description="Check if an image is safe for work (SFW) or not safe for work (NSFW)."
23
  )
24
 
25
+ iface.launch()