-
Notifications
You must be signed in to change notification settings - Fork 6k
[OmegaConf] replace it with yaml
#6488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hmm, needs a bit more work, will look into it. If I do: from diffusers import StableDiffusionPipeline
pipeline = StableDiffusionPipeline.from_single_file(
"https://huggingface.co/WarriorMama777/OrangeMixs/blob/main/Models/AbyssOrangeMix/AbyssOrangeMix.safetensors"
)
pipeline.to("cuda")
_ = pipeline("hey", num_inference_steps=5).images[0] It fails with: Traceback (most recent call last):
File "/home/sayak/check_without_omegaconf.py", line 4, in <module>
pipeline = StableDiffusionPipeline.from_single_file(
File "/home/sayak/.pyenv/versions/diffusers/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 118, in _inner_fn
return fn(*args, **kwargs)
File "/home/sayak/diffusers/src/diffusers/loaders/single_file.py", line 257, in from_single_file
pipe = download_from_original_stable_diffusion_ckpt(
File "/home/sayak/diffusers/src/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py", line 1321, in download_from_original_stable_diffusion_ckpt
and "cond_stage_config" in original_config.model.params
AttributeError: 'dict' object has no attribute 'model' |
Okay, so, to get around the class DotDict(dict):
""" Custom dictionary class to access dictionary elements using dot notation. """
__getattr__ = dict.get
__setattr__ = dict.__setitem__
__delattr__ = dict.__delitem__
def __init__(self, dictionary):
for key, value in dictionary.items():
if isinstance(value, dict):
value = DotDict(value)
self[key] = value So, it makes member access with "." possible. For example: from io import BytesIO
import yaml
import requests
config_url = "https://raw.githubusercontent.com/CompVis/stable-diffusion/main/configs/stable-diffusion/v1-inference.yaml"
original_config_file = BytesIO(requests.get(config_url).content)
original_config = yaml.safe_load(original_config_file)
original_config = DotDict(original_config) Now, we can do: original_config.model.params You can also do So, I think we have two options:
|
I'm not sure what exactly to review here - does PyYaml already work? |
Let me know which option in #6488 (comment) you'd prefer in light of #6488 (comment)? |
I think it's totally fine if we do |
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
@patrickvonplaten I have replaced ![]() If the changes are okay, I will propagate them to the other scripts and utilities. LMK. |
Changes look great! Nice job |
yaml
yaml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing work! 👍🏽
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job!
this seems to cause pretty bad regressions in some areas and its preventing model load.
|
I did run these tests from #6488 (comment). Could you please give me something that helps to reproduce the problem? I will fix right away :) |
simple loading using from_single_file fails with diffusers==0.26.0.dev and works with diffusers==0.25.1 import time
import torch
import diffusers
model_file = '/mnt/d/Models/stable-diffusion/base/sd-v15-runwayml.safetensors'
load_config = {
"low_cpu_mem_usage": True,
"torch_dtype": torch.float16,
"safety_checker": None,
"requires_safety_checker": False,
"load_safety_checker": False,
"load_connected_pipeline": True,
'config_files': {
'v1': 'configs/v1-inference.yaml',
'v2': 'configs/v2-inference-768-v.yaml',
'xl': 'configs/sd_xl_base.yaml',
'xl_refiner': 'configs/sd_xl_refiner.yaml',
}
}
t0 = time.time()
pipe = diffusers.StableDiffusionPipeline.from_single_file(model_file, **load_config)
t1 = time.time()
print(f"Loaded: {t1-t0:.2f}") note: i specify config files in load config to prevent load perform a network lookup/download on each model load. |
It works with #6633, thanks to @spezialspezial! Colab: https://colab.research.google.com/gist/sayakpaul/99e1759ca450fa39b47b647f1e2fbd6f/scratchpad.ipynb |
@sayakpaul |
@jasstionzyf can you ensure you are using the latest |
@sayakpaul i use pip install git+https://github.com/huggingface/diffusers try to build and install latest main branch , but result is alwayes 0.26.0.dev0, is that normal? |
Ah I see. You should try the following: pip uninstall diffusers -y
git clone https://github.com/huggingface/diffusers
cd diffusers && pip install -e . |
@sayakpaul |
Then please open a new issue and provide a fully reproducible yet minimal script. Please keep it as minimal as possible while also making it fully reproducible. |
* remove omegaconf from convert_from_ckpt. * remove from single_file. * change to string based ubscription. * style * okay * fix: vae_param * no . indexing. * style * style * turn getattrs into explicit if/else * style * propagate changes to ldm_uncond. * propagate to gligen * propagate to if. * fix: quotes. * propagate to audioldm. * propagate to audioldm2 * propagate to musicldm. * propagate to vq_diffusion * propagate to zero123. * remove omegaconf from diffusers codebase.
What does this PR do?
Since
PyYAML
needs to be installed anyway withhuggingface_hub
which is a required dependency fordiffusers
, it makes sense to replace the usage ofomegaconf
withyaml
. We useomegaconf
to deal with the config files of the single file checkpoints.If there's agreement I will make the changes to the rest of the files and remove
omegaconf
entirely fromdiffusers
.