From 3d444954add6b98acf9911163b3a4248453a4384 Mon Sep 17 00:00:00 2001 From: Kaustubh Maske Patil <37668193+nikochiko@users.noreply.github.com> Date: Wed, 11 Oct 2023 13:05:51 +0530 Subject: [PATCH] rename: safety_checker -> safety_checker_text, check_image -> safety_checker_image --- daras_ai_v2/azure_image_moderation.py | 2 +- recipes/DeforumSD.py | 4 ++-- recipes/Img2Img.py | 8 ++++---- recipes/LipsyncTTS.py | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/daras_ai_v2/azure_image_moderation.py b/daras_ai_v2/azure_image_moderation.py index 4e49a1dd3..0b2d3f9fc 100644 --- a/daras_ai_v2/azure_image_moderation.py +++ b/daras_ai_v2/azure_image_moderation.py @@ -30,7 +30,7 @@ def is_image_nsfw(image_url: str, cache: bool = False) -> bool: return response["IsImageAdultClassified"] -def check_image(image_url: str, cache: bool = False) -> None: +def safety_checker_image(image_url: str, cache: bool = False) -> None: if is_image_nsfw(image_url=image_url, cache=cache): raise ValueError( "Your request was rejected as a result of our safety system. " diff --git a/recipes/DeforumSD.py b/recipes/DeforumSD.py index f523ba14e..328c4537d 100644 --- a/recipes/DeforumSD.py +++ b/recipes/DeforumSD.py @@ -442,7 +442,7 @@ def run(self, state: dict): yield if not self.request.user.disable_safety_checker: - safety_checker(self.preview_input(state)) + safety_checker_text(self.preview_input(state)) state["output_video"] = call_celery_task_outfile( "deforum", @@ -470,7 +470,7 @@ def run(self, state: dict): )[0] -def safety_checker(text_input: str): +def safety_checker_text(text_input: str): # ge the billing account for the checker billing_account = AppUser.objects.get_or_create_from_email( settings.SAFTY_CHECKER_BILLING_EMAIL diff --git a/recipes/Img2Img.py b/recipes/Img2Img.py index 12f3af3d7..2c7c0a5c4 100644 --- a/recipes/Img2Img.py +++ b/recipes/Img2Img.py @@ -17,8 +17,8 @@ controlnet, ControlNetModels, ) -from daras_ai_v2.azure_image_moderation import check_image -from recipes.DeforumSD import safety_checker +from daras_ai_v2.azure_image_moderation import safety_checker_image +from recipes.DeforumSD import safety_checker_text class Img2ImgPage(BasePage): @@ -147,8 +147,8 @@ def run(self, state: dict) -> typing.Iterator[str | None]: yield "Generating Image..." if not self.request.user.disable_safety_checker: - safety_checker(request.text_prompt) - check_image(request.input_image) + safety_checker_text(request.text_prompt) + safety_checker_image(request.input_image) if request.selected_model == Img2ImgModels.instruct_pix2pix.name: state["output_images"] = instruct_pix2pix( diff --git a/recipes/LipsyncTTS.py b/recipes/LipsyncTTS.py index d31171596..71783d09e 100644 --- a/recipes/LipsyncTTS.py +++ b/recipes/LipsyncTTS.py @@ -4,7 +4,7 @@ import gooey_ui as st from bots.models import Workflow -from recipes.DeforumSD import safety_checker +from recipes.DeforumSD import safety_checker_text from recipes.Lipsync import LipsyncPage from recipes.TextToSpeech import TextToSpeechPage, TextToSpeechProviders from daras_ai_v2.loom_video_widget import youtube_video @@ -115,7 +115,7 @@ def render_settings(self): def run(self, state: dict) -> typing.Iterator[str | None]: if not self.request.user.disable_safety_checker: - safety_checker(state["text_prompt"]) + safety_checker_text(state["text_prompt"]) yield from TextToSpeechPage.run(self, state) # IMP: Copy output of TextToSpeechPage "audio_url" to Lipsync as "input_audio"