Add comprehensive tests for image processing and mask functionalities

- Introduced tests for color image handling, ensuring source preservation and premultiplied alpha usage.
- Implemented tests for brush stroke operations, validating segment boundaries and brush anti-aliasing.
- Added tests for frame anti-aliasing, confirming correct rendering behavior with various alpha values and depth settings.
- Created tests for frame projection, ensuring accurate overlap calculations and half-plane clipping.
- Developed tests for image premultiplied retention, verifying behavior during loading and packing processes.
- Added undo functionality tests for mask operations, ensuring single transaction behavior during edits.
This commit is contained in:
2026-09-05 21:33:11 +08:00
parent bbaa4bff46
commit 1994d38ccd
111 changed files with 7691 additions and 2341 deletions

View File

@@ -3,33 +3,20 @@
from pathlib import Path
from ..geometry.prediction_artifacts import generate_moge2_artifacts
from ..selection import refine_selection
def run(context, parameters):
context.progress(0.05, "Preparing Cutout Selection")
context.directory.mkdir(parents=True, exist_ok=True)
input_path = Path(parameters["input"])
selection_image_path = input_path
result = {}
if parameters.get("refine_selection"):
context.progress(0.2, "Refining Selection")
selection_image_path = refine_selection(
context,
input_path,
parameters["refine_model"],
parameters["device"],
context.directory / "selection.png",
)
result["selection_image"] = selection_image_path.name
depth_mode = str(parameters.get("depth_mode", "NONE"))
normal_mode = str(parameters.get("normal_mode", "NONE"))
if depth_mode != "NONE" or normal_mode != "NONE":
artifacts = generate_moge2_artifacts(
context,
parameters,
selection_image_path,
input_path,
depth_mode=depth_mode,
normal_mode=normal_mode,
)

View File

@@ -1,24 +0,0 @@
import time
from ..selection import refine_selection
def run(context, parameters):
"""Refine foreground Alpha while preserving the submitted bounds canvas."""
started = time.perf_counter()
context.progress(0.05, "Preparing image Selection")
context.check_cancelled()
output_directory = context.directory
output_directory.mkdir(parents=True, exist_ok=True)
context.progress(0.2, f"Loading BEN2 for {parameters['device'].upper()}")
output_path = refine_selection(
context,
parameters["input"],
parameters["model"],
parameters["device"],
output_directory / "image.png",
)
elapsed_ms = (time.perf_counter() - started) * 1000.0
message = f"Image Selection refined in {elapsed_ms:.0f} ms"
context.progress(1.0, message)
return {"selection_image": output_path.name}