mirror of
https://github.com/lllyasviel/stable-diffusion-webui-forge.git
synced 2026-04-29 10:41:25 +00:00
elegant codes
This commit is contained in:
@@ -52,14 +52,7 @@ class PhotomakerPatcher(ControlModelPatcher):
|
|||||||
text = process.prompts[0]
|
text = process.prompts[0]
|
||||||
|
|
||||||
cond_modified = opPhotoMakerEncode(photomaker=self.model, image=cond.movedim(1, -1), clip=clip, text=text)[0]
|
cond_modified = opPhotoMakerEncode(photomaker=self.model, image=cond.movedim(1, -1), clip=clip, text=text)[0]
|
||||||
noise = kwargs['x']
|
cond_modified = unet.encode_conds_from_clip(conds=cond_modified, noise=kwargs['x'])[0]
|
||||||
cond_modified = encode_model_conds(
|
|
||||||
model_function=unet.model.extra_conds,
|
|
||||||
conds=convert_cond(cond_modified),
|
|
||||||
noise=noise,
|
|
||||||
device=noise.device,
|
|
||||||
prompt_type="positive"
|
|
||||||
)[0]
|
|
||||||
|
|
||||||
def conditioning_modifier(model, x, timestep, uncond, cond, cond_scale, model_options, seed):
|
def conditioning_modifier(model, x, timestep, uncond, cond, cond_scale, model_options, seed):
|
||||||
cond = cond.copy()
|
cond = cond.copy()
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import copy
|
import copy
|
||||||
|
|
||||||
from ldm_patched.modules.model_patcher import ModelPatcher
|
from ldm_patched.modules.model_patcher import ModelPatcher
|
||||||
|
from ldm_patched.modules.sample import convert_cond
|
||||||
|
from ldm_patched.modules.samplers import encode_model_conds
|
||||||
|
|
||||||
|
|
||||||
class UnetPatcher(ModelPatcher):
|
class UnetPatcher(ModelPatcher):
|
||||||
@@ -96,3 +98,12 @@ class UnetPatcher(ModelPatcher):
|
|||||||
for transformer_index in range(16):
|
for transformer_index in range(16):
|
||||||
self.set_model_patch_replace(patch, target, block_name, number, transformer_index)
|
self.set_model_patch_replace(patch, target, block_name, number, transformer_index)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def encode_conds_from_clip(self, conds, noise, prompt_type="positive"):
|
||||||
|
return encode_model_conds(
|
||||||
|
model_function=self.model.extra_conds,
|
||||||
|
conds=convert_cond(conds),
|
||||||
|
noise=noise,
|
||||||
|
device=noise.device,
|
||||||
|
prompt_type=prompt_type
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user