Skip to content

Commit 7534b51

Browse files
[Bug fix] Fix img2img processor with safety checker (huggingface#3127)
Fix img2img processor with safety checker
1 parent 1be9d5b commit 7534b51

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pipelines/stable_diffusion/safety_checker.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ def forward(self, clip_input, images):
8585

8686
for idx, has_nsfw_concept in enumerate(has_nsfw_concepts):
8787
if has_nsfw_concept:
88-
images[idx] = np.zeros(images[idx].shape) # black image
88+
if torch.is_tensor(images) or torch.is_tensor(images[0]):
89+
images[idx] = torch.zeros_like(images[idx]) # black image
90+
else:
91+
images[idx] = np.zeros(images[idx].shape) # black image
8992

9093
if any(has_nsfw_concepts):
9194
logger.warning(

0 commit comments

Comments
 (0)