(p: processing.StableDiffusionProcessing)
| 69 | |
| 70 | |
| 71 | def process_pre(p: processing.StableDiffusionProcessing): |
| 72 | from modules import ipadapter, sd_hijack_freeu, para_attention, teacache, hidiffusion, ras, pag, cfgzero, transformer_cache, token_merge, linfusion, cachedit |
| 73 | if shared.sd_model is None: |
| 74 | log.warning('Processing modifiers: model not loaded') |
| 75 | return |
| 76 | log.info('Processing modifiers: apply') |
| 77 | try: |
| 78 | # apply-with-unapply |
| 79 | sd_models_compile.check_deepcache(enable=True) |
| 80 | ipadapter.apply(shared.sd_model, p) |
| 81 | token_merge.apply_token_merging(shared.sd_model) |
| 82 | hidiffusion.apply(p, shared.sd_model_type) |
| 83 | ras.apply(shared.sd_model, p) |
| 84 | pag.apply(p) |
| 85 | cfgzero.apply(p) |
| 86 | linfusion.apply(shared.sd_model) |
| 87 | cachedit.apply_cache_dit(shared.sd_model) |
| 88 | |
| 89 | # apply-only |
| 90 | sd_hijack_freeu.apply_freeu(p) |
| 91 | transformer_cache.set_cache() |
| 92 | para_attention.apply_first_block_cache() |
| 93 | teacache.apply_teacache(p) |
| 94 | except Exception as e: |
| 95 | log.error(f'Processing apply: {e}') |
| 96 | errors.display(e, 'apply') |
| 97 | |
| 98 | shared.sd_model = sd_models.apply_balanced_offload(shared.sd_model) |
| 99 | # if hasattr(shared.sd_model, 'unet'): |
| 100 | # sd_models.move_model(shared.sd_model.unet, devices.device) |
| 101 | # if hasattr(shared.sd_model, 'transformer'): |
| 102 | # sd_models.move_model(shared.sd_model.transformer, devices.device) |
| 103 | |
| 104 | from modules import modular |
| 105 | if modular.is_compatible(shared.sd_model): |
| 106 | modular_pipe = modular.convert_to_modular(shared.sd_model) |
| 107 | if modular_pipe is not None: |
| 108 | shared.sd_model = modular_pipe |
| 109 | if modular.is_guider(shared.sd_model): |
| 110 | from modules import modular_guiders |
| 111 | modular_guiders.set_guider(p) |
| 112 | |
| 113 | timer.process.record('pre') |
| 114 | |
| 115 | |
| 116 | def process_post(p: processing.StableDiffusionProcessing): |
no test coverage detected