Comments (12)
I will be trying to do it. If someone familiar with UI could assist, that would be even better.
from hidiffusion.
as promised: https://github.com/blepping/comfyui_jankhidiffusion
from hidiffusion.
i tried porting the MSW-MSA attention part to Comfy: https://gist.github.com/blepping/02e389f660112097983684a8ea8093b1
not sure i did it correctly, but the results seem reasonable and it's a noticeable speed improvement. note: barely tested at this point.
implementing the RAU-Net part seems like it would be considerably harder since i'm not sure if there's a way to replace upsample/downsample model blocks without actually patching ComfyUI itself. the code is also difficult to understand and there are conditionals that are the same in both branches. it's kind of hard to understand what it's actually doing, at least for me.
edit: this mainly seems to help with SD 1.5, i did some testing with SDXL and the performance effects seem very minor. it may not be worth using for SDXL unless you like how it affects generation quality (i feel like it may help a bit for reducing artifacts at high res for SD15 and SDXL).
from hidiffusion.
A lot of code in RAU-Net are directly copied from diffusers impl (That is why I do not like diffuers). The main logic seem to be further increase compression / decompression by 2.
right. from what i've figured out messing with it, aside from the MSW-MSA attention part it is almost exactly Kohya Deep Shrink.
- the cross attention part uses Torch
avg_pool2d
instead of bicubic. - the RAU downsampler part uses conv stride/dilation to downscale instead of bicubic.
for the second one, it might matter where the downscale is happening. the conv approach does seem like it produces better results than deep shrink (including with other downscale methods i've tried).
MSW-MSA attention and randomly choosing windows seems like a new idea though and from my testing works pretty well (at least with SD15).
anyway, i've finished the RAUNet part and i will probably release it tomorrow. don't get too excited though, my stuff is usually fairly janky and not too user friendly. however, that should be like 90+% of the work done so someone else could potentially take it and build on it.
it also required monkey patching ComfyUI's guts which isn't really ideal. i don't think there's any better way presently though.
from hidiffusion.
I created custom nodes to use HiDiffusion with ComfyUI.
Today I released an update that allows any SDXL checkpoint to be used.
https://github.com/florestefano1975/ComfyUI-HiDiffusion
from hidiffusion.
can you share a workflow with the right way to use this?
i updated the README and added example workflows for SD 1.5 and SDXL.
from hidiffusion.
blepping/comfyui_jankhidiffusion#5
can anyone help this?
So far florestefano's version is just a transfer of diffuser code. We cannot use even use lora in this plugin.
from hidiffusion.
I will be trying to do it. If someone familiar with UI could assist, that would be even better.
I tried having a quick go at this, but it's a lot of work and I think it'd be quicker if you do it. In your current diffusers code it looks like you're hijacking existing functions and injecting classes, but with comfyui you can hook onto various stages a bit more cleanly.
To get started create a directory in comfyui/custom_nodes/comfyui-hidiffusion or something similar (do not simply call it hidiffusion, otherwise if you decide to "import hidiffusion" you'll import recursively)
Then create a init.py with something like the following:
https://github.com/comfyanonymous/ComfyUI/blob/master/comfy_extras/nodes_model_downscale.py
https://github.com/comfyanonymous/ComfyUI/blob/master/comfy_extras/nodes_tomesd.py
These two nodes hook onto various stages of the process and do something similar to hidiffusion. You can literally copy paste the code from one of those nodes as a starting point into your init.py file and just rename the class and mapping names.
In case comfyui is lacking hooks to various stages or "extra_info" you'd have to modify comfyui somewhere around here:
https://github.com/comfyanonymous/ComfyUI/blob/8dc19e40d129c8ee049be7be2657458509717ba5/comfy/model_patcher.py#L125-L159
https://github.com/comfyanonymous/ComfyUI/blob/8dc19e40d129c8ee049be7be2657458509717ba5/comfy/ldm/modules/attention.py#L462-L574
https://github.com/comfyanonymous/ComfyUI/blob/8dc19e40d129c8ee049be7be2657458509717ba5/comfy/ldm/modules/diffusionmodules/openaimodel.py#L819-L890
The author would probably accept the changes if they are general enough.
from hidiffusion.
i tried porting the MSW-MSA attention part to Comfy: https://gist.github.com/blepping/02e389f660112097983684a8ea8093b1
not sure i did it correctly, but the results seem reasonable and it's a noticeable speed improvement. note: barely tested at this point.
implementing the RAU-Net part seems like it would be considerably harder since i'm not sure if there's a way to replace upsample/downsample model blocks without actually patching ComfyUI itself. the code is also difficult to understand and there are conditionals that are the same in both branches. it's kind of hard to understand what it's actually doing, at least for me.
edit: this mainly seems to help with SD 1.5, i did some testing with SDXL and the performance effects seem very minor. it may not be worth using for SDXL unless you like how it affects generation quality (i feel like it may help a bit for reducing artifacts at high res for SD15 and SDXL).
A lot of code in RAU-Net are directly copied from diffusers impl (That is why I do not like diffuers). The main logic seem to be further increase compression / decompression by 2.
from hidiffusion.
can you share a workflow with the right way to use this?
from hidiffusion.
@YacratesWyh i pushed a changed today that hopefully improves the ControlNet situation. see: https://github.com/blepping/comfyui_jankhidiffusion#use-with-controlnet
this more of a bandaid type thing than a correct fix (as far as i know) so i definitely still could use help. also appreciate your post!
from hidiffusion.
so sad that comfy doesnt officially support it... If I understand right, current implementations are rather hacky and may stop work on comfy updates. So can't use it, as my all projects are long term ones( But this tool would be extremely useful in comfy. Could developers contact comfy team?...
from hidiffusion.
Related Issues (20)
- Torch 1.X is completely incompatible with all recent versions of all UIs, this is unfortunately useless without proper Torch 2.X support HOT 3
- Looking forward to it! When will there be a webui interface? HOT 1
- FYI: Full Integration HOT 4
- non-square aspect ratio results in failure (although have installed all the suitable version) HOT 7
- What about the optionnal code? HOT 1
- Do you support ControlNet in SD 1.5? HOT 3
- Dose it support ControlNet inpaint in SDXL? HOT 6
- !!!!Replace the prompt in your example.ipynb!!! HOT 1
- Can we add version support for diffusers 0.272? HOT 1
- sdxl version doesn't work on non-square image HOT 3
- Problem at high resolutions using PuLID embeddings HOT 1
- USE_PEFT_BACKEND HOT 2
- Support for SD 1.5 Controlnet + Inpainting HOT 1
- 'is_inpainting_task': 'inpainting' in model.name_or_path HOT 3
- does it work better than upscale + hires + tile? HOT 1
- Support LoRA?
- image to image SD3: NameError: name 'scale_lora_layers' is not defined HOT 3
- 'StableDiffusionPipeline' object has no attribute '_num_timesteps' HOT 1
- would you team support it in a1111 webui officially? HOT 1
- a little speed up
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hidiffusion.