Remove obsolete implementation and simplify project structure

This commit is contained in:
2026-08-21 09:46:50 +08:00
parent b5a2f9690c
commit af5603045c
100 changed files with 365 additions and 365 deletions

View File

@@ -0,0 +1,26 @@
from ..media import copy_frames
from ..models.ben2 import infer_foreground
from .common import input_frames
def run(context, parameters):
context.progress(0.02, "Preparing BEN2 API input")
context.directory.mkdir(parents=True, exist_ok=True)
model_manager = context.resource("model_manager")
model_directory = model_manager.directory(parameters["model"])
with input_frames(context, parameters) as images:
for index, image in enumerate(images):
context.check_cancelled()
foreground, _load_ms, _inference_ms = infer_foreground(
image,
model_directory,
parameters["device"],
model_cache=model_manager,
cancel_check=context.check_cancelled,
)
suffix = "" if len(images) == 1 else f".{index + 1:04d}"
foreground.save(context.directory / f"foreground{suffix}.png")
copy_frames(images, context.directory)
context.check_cancelled()
context.progress(1.0, "Saved raw BEN2 API foreground")
return {"directory": "."}