safety_checker
Browse files
server/pipelines/controlnetLoraSDXL-Lightning.py
CHANGED
@@ -296,7 +296,7 @@ class Pipeline:
|
|
296 |
if any(has_nsfw_concepts):
|
297 |
return None
|
298 |
|
299 |
-
result_image =
|
300 |
if params.debug_canny:
|
301 |
# paste control_image on top of result_image
|
302 |
w0, h0 = (200, 200)
|
|
|
296 |
if any(has_nsfw_concepts):
|
297 |
return None
|
298 |
|
299 |
+
result_image = images[0]
|
300 |
if params.debug_canny:
|
301 |
# paste control_image on top of result_image
|
302 |
w0, h0 = (200, 200)
|
server/pipelines/controlnetSDTurbo.py
CHANGED
@@ -272,7 +272,8 @@ class Pipeline:
|
|
272 |
images, has_nsfw_concepts = self.safety_checker(images)
|
273 |
if any(has_nsfw_concepts):
|
274 |
return None
|
275 |
-
|
|
|
276 |
if params.debug_canny:
|
277 |
# paste control_image on top of result_image
|
278 |
w0, h0 = (200, 200)
|
|
|
272 |
images, has_nsfw_concepts = self.safety_checker(images)
|
273 |
if any(has_nsfw_concepts):
|
274 |
return None
|
275 |
+
|
276 |
+
result_image = images[0]
|
277 |
if params.debug_canny:
|
278 |
# paste control_image on top of result_image
|
279 |
w0, h0 = (200, 200)
|
server/pipelines/controlnetSDXLTurbo.py
CHANGED
@@ -7,6 +7,7 @@ from diffusers import (
|
|
7 |
from compel import Compel, ReturnedEmbeddingsType
|
8 |
import torch
|
9 |
from pipelines.utils.canny_gpu import SobelOperator
|
|
|
10 |
|
11 |
try:
|
12 |
import intel_extension_for_pytorch as ipex # type: ignore
|
@@ -170,19 +171,16 @@ class Pipeline:
|
|
170 |
vae = AutoencoderKL.from_pretrained(
|
171 |
"madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch_dtype
|
172 |
)
|
|
|
173 |
if args.safety_checker:
|
174 |
-
self.
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
safety_checker=None,
|
183 |
-
controlnet=controlnet_canny,
|
184 |
-
vae=vae,
|
185 |
-
)
|
186 |
self.canny_torch = SobelOperator(device=device)
|
187 |
|
188 |
if args.sfast:
|
@@ -277,14 +275,13 @@ class Pipeline:
|
|
277 |
control_guidance_end=params.controlnet_end,
|
278 |
)
|
279 |
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
result_image = results.images[0]
|
288 |
if params.debug_canny:
|
289 |
# paste control_image on top of result_image
|
290 |
w0, h0 = (200, 200)
|
|
|
7 |
from compel import Compel, ReturnedEmbeddingsType
|
8 |
import torch
|
9 |
from pipelines.utils.canny_gpu import SobelOperator
|
10 |
+
from pipelines.utils.safety_checker import SafetyChecker
|
11 |
|
12 |
try:
|
13 |
import intel_extension_for_pytorch as ipex # type: ignore
|
|
|
171 |
vae = AutoencoderKL.from_pretrained(
|
172 |
"madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch_dtype
|
173 |
)
|
174 |
+
self.safety_checker = None
|
175 |
if args.safety_checker:
|
176 |
+
self.safety_checker = SafetyChecker(device=device.type)
|
177 |
+
|
178 |
+
self.pipe = StableDiffusionXLControlNetImg2ImgPipeline.from_pretrained(
|
179 |
+
model_id,
|
180 |
+
safety_checker=None,
|
181 |
+
controlnet=controlnet_canny,
|
182 |
+
vae=vae,
|
183 |
+
)
|
|
|
|
|
|
|
|
|
184 |
self.canny_torch = SobelOperator(device=device)
|
185 |
|
186 |
if args.sfast:
|
|
|
275 |
control_guidance_end=params.controlnet_end,
|
276 |
)
|
277 |
|
278 |
+
images = results.images
|
279 |
+
if self.safety_checker:
|
280 |
+
images, has_nsfw_concepts = self.safety_checker(images)
|
281 |
+
if any(has_nsfw_concepts):
|
282 |
+
return None
|
283 |
+
|
284 |
+
result_image = images[0]
|
|
|
285 |
if params.debug_canny:
|
286 |
# paste control_image on top of result_image
|
287 |
w0, h0 = (200, 200)
|