Image cannot run correctly on stable-diffusion-2-1
import requests
# import ptp_utils
from PIL import Image
from io import BytesIO
import torch
import os
from diffusers import DiffusionPipeline, DDIMScheduler, DPMSolverMultistepScheduler
has_cuda = torch.cuda.is_available()
device = torch.device('cpu' if not has_cuda else 'cuda:4')
pipe = DiffusionPipeline.from_pretrained(
    "./models/stable-diffusion-2-1",
        safety_checker=None,
    use_auth_token=True,
    custom_pipeline="imagic_stable_diffusion",
).to(device)
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)

generator = torch.Generator("cuda").manual_seed(1)
seed = 0
prompt = "A laughing man"
url = './images/p1.jpeg'
init_image = Image.open(url).convert("RGB")
init_image = init_image.resize((768, 768))

res = pipe.train(
    prompt,
    image=init_image,
    text_embedding_optimization_steps = 1000,
    embedding_learning_rate = 2e-3,
    model_fine_tuning_optimization_steps = 1500,
    diffusion_model_learning_rate = 5e-7,
    generator=generator)
res = pipe(alpha=0.3, guidance_scale=7.5, num_inference_steps=50)
os.makedirs("imagic", exist_ok=True)
image = res.images[0]I testImagicon stable-diffusion-2-1, but I cannot got a reasonable output. The same code I have test on stable-diffusion-v1-5 which works well.download512×512 65.5 KB