comfyanonymous / ComfyUI

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface.
https://www.comfy.org/
GNU General Public License v3.0
56.62k stars 6k forks source link

Universal was to get state_dict keys for svd model? #4145

Open 311-code opened 3 months ago

311-code commented 3 months ago

Your question

On a custom node I am making, I have spent months trying to get the actual state_dict keys for the svd model as they don't match the huggingface names when you click the little layer icon. I need the comfyui post prefixed names for clip_vision, unet. I want it to print all of the names used and even the open clip ones after positional.embedding.

I noticed comfyui renames a bunch of the state_dict key prefixes and this makes it very difficult for targeting weight and bias layers directly when using comfyui. I think I am definitely missing something here. I see some classes that include layer_idx at least, but when I use their methods to get the state_dict keys (after importing) it doesn't work.

In addition, can we get some comments for sd1_clip.py, the sdxl_clip.py, the class SDXLClipG, the SDXLClipGTokenizer, and other classes like that. These seems to be exactly what I am looking but it took 4 months to finally discover them. I need to be able to get the actual state_dict names comfyui renames everything in the svd model to.

I don't mind the state_dict_prefix_replace in the sd.py if it's necessary, but there needs to still be a way to get the prefixed names. Unless I am missing something here. Thanks!

comfyanonymous commented 3 months ago

https://github.com/comfyanonymous/ComfyUI/blob/master/comfy/model_patcher.py#L258

You can call .state_dict() on the MODEL object.

github-actions[bot] commented 2 months ago

This issue is being marked stale because it has not had any activity for 30 days. Reply below within 7 days if your issue still isn't solved, and it will be left open. Otherwise, the issue will be closed automatically.