Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2025-07-19 11:33:16 -04:00
parent 74d3f0bdd5
commit 3bf31eb4fd
4 changed files with 17 additions and 20 deletions
+9 -9
View File
@@ -10,7 +10,7 @@ def nudenet_censor(
method: str = Body('pixelate', title='nudenet censorship method'),
overlay: str = Body('', title='nudenet overlay image path'),
):
from scripts.nudenet import nudenet
from scripts.nudenet import nudenet # pylint: disable=no-name-in-module
base64image = image
image = api.decode_base64_to_image(image)
if nudenet.detector is None:
@@ -27,7 +27,7 @@ def prompt_check(
lang: str = Body("eng", title='allowed languages'),
alphabet: str = Body("latn", title='allowed alphabets'),
):
from scripts.nudenet import langdetect
from scripts.nudenet import langdetect # pylint: disable=no-name-in-module
res = langdetect.lang_detect(prompt)
res = ','.join(res) if isinstance(res, list) else res
lang = [a.strip() for a in lang.split(',')] if lang else []
@@ -41,7 +41,7 @@ def image_guard(
image: str = Body("", title='input image'),
policy: str = Body("", title='optional policy definition'),
):
from scripts.nudenet import imageguard
from scripts.nudenet import imageguard # pylint: disable=no-name-in-module
image = api.decode_base64_to_image(image)
res = imageguard.image_guard(image=image, policy=policy)
return res
@@ -51,14 +51,14 @@ def banned_words(
words: str = Body("", title='comma separated list of banned words'),
prompt: str = Body("", title='prompt text'),
):
from scripts.nudenet import bannedwords
from scripts.nudenet import bannedwords # pylint: disable=no-name-in-module
found = bannedwords.check_banned(words=words, prompt=prompt)
return found
def register_api():
from modules.shared import api
api.add_api_route("/sdapi/v1//nudenet", nudenet_censor, methods=["POST"], response_model=dict)
api.add_api_route("/sdapi/v1//prompt-lang", prompt_check, methods=["POST"], response_model=dict)
api.add_api_route("/sdapi/v1//image-guard", image_guard, methods=["POST"], response_model=dict)
api.add_api_route("/sdapi/v1//prompt-banned", banned_words, methods=["POST"], response_model=list)
from modules.shared import api as api_instance
api_instance.add_api_route("/sdapi/v1//nudenet", nudenet_censor, methods=["POST"], response_model=dict)
api_instance.add_api_route("/sdapi/v1//prompt-lang", prompt_check, methods=["POST"], response_model=dict)
api_instance.add_api_route("/sdapi/v1//image-guard", image_guard, methods=["POST"], response_model=dict)
api_instance.add_api_route("/sdapi/v1//prompt-banned", banned_words, methods=["POST"], response_model=list)