Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -111,6 +111,12 @@ def _infer(input_image, prompt, seed=42, randomize_seed=False, guidance_scale=2.
|
|
| 111 |
try:
|
| 112 |
if input_image:
|
| 113 |
input_image = input_image.convert("RGB")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
image = pipe(
|
| 115 |
image=input_image,
|
| 116 |
prompt=prompt,
|
|
@@ -129,7 +135,7 @@ def _infer(input_image, prompt, seed=42, randomize_seed=False, guidance_scale=2.
|
|
| 129 |
callback_on_step_end=callback_fn,
|
| 130 |
generator=torch.Generator().manual_seed(seed),
|
| 131 |
).images[0]
|
| 132 |
-
|
| 133 |
if nsfw_model and nsfw_processor:
|
| 134 |
if detect_nsfw(image):
|
| 135 |
msg = "Generated image contains NSFW content and cannot be displayed. Please modify your prompt and try again."
|
|
|
|
| 111 |
try:
|
| 112 |
if input_image:
|
| 113 |
input_image = input_image.convert("RGB")
|
| 114 |
+
# NSFW 检测
|
| 115 |
+
if nsfw_model and nsfw_processor:
|
| 116 |
+
if detect_nsfw(input_image):
|
| 117 |
+
msg = "Generated image contains NSFW content and cannot be displayed. Please modify your prompt and try again."
|
| 118 |
+
raise Exception(msg)
|
| 119 |
+
|
| 120 |
image = pipe(
|
| 121 |
image=input_image,
|
| 122 |
prompt=prompt,
|
|
|
|
| 135 |
callback_on_step_end=callback_fn,
|
| 136 |
generator=torch.Generator().manual_seed(seed),
|
| 137 |
).images[0]
|
| 138 |
+
# NSFW 检测
|
| 139 |
if nsfw_model and nsfw_processor:
|
| 140 |
if detect_nsfw(image):
|
| 141 |
msg = "Generated image contains NSFW content and cannot be displayed. Please modify your prompt and try again."
|