我正在研究一个稳定的扩散模型,同时实现了一个简单的代码示例,下面的链接中给出。我已经按照链接中提到的相同步骤,但它仍然给出了一个错误
https://replicate.com/lambdal/stable-diffusion-image-variation
编码
from pathlib import Path
from lambda_diffusers import StableDiffusionImageEmbedPipeline
from PIL import Image
import torch
#device = "cuda" if torch.cuda.is_available() else "cpu"
device = "cpu"
pipe = StableDiffusionImageEmbedPipeline.from_pretrained("lambdalabs/sd-image-variations-diffusers")
pipe = pipe.to(device)
im = Image.open("/home/cvpr/Desktop/bird.jpg")
num_samples = 4
image = pipe(num_samples*[im], guidance_scale=3.0)
image = image["sample"]
base_path = Path("outputs/im2im")
base_path.mkdir(exist_ok=True, parents=True)
for idx, im in enumerate(image):
im.save(base_path/f"{idx:06}.jpg")
Trackback
Traceback (most recent call last):
File "/media/cvpr/CM_1/lambda-diffusers/image_variation.py", line 46, in <module>
image = pipe(num_samples*[im], guidance_scale=3.0)
File "/media/cvpr/CM_1/lambda-diffusers/.venv/lib/python3.8/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "/media/cvpr/CM_1/lambda-diffusers/lambda_diffusers/pipelines/pipeline_stable_diffusion_im_embed.py", line 77, in __call__
image_embeddings = self.image_encoder.get_image_features(**input_image)
File "/media/cvpr/CM_1/lambda-diffusers/.venv/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1614, in __getattr__
raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'CLIPVisionModelWithProjection' object has no attribute 'get_image_features'
1条答案
按热度按时间bt1cpqcv1#
这不是版本冲突问题,您必须修改
pipe
部分发件人:
收件人: