NeuralNotW0rk / LoRAW

Flexible LoRA Implementation to use with stable-audio-tools
MIT License
48 stars 4 forks source link

Error: `IndexError: list index out of range` in LoRAW Gradio Interface When Loading LoRA Model #12

Closed furmanlukasz closed 2 months ago

furmanlukasz commented 2 months ago

Issue Description:

I encountered an error while running a trained LoRA checkpoint in the Gradio interface for LoRAW. The model loads successfully, but when attempting to generate audio, it throws an IndexError: list index out of range.

Error Log:

/workspace
Creating model from config
No module named 'flash_attn'
flash_attn not installed, disabling Flash Attention
/usr/local/lib/python3.10/dist-packages/torch/nn/utils/weight_norm.py:30: UserWarning: torch.nn.utils.weight_norm is deprecated in favor of torch.nn.utils.parametrizations.weight_norm.
  warnings.warn("torch.nn.utils.weight_norm is deprecated in favor of torch.nn.utils.parametrizations.weight_norm.")
Loading model checkpoint from /workspace/model.ckpt
Done loading model
Found 170 candidates for LoRA replacement
LoRA registered: stable_audio_open_finetune_loraw1
Running on local URL:  http://127.0.0.1:7860
Running on public URL: https://b59f39fd94fc1607b4.gradio.live

This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)
Prompt: ttett
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/gradio/queueing.py", line 536, in process_events
    response = await route_utils.call_process_api(
  File "/usr/local/lib/python3.10/dist-packages/gradio/route_utils.py", line 321, in call_process_api
    output = await app.get_blocks().process_api(
  File "/usr/local/lib/python3.10/dist-packages/gradio/blocks.py", line 1935, in process_api
    result = await self.call_function(
  File "/usr/local/lib/python3.10/dist-packages/gradio/blocks.py", line 1520, in call_function
    prediction = await anyio.to_thread.run_sync(  # type: ignore
  File "/usr/local/lib/python3.10/dist-packages/anyio/to_thread.py", line 33, in run_sync
    return await get_async_backend().run_sync_in_worker_thread(
  File "/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py", line 2106, in run_sync_in_worker_thread
    return await future
  File "/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py", line 833, in run
    result = context.run(func, *args)
  File "/usr/local/lib/python3.10/dist-packages/gradio/utils.py", line 826, in wrapper
    response = f(*args, **kwargs)
  File "/workspace/LoRAW/interface/gradio.py", line 175, in generate_cond
    lora_merger.merge({lora_names[0]: lora1, lora_names[1]: lora2, lora_names[2]: lora3})
IndexError: list index out of range

Steps to Reproduce:

  1. Run the LoRAW interface with the following command:
    %cd /workspace
    command = (
       "python LoRAW/run_gradio.py"
       " --model-config /workspace/model_config_loraw.json"
       " --ckpt-path /workspace/model.ckpt"
       " --lora-dir /workspace/Lora-Model"
    )
    !{command}
  2. The model successfully loads, and LoRA candidates are registered.
  3. On submitting a text prompt, the error IndexError: list index out of range is triggered at gradio.py:175.

Additional Context:

Any help resolving this issue or guidance on properly handling LoRA model checkpoints in this interface would be appreciated.

NeuralNotW0rk commented 2 months ago

Hey there, Gradio can't do variable number of components so when I hard-coded for up to 3 loras I forgot to check for fewer than 3. Fixed now.