Skip to content

Commit

Permalink
rename: safety_checker -> safety_checker_text, check_image -> safety_…
Browse files Browse the repository at this point in the history
…checker_image
  • Loading branch information
nikochiko committed Oct 11, 2023
1 parent e266df8 commit 3d44495
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion daras_ai_v2/azure_image_moderation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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. "
Expand Down
4 changes: 2 additions & 2 deletions recipes/DeforumSD.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions recipes/Img2Img.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions recipes/LipsyncTTS.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 3d44495

Please sign in to comment.