hr conditioning
This commit is contained in:
parent
c5d4c87c02
commit
2ab2bce74d
@ -235,7 +235,7 @@ class StableDiffusionProcessing:
|
|||||||
def init(self, all_prompts, all_seeds, all_subseeds):
|
def init(self, all_prompts, all_seeds, all_subseeds):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def sample(self, conditioning, unconditional_conditioning, hr_conditioning, hr_uconditional_conditioning, seeds, subseeds, subseed_strength, prompts):
|
def sample(self, conditioning, unconditional_conditioning, hr_conditioning=None, hr_unconditional_conditioning=None, seeds, subseeds, subseed_strength, prompts):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
@ -517,7 +517,7 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed:
|
|||||||
p.all_negative_prompts = p.batch_size * p.n_iter * [shared.prompt_styles.apply_negative_styles_to_prompt(p.negative_prompt, p.styles)]
|
p.all_negative_prompts = p.batch_size * p.n_iter * [shared.prompt_styles.apply_negative_styles_to_prompt(p.negative_prompt, p.styles)]
|
||||||
|
|
||||||
if type(p) == StableDiffusionProcessingTxt2Img:
|
if type(p) == StableDiffusionProcessingTxt2Img:
|
||||||
if p.enable_hr:
|
if p.enable_hr and p.hr_prompt != '':
|
||||||
if type(p.prompt) == list:
|
if type(p.prompt) == list:
|
||||||
p.all_hr_prompts = [shared.prompt_styles.apply_styles_to_prompt(x, p.styles) for x in p.hr_prompt]
|
p.all_hr_prompts = [shared.prompt_styles.apply_styles_to_prompt(x, p.styles) for x in p.hr_prompt]
|
||||||
else:
|
else:
|
||||||
@ -601,7 +601,7 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed:
|
|||||||
negative_prompts = p.all_negative_prompts[n * p.batch_size:(n + 1) * p.batch_size]
|
negative_prompts = p.all_negative_prompts[n * p.batch_size:(n + 1) * p.batch_size]
|
||||||
|
|
||||||
if type(p) == StableDiffusionProcessingTxt2Img:
|
if type(p) == StableDiffusionProcessingTxt2Img:
|
||||||
if p.enable_hr:
|
if p.enable_hr and p.hr_prompt != '':
|
||||||
hr_prompts = p.all_hr_prompts[n * p.batch_size:(n + 1) * p.batch_size]
|
hr_prompts = p.all_hr_prompts[n * p.batch_size:(n + 1) * p.batch_size]
|
||||||
hr_negative_prompts = p.all_negative_prompts[n * p.batch_size:(n + 1) * p.batch_size]
|
hr_negative_prompts = p.all_negative_prompts[n * p.batch_size:(n + 1) * p.batch_size]
|
||||||
|
|
||||||
@ -619,7 +619,7 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed:
|
|||||||
uc = get_conds_with_caching(prompt_parser.get_learned_conditioning, negative_prompts, p.steps, cached_uc)
|
uc = get_conds_with_caching(prompt_parser.get_learned_conditioning, negative_prompts, p.steps, cached_uc)
|
||||||
c = get_conds_with_caching(prompt_parser.get_multicond_learned_conditioning, prompts, p.steps, cached_c)
|
c = get_conds_with_caching(prompt_parser.get_multicond_learned_conditioning, prompts, p.steps, cached_c)
|
||||||
if type(p) == StableDiffusionProcessingTxt2Img:
|
if type(p) == StableDiffusionProcessingTxt2Img:
|
||||||
if p.enable_hr:
|
if p.enable_hr and p.hr_prompt != '':
|
||||||
hr_uc = get_conds_with_caching(prompt_parser.get_learned_conditioning, hr_negative_prompts, p.steps,
|
hr_uc = get_conds_with_caching(prompt_parser.get_learned_conditioning, hr_negative_prompts, p.steps,
|
||||||
cached_uc)
|
cached_uc)
|
||||||
hr_c = get_conds_with_caching(prompt_parser.get_multicond_learned_conditioning, hr_prompts, p.steps,
|
hr_c = get_conds_with_caching(prompt_parser.get_multicond_learned_conditioning, hr_prompts, p.steps,
|
||||||
@ -635,7 +635,12 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed:
|
|||||||
with devices.autocast():
|
with devices.autocast():
|
||||||
if type(p) == StableDiffusionProcessingTxt2Img:
|
if type(p) == StableDiffusionProcessingTxt2Img:
|
||||||
if p.enable_hr:
|
if p.enable_hr:
|
||||||
|
if p.hr_prompts != '':
|
||||||
samples_ddim = p.sample(conditioning=c, unconditional_conditioning=uc, hr_conditioning=hr_c, hr_unconditional_conditioning=hr_uc, seeds=seeds, subseeds=subseeds, subseed_strength=p.subseed_strength, prompts=prompts)
|
samples_ddim = p.sample(conditioning=c, unconditional_conditioning=uc, hr_conditioning=hr_c, hr_unconditional_conditioning=hr_uc, seeds=seeds, subseeds=subseeds, subseed_strength=p.subseed_strength, prompts=prompts)
|
||||||
|
else:
|
||||||
|
samples_ddim = p.sample(conditioning=c, unconditional_conditioning=uc, hr_conditioning=c,
|
||||||
|
hr_unconditional_conditioning=uc, seeds=seeds, subseeds=subseeds,
|
||||||
|
subseed_strength=p.subseed_strength, prompts=prompts)
|
||||||
else:
|
else:
|
||||||
samples_ddim = p.sample(conditioning=c, unconditional_conditioning=uc, seeds=seeds, subseeds=subseeds,
|
samples_ddim = p.sample(conditioning=c, unconditional_conditioning=uc, seeds=seeds, subseeds=subseeds,
|
||||||
subseed_strength=p.subseed_strength, prompts=prompts)
|
subseed_strength=p.subseed_strength, prompts=prompts)
|
||||||
@ -756,8 +761,8 @@ class StableDiffusionProcessingTxt2Img(StableDiffusionProcessing):
|
|||||||
self.hr_upscale_to_x = hr_resize_x
|
self.hr_upscale_to_x = hr_resize_x
|
||||||
self.hr_upscale_to_y = hr_resize_y
|
self.hr_upscale_to_y = hr_resize_y
|
||||||
self.hr_sampler = hr_sampler
|
self.hr_sampler = hr_sampler
|
||||||
self.hr_prompt = hr_prompt if hr_prompt != '' else self.prompt
|
self.hr_prompt = hr_prompt if hr_prompt != '' else ''
|
||||||
self.hr_negative_prompt = hr_negative_prompt if hr_negative_prompt != '' else self.negative_prompt
|
self.hr_negative_prompt = hr_negative_prompt if hr_negative_prompt != '' else ''
|
||||||
self.all_hr_prompts = None
|
self.all_hr_prompts = None
|
||||||
self.all_hr_negative_prompts = None
|
self.all_hr_negative_prompts = None
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user