MCPcopy Index your code
hub / github.com/vladmandic/sdnext / restore_state

Function restore_state

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

Source from the content-addressed store, hash-verified

20
21
22def restore_state(p: processing.StableDiffusionProcessing):
23 if p.state in ['reprocess_refine', 'reprocess_detail']:
24 # validate
25 if last_p is None:
26 log.warning(f'Restore state: op={p.state} last state missing')
27 return p
28 if p.__class__ != last_p.__class__:
29 log.warning(f'Restore state: op={p.state} last state is different type')
30 return p
31 if shared.history.count == 0:
32 log.warning(f'Restore state: op={p.state} last latents missing')
33 return p
34 state = p.state
35
36 # set ops
37 if state == 'reprocess_refine':
38 width, width_before, width_after, width_mask = p.width, p.width_before, p.width_after, p.width_mask
39 height, height_before, height_after, height_mask = p.height, p.height_before, p.height_after, p.height_mask
40 scale_by, scale_by_before, scale_by_after, scale_by_mask = p.scale_by, p.scale_by_before, p.scale_by_after, p.scale_by_mask
41 resize_name, resize_name_before, resize_name_after, resize_name_mask = p.resize_name, p.resize_name_before, p.resize_name_after, p.resize_name_mask
42 resize_mode, resize_mode_before, resize_mode_after, resize_mode_mask = p.resize_mode, p.resize_mode_before, p.resize_mode_after, p.resize_mode_mask
43 resize_context, resize_context_before, resize_context_after, resize_context_mask = p.resize_context, p.resize_context_before, p.resize_context_after, p.resize_context_mask
44 selected_scale_tab, selected_scale_tab_before, selected_scale_tab_after, selected_scale_tab_mask = p.selected_scale_tab, p.selected_scale_tab_before, p.selected_scale_tab_after, p.selected_scale_tab_mask
45 hr_scale, hr_resize_mode, hr_resize_context, hr_upscaler, hr_second_pass_steps = p.hr_scale, p.hr_resize_mode, p.hr_resize_context, p.hr_upscaler, p.hr_second_pass_steps
46 hr_resize_x, hr_resize_y, hr_upscale_to_x, hr_upscale_to_y, hr_denoising_strength = p.hr_resize_x, p.hr_resize_y, p.hr_upscale_to_x, p.hr_upscale_to_y, p.hr_denoising_strength
47
48 p = last_p
49 p.skip = ['encode', 'base']
50 p.state = state
51 p.enable_hr = True
52 p.hr_force = True
53 p.init_images = None
54
55 p.width, p.width_before, p.width_after, p.width_mask = width, width_before, width_after, width_mask
56 p.height, p.height_before, p.height_after, p.height_mask = height, height_before, height_after, height_mask
57 p.resize_name, p.resize_name_before, p.resize_name_after, p.resize_name_mask = resize_name, resize_name_before, resize_name_after, resize_name_mask
58 p.resize_mode, p.resize_mode_before, p.resize_mode_after, p.resize_mode_mask = resize_mode, resize_mode_before, resize_mode_after, resize_mode_mask
59 p.resize_context, p.resize_context_before, p.resize_context_after, p.resize_context_mask = resize_context, resize_context_before, resize_context_after, resize_context_mask
60 p.selected_scale_tab, p.selected_scale_tab_before, p.selected_scale_tab_after, p.selected_scale_tab_mask = selected_scale_tab, selected_scale_tab_before, selected_scale_tab_after, selected_scale_tab_mask
61 p.scale_by, p.scale_by_before, p.scale_by_after, p.scale_by_mask = scale_by, scale_by_before, scale_by_after, scale_by_mask
62 p.hr_scale, p.hr_resize_mode, p.hr_resize_context, p.hr_upscaler, p.hr_second_pass_steps = hr_scale, hr_resize_mode, hr_resize_context, hr_upscaler, hr_second_pass_steps
63 p.hr_resize_x, p.hr_resize_y, p.hr_upscale_to_x, p.hr_upscale_to_y, p.hr_denoising_strength = hr_resize_x, hr_resize_y, hr_upscale_to_x, hr_upscale_to_y, hr_denoising_strength
64 if state == 'reprocess_detail':
65 p.skip = ['encode', 'base', 'hires']
66 p.detailer_enabled = True
67 log.info(f'Restore state: op={p.state} skip={p.skip}')
68 return p
69
70
71def process_pre(p: processing.StableDiffusionProcessing):

Callers 1

process_diffusersFunction · 0.85

Calls 1

infoMethod · 0.80

Tested by

no test coverage detected