MCPcopy
hub / github.com/vladmandic/sdnext / process_base

Function process_base

modules/processing_diffusers.py:136–239  ·  view source on GitHub ↗
(p: processing.StableDiffusionProcessing)

Source from the content-addressed store, hash-verified

134
135
136def process_base(p: processing.StableDiffusionProcessing):
137 jobid = shared.state.begin('Base')
138 txt2img = is_txt2img()
139 use_refiner_start = is_refiner_enabled(p) and (not p.is_hr_pass)
140 use_denoise_start = not txt2img and p.refiner_start > 0 and p.refiner_start < 1
141
142 shared.sd_model = update_pipeline(shared.sd_model, p)
143 update_sampler(p, shared.sd_model)
144 timer.process.record('prepare')
145 process_pre(p)
146 sched_eta = p.scheduler_eta if p.scheduler_eta is not None else shared.opts.scheduler_eta
147 desc = 'Base'
148 if 'detailer' in p.ops:
149 desc = 'Detail'
150 base_args = set_pipeline_args(
151 p=p,
152 model=shared.sd_model,
153 prompts=p.prompts,
154 negative_prompts=p.negative_prompts,
155 prompts_2=[p.refiner_prompt] if len(p.refiner_prompt) > 0 else p.prompts,
156 negative_prompts_2=[p.refiner_negative] if len(p.refiner_negative) > 0 else p.negative_prompts,
157 num_inference_steps=calculate_base_steps(p, use_refiner_start=use_refiner_start, use_denoise_start=use_denoise_start),
158 eta=sched_eta,
159 guidance_scale=p.cfg_scale if p.cfg_scale is not None and p.cfg_scale > -1 else None,
160 guidance_rescale=p.cfg_rescale if p.cfg_rescale is not None and p.cfg_rescale > -1 else None,
161 true_cfg_scale=p.cfg_true if p.cfg_true is not None and p.cfg_true > -1 else None,
162 denoising_start=0 if use_refiner_start else p.refiner_start if use_denoise_start else None,
163 denoising_end=p.refiner_start if use_refiner_start else 1 if use_denoise_start else None,
164 num_frames=getattr(p, 'frames', 1),
165 output_type=output_type,
166 clip_skip=p.clip_skip,
167 prompt_attention=getattr(p, 'prompt_attention', None),
168 desc=desc,
169 )
170 base_steps = base_args.get('prior_num_inference_steps', None) or p.steps or base_args.get('num_inference_steps', None)
171 shared.state.update(get_job_name(p, shared.sd_model), base_steps, 1)
172 if sched_eta is not None and sched_eta > 0 and sched_eta < 1:
173 p.extra_generation_params["Sampler Eta"] = sched_eta
174 output = None
175 if debug:
176 modelstats.analyze()
177 try:
178 t0 = time.time()
179 p.prompts, p.network_data = extra_networks.parse_prompts(p.prompts, p.network_data)
180 extra_networks.activate(p, exclude=['text_encoder', 'text_encoder_2', 'text_encoder_3'])
181
182 if hasattr(shared.sd_model, 'tgate') and getattr(p, 'gate_step', -1) > 0:
183 base_args['gate_step'] = p.gate_step
184 output = shared.sd_model.tgate(**base_args) # pylint: disable=not-callable
185 else:
186 taskid = shared.state.begin('Inference')
187 output = shared.sd_model(**base_args)
188 shared.state.end(taskid)
189 if isinstance(output, dict):
190 output = SimpleNamespace(**output)
191 if isinstance(output, list):
192 output = SimpleNamespace(images=output)
193 if isinstance(output, Image.Image):

Callers 1

process_diffusersFunction · 0.85

Calls 15

is_txt2imgFunction · 0.90
is_refiner_enabledFunction · 0.90
update_samplerFunction · 0.90
set_pipeline_argsFunction · 0.90
calculate_base_stepsFunction · 0.90
get_job_nameFunction · 0.90
update_pipelineFunction · 0.85
process_preFunction · 0.85
process_postFunction · 0.85
beginMethod · 0.80
analyzeMethod · 0.80
infoMethod · 0.80

Tested by

no test coverage detected