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

Function fill_dummy_bord

inpaint/mesh_tools.py:471–501  ·  view source on GitHub ↗
(mesh, info_on_pix, image, depth, config)

Source from the content-addressed store, hash-verified

469 return osize
470
471def fill_dummy_bord(mesh, info_on_pix, image, depth, config):
472 context = np.zeros_like(depth).astype(np.uint8)
473 context[mesh.graph['hoffset']:mesh.graph['hoffset'] + mesh.graph['noext_H'],
474 mesh.graph['woffset']:mesh.graph['woffset'] + mesh.graph['noext_W']] = 1
475 mask = 1 - context
476 xs, ys = np.where(mask > 0)
477 depth = depth * context
478 image = image * context[..., None]
479 cur_depth = 0
480 cur_disp = 0
481 color = [0, 0, 0]
482 for x, y in zip(xs, ys):
483 cur_node = (x, y, cur_depth)
484 mesh.add_node(cur_node, color=color,
485 synthesis=False,
486 disp=cur_disp,
487 cc_id=set(),
488 ext_pixel=True)
489 info_on_pix[(x, y)] = [{'depth':cur_depth,
490 'color':mesh.nodes[(x, y, cur_depth)]['color'],
491 'synthesis':False,
492 'disp':mesh.nodes[cur_node]['disp'],
493 'ext_pixel':True}]
494 # for x, y in zip(xs, ys):
495 four_nes = [(xx, yy) for xx, yy in [(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)] if\
496 0 <= x < mesh.graph['H'] and 0 <= y < mesh.graph['W'] and info_on_pix.get((xx, yy)) is not None]
497 for ne in four_nes:
498 # if (ne[0] - x) + (ne[1] - y) == 1 and info_on_pix.get((ne[0], ne[1])) is not None:
499 mesh.add_edge(cur_node, (ne[0], ne[1], info_on_pix[(ne[0], ne[1])][0]['depth']))
500
501 return mesh, info_on_pix
502
503
504def enlarge_border(mesh, info_on_pix, depth, image, config):

Callers 1

write_meshFunction · 0.90

Calls 1

getMethod · 0.80

Tested by

no test coverage detected