Skip to content

After call IP - Adapter unload method StableDiffusionImg2ImgPipeline(**pipe.components) error #6818

@Honey-666

Description

@Honey-666

hi!
When I used 1.5 to load the model, I enabled the security check mechanism, uninstalled after using the IP-Adapter, and generated the pipe from the previous pipe, which would throw an error with the security check parameters

if hasattr(self, "feature_extractor") and getattr(self, "feature_extractor", None) is not None:

if safety_checker is not None and feature_extractor is None:

os:
diffusers==0.26.0

this is my code:

import torch
from PIL import Image
from diffusers import StableDiffusionPipeline, StableDiffusionImg2ImgPipeline

model_path = 'C:\\work\\pythonProject\\aidazuo\\models\\Stable-diffusion\\stable-diffusion-v1-5'
ip_adapter_path = 'C:\\work\\pythonProject\\aidazuo\\models\\IP-Adapter'
ip_img_path = 'C:\\work\\pythonProject\\aidazuo\\jupyter-script\\test-img\\vermeer.png'

pipe = StableDiffusionPipeline.from_pretrained(
    model_path,
    variant="fp16",
    torch_dtype=torch.float16).to("cuda")

pipe.load_ip_adapter(ip_adapter_path, subfolder="models", weight_name="ip-adapter-plus_sd15.bin")
pipe.set_ip_adapter_scale(0.6)

ip_adapter_img = Image.open(ip_img_path)

images = pipe(
    prompt='a beautiful girl',
    ip_adapter_image=ip_adapter_img,
    negative_prompt="",
    num_inference_steps=30,
    num_images_per_prompt=1,
    width=512,
    height=512).images

pipe.unload_ip_adapter()

imagePipe = StableDiffusionImg2ImgPipeline(**pipe.components).to("cuda")

images2 = imagePipe(num_inference_steps=30,
                    image=images[0],
                    strength=0.5,
                    prompt='a beautiful girl').images

for img in images2:
    print(img)
    img.show()

error_img

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions