feat: Add restore cutout depth extension with edge depth correction
- Introduced a new extension for restoring cutout depth with edge correction. - Implemented edge depth extension algorithm in `edge_depth.py` to enhance depth accuracy near cutout edges. - Updated `generate_moge_artifacts` to include an option for extending depth edges during depth generation. - Modified cutout job processing to enable edge depth extension based on depth request. - Added comprehensive tests for edge depth functionality, ensuring correct behavior under various scenarios. - Updated existing node loading functions to remove asset revision dependencies, simplifying the loading process. - Created new design and proposal documentation outlining the goals and decisions for the extension.
This commit is contained in:
@@ -58,8 +58,9 @@ def test_alpha_resize_retains_threshold_values(tmp_path):
|
||||
(False, "OBJECT"),
|
||||
],
|
||||
)
|
||||
def test_artifacts_preserve_original_geometry_with_alpha(
|
||||
tmp_path, generate_depth, normal_mode
|
||||
@pytest.mark.parametrize("extend_depth_edges", [False, True])
|
||||
def test_artifacts_extend_only_requested_depth_and_preserve_normals(
|
||||
tmp_path, generate_depth, normal_mode, extend_depth_edges
|
||||
):
|
||||
frame, alpha = silhouette()
|
||||
rgba = np.full((*alpha.shape, 4), 255, np.uint8)
|
||||
@@ -73,7 +74,7 @@ def test_artifacts_preserve_original_geometry_with_alpha(
|
||||
check_cancelled=lambda: None,
|
||||
)
|
||||
with (
|
||||
patch.object(artifacts.moge, "infer", return_value=frame),
|
||||
patch.object(artifacts.moge, "infer", return_value=frame) as infer,
|
||||
patch.object(
|
||||
artifacts, "write_depth_texture",
|
||||
return_value=tmp_path / "depth.exr",
|
||||
@@ -84,10 +85,14 @@ def test_artifacts_preserve_original_geometry_with_alpha(
|
||||
patch.object(
|
||||
artifacts, "_write_normal", return_value=tmp_path / "normal.png"
|
||||
) as normal,
|
||||
patch.object(artifacts, "extend_edge_depth", wraps=artifacts.extend_edge_depth) as extend,
|
||||
):
|
||||
artifacts.generate_moge_artifacts(
|
||||
context, {}, path, generate_depth=generate_depth, normal_mode=normal_mode,
|
||||
**({"extend_depth_edges": True} if extend_depth_edges else {}),
|
||||
)
|
||||
infer.assert_called_once()
|
||||
assert extend.call_count == int(generate_depth and extend_depth_edges)
|
||||
if normal_mode != "NONE":
|
||||
assert normal.call_args.args[0] is frame
|
||||
else:
|
||||
@@ -96,8 +101,9 @@ def test_artifacts_preserve_original_geometry_with_alpha(
|
||||
written_frame = depth.call_args.args[0]
|
||||
np.testing.assert_array_equal(depth.call_args.kwargs["alpha"], alpha)
|
||||
assert metadata.call_args.args[0] is written_frame
|
||||
assert written_frame is frame
|
||||
assert written_frame.depth[12, 24] == 20
|
||||
assert (written_frame is frame) == (not extend_depth_edges)
|
||||
assert written_frame.depth[12, 24] == (2 if extend_depth_edges else 20)
|
||||
assert frame.depth[12, 24] == 20
|
||||
assert written_frame.validity is frame.validity
|
||||
else:
|
||||
metadata.assert_not_called()
|
||||
|
||||
Reference in New Issue
Block a user