lllyasviel / lllyasviel/ControlNet

Error when transferring control

Open
#91 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
34.1k
Forks
3k
PR merge metrics
No merged PRs in 30d

Description

**Traceback:**
```shell
(control) malo@win11-f8:/mnt/i/source/ControlNet$ python tool_transfer_control.py
logging improved.
Loaded state_dict from [/mnt/i/ckpt/native/sd1-5pruned.ckpt]
Loaded state_dict from [/mnt/i/source/automatic-ui/extensions/sd-webui-controlnet/models/control_sd15_canny.pth]
Loaded state_dict from [/mnt/i/ckpt/native/novelai-pruned.ckpt]
Traceback (most recent call last):
File "tool_transfer_control.py", line 42, in
final_state_dict[key] = input_state_dict[key]
KeyError: 'first_stage_model.encoder.conv_in.weight'
```
I suggest changing

```python
if is_first_stage or is_cond_stage:
final_state_dict[key] = input_state_dict[key]
continue
```

to

```python
if is_first_stage or is_cond_stage:
if not input_state_dict.get(key):
continue
final_state_dict[key] = input_state_dict[key]
continue
```

This will ensure script does not die if one model has a state key that other does not. This helped me to transfer models to novelai.

Sorry for being lazy with PRs

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with tool_transfer_control.py around line 42 and inspect how missing state-dictionary keys are handled during model transfer. Run the command shown in the traceback with compatible model files; done means a missing first-stage key no longer raises KeyError and the transfer completes.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning, tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.