MCPcopy Create free account
hub / github.com/thygate/stable-diffusion-webui-depthmap-script / recursive_add_edge

Function recursive_add_edge

inpaint/mesh_tools.py:815–839  ·  view source on GitHub ↗
(edge_mesh, mesh, info_on_pix, cur_node, mark)

Source from the content-addressed store, hash-verified

813 return mesh
814
815def recursive_add_edge(edge_mesh, mesh, info_on_pix, cur_node, mark):
816 ne_nodes = [(x[0], x[1]) for x in edge_mesh.neighbors(cur_node)]
817 for node_xy in ne_nodes:
818 node = (node_xy[0], node_xy[1], info_on_pix[node_xy][0]['depth'])
819 if mark[node[0], node[1]] != 3:
820 continue
821 else:
822 mark[node[0], node[1]] = 0
823 mesh.remove_edges_from([(xx, node) for xx in mesh.neighbors(node)])
824 mesh = build_connection(mesh, cur_node, node)
825 re_info = dict(depth=0, count=0)
826 for re_ne in mesh.neighbors(node):
827 re_info['depth'] += re_ne[2]
828 re_info['count'] += 1.
829 try:
830 re_depth = re_info['depth'] / re_info['count']
831 except:
832 re_depth = node[2]
833 re_node = (node_xy[0], node_xy[1], re_depth)
834 mapping_dict = {node: re_node}
835 info_on_pix, edge_mesh, mesh = update_info(mapping_dict, info_on_pix, edge_mesh, mesh)
836
837 edge_mesh, mesh, mark, info_on_pix = recursive_add_edge(edge_mesh, mesh, info_on_pix, re_node, mark)
838
839 return edge_mesh, mesh, mark, info_on_pix
840
841def resize_for_edge(tensor_dict, largest_size):
842 resize_dict = {k: v.clone() for k, v in tensor_dict.items()}

Callers 1

remove_danglingFunction · 0.90

Calls 2

build_connectionFunction · 0.85
update_infoFunction · 0.85

Tested by

no test coverage detected