Spaces:
Runtime error
Runtime error
safety checker
Browse files
server/pipelines/controlnetLoraSDXL-Lightning.py
CHANGED
|
@@ -169,6 +169,7 @@ class Pipeline:
|
|
| 169 |
)
|
| 170 |
|
| 171 |
def __init__(self, args: Args, device: torch.device, torch_dtype: torch.dtype):
|
|
|
|
| 172 |
if args.safety_checker:
|
| 173 |
self.safety_checker = SafetyChecker(device=device.type)
|
| 174 |
|
|
@@ -292,9 +293,8 @@ class Pipeline:
|
|
| 292 |
images = results.images
|
| 293 |
if self.safety_checker:
|
| 294 |
images, has_nsfw_concepts = self.safety_checker(images)
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
return None
|
| 298 |
|
| 299 |
result_image = results.images[0]
|
| 300 |
if params.debug_canny:
|
|
|
|
| 169 |
)
|
| 170 |
|
| 171 |
def __init__(self, args: Args, device: torch.device, torch_dtype: torch.dtype):
|
| 172 |
+
self.safety_checker = None
|
| 173 |
if args.safety_checker:
|
| 174 |
self.safety_checker = SafetyChecker(device=device.type)
|
| 175 |
|
|
|
|
| 293 |
images = results.images
|
| 294 |
if self.safety_checker:
|
| 295 |
images, has_nsfw_concepts = self.safety_checker(images)
|
| 296 |
+
if any(has_nsfw_concepts):
|
| 297 |
+
return None
|
|
|
|
| 298 |
|
| 299 |
result_image = results.images[0]
|
| 300 |
if params.debug_canny:
|
server/pipelines/controlnetSDTurbo.py
CHANGED
|
@@ -7,18 +7,17 @@ from diffusers import (
|
|
| 7 |
from compel import Compel
|
| 8 |
import torch
|
| 9 |
from pipelines.utils.canny_gpu import SobelOperator
|
|
|
|
| 10 |
|
| 11 |
try:
|
| 12 |
import intel_extension_for_pytorch as ipex # type: ignore
|
| 13 |
except:
|
| 14 |
pass
|
| 15 |
|
| 16 |
-
import psutil
|
| 17 |
from config import Args
|
| 18 |
from pydantic import BaseModel, Field
|
| 19 |
from PIL import Image
|
| 20 |
import math
|
| 21 |
-
import time
|
| 22 |
|
| 23 |
#
|
| 24 |
taesd_model = "madebyollin/taesd"
|
|
@@ -163,17 +162,16 @@ class Pipeline:
|
|
| 163 |
)
|
| 164 |
self.pipes = {}
|
| 165 |
|
|
|
|
| 166 |
if args.safety_checker:
|
| 167 |
-
self.
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
torch_dtype=torch_dtype,
|
| 176 |
-
)
|
| 177 |
|
| 178 |
if args.taesd:
|
| 179 |
self.pipe.vae = AutoencoderTiny.from_pretrained(
|
|
@@ -269,13 +267,11 @@ class Pipeline:
|
|
| 269 |
control_guidance_start=params.controlnet_start,
|
| 270 |
control_guidance_end=params.controlnet_end,
|
| 271 |
)
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
if nsfw_content_detected:
|
| 278 |
-
return None
|
| 279 |
result_image = results.images[0]
|
| 280 |
if params.debug_canny:
|
| 281 |
# paste control_image on top of result_image
|
|
|
|
| 7 |
from compel import Compel
|
| 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
|
| 14 |
except:
|
| 15 |
pass
|
| 16 |
|
|
|
|
| 17 |
from config import Args
|
| 18 |
from pydantic import BaseModel, Field
|
| 19 |
from PIL import Image
|
| 20 |
import math
|
|
|
|
| 21 |
|
| 22 |
#
|
| 23 |
taesd_model = "madebyollin/taesd"
|
|
|
|
| 162 |
)
|
| 163 |
self.pipes = {}
|
| 164 |
|
| 165 |
+
self.safety_checker = None
|
| 166 |
if args.safety_checker:
|
| 167 |
+
self.safety_checker = SafetyChecker(device=device.type)
|
| 168 |
+
|
| 169 |
+
self.pipe = StableDiffusionControlNetImg2ImgPipeline.from_pretrained(
|
| 170 |
+
base_model,
|
| 171 |
+
controlnet=controlnet_canny,
|
| 172 |
+
safety_checker=None,
|
| 173 |
+
torch_dtype=torch_dtype,
|
| 174 |
+
)
|
|
|
|
|
|
|
| 175 |
|
| 176 |
if args.taesd:
|
| 177 |
self.pipe.vae = AutoencoderTiny.from_pretrained(
|
|
|
|
| 267 |
control_guidance_start=params.controlnet_start,
|
| 268 |
control_guidance_end=params.controlnet_end,
|
| 269 |
)
|
| 270 |
+
images = results.images
|
| 271 |
+
if self.safety_checker:
|
| 272 |
+
images, has_nsfw_concepts = self.safety_checker(images)
|
| 273 |
+
if any(has_nsfw_concepts):
|
| 274 |
+
return None
|
|
|
|
|
|
|
| 275 |
result_image = results.images[0]
|
| 276 |
if params.debug_canny:
|
| 277 |
# paste control_image on top of result_image
|