|
|
|
import PIL |
|
from transformers import CLIPImageProcessor |
|
from diffusers.pipelines.stable_diffusion import StableDiffusionSafetyChecker |
|
|
|
feature_extractor = CLIPImageProcessor.from_pretrained("runwayml/stable-diffusion-v1-5", subfolder="feature_extractor") |
|
safety_checker = StableDiffusionSafetyChecker.from_pretrained("runwayml/stable-diffusion-v1-5", subfolder="safety_checker") |
|
device = "cpu" |
|
|
|
image = PIL.Image.open("/home/patrick/images/0.png") |
|
|
|
safety_checker_input = feature_extractor(image, return_tensors="pt").to(device) |
|
image, has_nsfw_concept = safety_checker(images=image, clip_input=safety_checker_input.pixel_values) |
|
|