MCPcopy Index your code
hub / github.com/thygate/stable-diffusion-webui-depthmap-script / extrapolate

Function extrapolate

inpaint/mesh_tools.py:81–439  ·  view source on GitHub ↗
(global_mesh,
                info_on_pix,
                image,
                depth,
                other_edge_with_id,
                edge_map,
                edge_ccs,
                depth_edge_model,
                depth_feat_model,
                rgb_feat_model,
                config,
                direc='right-up')

Source from the content-addressed store, hash-verified

79 return valid_edge_ccs
80
81def extrapolate(global_mesh,
82 info_on_pix,
83 image,
84 depth,
85 other_edge_with_id,
86 edge_map,
87 edge_ccs,
88 depth_edge_model,
89 depth_feat_model,
90 rgb_feat_model,
91 config,
92 direc='right-up'):
93 h_off, w_off = global_mesh.graph['hoffset'], global_mesh.graph['woffset']
94 noext_H, noext_W = global_mesh.graph['noext_H'], global_mesh.graph['noext_W']
95
96 if "up" in direc.lower() and "-" not in direc.lower():
97 all_anchor = [0, h_off + config['context_thickness'], w_off, w_off + noext_W]
98 global_shift = [all_anchor[0], all_anchor[2]]
99 mask_anchor = [0, h_off, w_off, w_off + noext_W]
100 context_anchor = [h_off, h_off + config['context_thickness'], w_off, w_off + noext_W]
101 valid_line_anchor = [h_off, h_off + 1, w_off, w_off + noext_W]
102 valid_anchor = [min(mask_anchor[0], context_anchor[0]), max(mask_anchor[1], context_anchor[1]),
103 min(mask_anchor[2], context_anchor[2]), max(mask_anchor[3], context_anchor[3])]
104 elif "down" in direc.lower() and "-" not in direc.lower():
105 all_anchor = [h_off + noext_H - config['context_thickness'], 2 * h_off + noext_H, w_off, w_off + noext_W]
106 global_shift = [all_anchor[0], all_anchor[2]]
107 mask_anchor = [h_off + noext_H, 2 * h_off + noext_H, w_off, w_off + noext_W]
108 context_anchor = [h_off + noext_H - config['context_thickness'], h_off + noext_H, w_off, w_off + noext_W]
109 valid_line_anchor = [h_off + noext_H - 1, h_off + noext_H, w_off, w_off + noext_W]
110 valid_anchor = [min(mask_anchor[0], context_anchor[0]), max(mask_anchor[1], context_anchor[1]),
111 min(mask_anchor[2], context_anchor[2]), max(mask_anchor[3], context_anchor[3])]
112 elif "left" in direc.lower() and "-" not in direc.lower():
113 all_anchor = [h_off, h_off + noext_H, 0, w_off + config['context_thickness']]
114 global_shift = [all_anchor[0], all_anchor[2]]
115 mask_anchor = [h_off, h_off + noext_H, 0, w_off]
116 context_anchor = [h_off, h_off + noext_H, w_off, w_off + config['context_thickness']]
117 valid_line_anchor = [h_off, h_off + noext_H, w_off, w_off + 1]
118 valid_anchor = [min(mask_anchor[0], context_anchor[0]), max(mask_anchor[1], context_anchor[1]),
119 min(mask_anchor[2], context_anchor[2]), max(mask_anchor[3], context_anchor[3])]
120 elif "right" in direc.lower() and "-" not in direc.lower():
121 all_anchor = [h_off, h_off + noext_H, w_off + noext_W - config['context_thickness'], 2 * w_off + noext_W]
122 global_shift = [all_anchor[0], all_anchor[2]]
123 mask_anchor = [h_off, h_off + noext_H, w_off + noext_W, 2 * w_off + noext_W]
124 context_anchor = [h_off, h_off + noext_H, w_off + noext_W - config['context_thickness'], w_off + noext_W]
125 valid_line_anchor = [h_off, h_off + noext_H, w_off + noext_W - 1, w_off + noext_W]
126 valid_anchor = [min(mask_anchor[0], context_anchor[0]), max(mask_anchor[1], context_anchor[1]),
127 min(mask_anchor[2], context_anchor[2]), max(mask_anchor[3], context_anchor[3])]
128 elif "left" in direc.lower() and "up" in direc.lower() and "-" in direc.lower():
129 all_anchor = [0, h_off + config['context_thickness'], 0, w_off + config['context_thickness']]
130 global_shift = [all_anchor[0], all_anchor[2]]
131 mask_anchor = [0, h_off, 0, w_off]
132 context_anchor = "inv-mask"
133 valid_line_anchor = None
134 valid_anchor = all_anchor
135 elif "left" in direc.lower() and "down" in direc.lower() and "-" in direc.lower():
136 all_anchor = [h_off + noext_H - config['context_thickness'], 2 * h_off + noext_H, 0, w_off + config['context_thickness']]
137 global_shift = [all_anchor[0], all_anchor[2]]
138 mask_anchor = [h_off + noext_H, 2 * h_off + noext_H, 0, w_off]

Callers 1

write_meshFunction · 0.90

Calls 6

refine_depth_around_edgeFunction · 0.90
update_infoFunction · 0.85
toMethod · 0.80
appendMethod · 0.80
getMethod · 0.80
forward_3PMethod · 0.45

Tested by

no test coverage detected