Spaces:
Sleeping
Sleeping
Commit
·
4cb0029
1
Parent(s):
afae23e
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,12 +2,13 @@ import gradio as gr
|
|
| 2 |
import requests
|
| 3 |
import base64
|
| 4 |
|
| 5 |
-
def
|
| 6 |
-
|
| 7 |
-
|
|
|
|
| 8 |
|
| 9 |
def anti_nsfw(image):
|
| 10 |
-
encoded_image =
|
| 11 |
resp = requests.get(
|
| 12 |
"https://4937ea62-c0b0-414f-afbc-53be1f5b0d06.id.repl.co/scan",
|
| 13 |
data={"base64": encoded_image}
|
|
@@ -16,7 +17,7 @@ def anti_nsfw(image):
|
|
| 16 |
|
| 17 |
iface = gr.Interface(
|
| 18 |
fn=anti_nsfw,
|
| 19 |
-
inputs=
|
| 20 |
outputs="text",
|
| 21 |
title="AntiNSFW",
|
| 22 |
description="Check if an image is safe for work (SFW) or not safe for work (NSFW)."
|
|
|
|
| 2 |
import requests
|
| 3 |
import base64
|
| 4 |
|
| 5 |
+
def image_to_base64(image):
|
| 6 |
+
with open(image.name, "rb") as file:
|
| 7 |
+
encoded_string = base64.b64encode(file.read())
|
| 8 |
+
return encoded_string.decode("utf-8")
|
| 9 |
|
| 10 |
def anti_nsfw(image):
|
| 11 |
+
encoded_image = image_to_base64(image)
|
| 12 |
resp = requests.get(
|
| 13 |
"https://4937ea62-c0b0-414f-afbc-53be1f5b0d06.id.repl.co/scan",
|
| 14 |
data={"base64": encoded_image}
|
|
|
|
| 17 |
|
| 18 |
iface = gr.Interface(
|
| 19 |
fn=anti_nsfw,
|
| 20 |
+
inputs='file',
|
| 21 |
outputs="text",
|
| 22 |
title="AntiNSFW",
|
| 23 |
description="Check if an image is safe for work (SFW) or not safe for work (NSFW)."
|