sd-scripts
sd-scripts copied to clipboard
Fix train controlnet
Now we can train controlnet for SD 1.5. Sample image part not change.
Thank you for this! Is omegaconf
needed? I'd like to minimize the dependencies...
Thank you for this! Is
omegaconf
needed? I'd like to minimize the dependencies...
I think just having a method that wraps the config would be fine, but diffusers don't support the old SimpleNamespace anymore because SimpleNamespace doesn't support loops.
I think just having a method that wraps the config would be fine, but diffusers don't support the old SimpleNamespace anymore because SimpleNamespace doesn't support loops.
Thank you for clarification. It's annoying...
The following code may be working. Is it fine to use this? (I'm testing this PR on my env, but I get another error currently.)
# make unet.config iterable and accessible by attribute
class CustomConfig:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
def __getattr__(self, name):
if name in self.__dict__:
return self.__dict__[name]
else:
raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'")
def __contains__(self, name):
return name in self.__dict__
unet.config = CustomConfig(**unet.config)
I think just having a method that wraps the config would be fine, but diffusers don't support the old SimpleNamespace anymore because SimpleNamespace doesn't support loops.
Thank you for clarification. It's annoying...
The following code may be working. Is it fine to use this? (I'm testing this PR on my env, but I get another error currently.)
# make unet.config iterable and accessible by attribute class CustomConfig: def __init__(self, **kwargs): self.__dict__.update(kwargs) def __getattr__(self, name): if name in self.__dict__: return self.__dict__[name] else: raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") def __contains__(self, name): return name in self.__dict__ unet.config = CustomConfig(**unet.config)
it seems works in my env.
it seems works in my env.
Thank you! Perhaps my dataset may have an issue. I will test further.
Now it works! Some optimizer seems to be needed trainable_params = list(controlnet.parameters())
. Thank you for this!