huggingface / autotrain-advanced

🤗 AutoTrain Advanced
https://huggingface.co/autotrain
Apache License 2.0
3.8k stars 466 forks source link

error with ip adapter #442

Closed loboere closed 8 months ago

loboere commented 8 months ago

i give a error :

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
[<ipython-input-49-de98a7d384d4>](https://localhost:8080/#) in <cell line: 5>()
      3 negative_prompt = "monochrome, lowres, bad anatomy, worst quality, low quality, blurry, african , monkey"
      4 
----> 5 images = ip_model.generate(
      6     prompt=prompt, negative_prompt=negative_prompt,  faceid_embeds=faceid_embeds, num_samples=4, width=512, height=512, num_inference_steps=20, seed=2030
      7 )

3 frames
[/content/IP-Adapter/ip_adapter/ip_adapter_faceid.py](https://localhost:8080/#) in generate(self, faceid_embeds, prompt, negative_prompt, scale, num_samples, seed, guidance_scale, num_inference_steps, **kwargs)
    120         **kwargs,
    121     ):
--> 122         self.set_scale(scale)
    123 
    124 

[/content/IP-Adapter/ip_adapter/ip_adapter_faceid.py](https://localhost:8080/#) in set_scale(self, scale)
    104 
    105     def set_scale(self, scale):
--> 106         for attn_processor in self.pipe.unet.attn_processors.values():
    107             if isinstance(attn_processor, LoRAIPAttnProcessor):
    108                 attn_processor.scale = scale

[/usr/local/lib/python3.10/dist-packages/diffusers/models/modeling_utils.py](https://localhost:8080/#) in __getattr__(self, name)
    220 
    221         # call PyTorch's https://pytorch.org/docs/stable/_modules/torch/nn/modules/module.html#Module
--> 222         return super().__getattr__(name)
    223 
    224     @property

[/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py](https://localhost:8080/#) in __getattr__(self, name)
   1693             if name in modules:
   1694                 return modules[name]
-> 1695         raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
   1696 
   1697     def __setattr__(self, name: str, value: Union[Tensor, 'Module']) -> None:

AttributeError: 'UNet2DConditionModel' object has no attribute 'attn_processors'

I try to load a lora trained in autotrain and use it with ipadapter but it gives an error, this is the code

# load ip-adapter
ip_model = IPAdapterFaceID(pipe, "/content/IP-Adapter/ip-adapter-faceid_sd15.bin" ,  device)

pipe.load_lora_weights("/content/drive/MyDrive/loras/sd15/mer.safetensors")

# generate image
prompt = "  mer "
negative_prompt = "monochrome, lowres, bad anatomy, worst quality, low quality, blurry, african , monkey"

images = ip_model.generate(
    prompt=prompt, negative_prompt=negative_prompt,  faceid_embeds=faceid_embeds, num_samples=4, width=512, height=512, num_inference_steps=20, seed=2030
)
grid = image_grid(images, 1, 4)
grid
github-actions[bot] commented 8 months ago

This issue is stale because it has been open for 15 days with no activity.

github-actions[bot] commented 8 months ago

This issue was closed because it has been inactive for 2 days since being marked as stale.