From 9418dc41d5610087662ea995538c231a6449a788 Mon Sep 17 00:00:00 2001 From: Kaustubh Maske Patil <37668193+nikochiko@users.noreply.github.com> Date: Thu, 29 Aug 2024 20:43:31 +0530 Subject: [PATCH] feat: Add safety checker for QR code recipe (#449) * feat: Add safety checker for QR code recipe * fix: run safety checker before generating QR code --- recipes/QRCodeGenerator.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/recipes/QRCodeGenerator.py b/recipes/QRCodeGenerator.py index a2f6652fe..cfa9ce013 100644 --- a/recipes/QRCodeGenerator.py +++ b/recipes/QRCodeGenerator.py @@ -28,6 +28,7 @@ ) from daras_ai_v2.loom_video_widget import youtube_video from daras_ai_v2.repositioning import reposition_object, repositioning_preview_widget +from daras_ai_v2.safety_checker import safety_checker from daras_ai_v2.stable_diffusion import ( Text2ImgModels, controlnet, @@ -472,6 +473,9 @@ def _render_outputs(self, state: dict, max_count: int | None = None): def run(self, state: dict) -> typing.Iterator[str | None]: request: QRCodeGeneratorPage.RequestModel = self.RequestModel.parse_obj(state) + yield "Running safety checker..." + safety_checker(text=request.text_prompt, image=request.image_prompt) + yield "Generating QR Code..." image, qr_code_data, did_shorten = generate_and_upload_qr_code( request, self.request.user