cloneofsimo / lora

Using Low-rank adaptation to quickly fine-tune diffusion models.
https://arxiv.org/abs/2106.09685
Apache License 2.0
7.08k stars 481 forks source link

RecursionError: maximum recursion depth exceeded while calling a Python object #230

Open sabetAI opened 1 year ago

sabetAI commented 1 year ago

I'm trying to run inject_trainable_lora_extended on a UNet2DConditionModel, with Conv2d as the target module:

from lora_diffusion.lora import inject_trainable_lora_extended

rank = 4
unet = UNet2DConditionModel.from_pretrained("runwayml/stable-diffusion-v1-5", 
                                             subfolder="unet", 
                                             torch_dtype=torch.float16,
                                            )
unet_lora_params, _ = inject_trainable_lora_extended(
    unet,
    target_replace_module=["Conv2d"],
    r=rank,
)
unet_lora_params

I get the following error however: RecursionError: maximum recursion depth exceeded while calling a Python object.

Best to reimplement as a for loop to avoid recursion depth bug?