Consolidate the duplicated pipeline in clip_manager.py and backend/
The problem
clip_manager.py contains a second, independent implementation of the core pipeline that parallels backend/: its own ClipAsset/ClipEntry/asset discovery, its own run_inference, run_videomama, and alpha-generation orchestration. The CLI/wizard uses the clip_manager path; backend/service.py (built for programmatic/UI use) uses the other.
The two have already diverged in behavior, not just style:
- Asset attribute naming differs (
.typevs.asset_type), so helpers aren't interchangeable. - Mask channel handling:
clip_manager.run_inferencenormalizes channels inline, while the backend path routes throughvalidators.normalize_mask_*— edge cases (RGBA masks, 16-bit PNGs) can key differently depending on entry point. - Error handling:
clip_managerbreaks out of a clip on the first failed video read, whilebackend/service.pyrecords a skip and continues. - Fixes tend to land on one side only — e.g. #261 fixes a soft-alpha binarization bug in
backend/service.py's VideoMaMa write path thatclip_manager's equivalent never had, and conversely resume/skip-existing behaviors have evolved separately.
Every future fix now needs to be written (and reviewed) twice, or the entry points silently drift apart.
Proposed direction
Make backend/ the single implementation and turn clip_manager.py into a thin orchestration layer over CorridorKeyService, in small reviewable steps:
- Types first: replace
clip_manager'sClipEntry/ClipAsset/scan with imports frombackend.clip_state(adapting the.type→.asset_typerename). No behavior change intended; existing CLI tests keep passing. - Inference: route
clip_manager.run_inferencethroughservice.run_inference, mappingInferenceSettings→InferenceParams/OutputConfigand bridging the progress-callback protocols. - Alpha generation: same for GVM / VideoMaMa / BiRefNet orchestration.
- Delete the dead duplicates once nothing references them.
Each step is a separate PR so behavior differences surface one at a time instead of in one giant diff. This also composes with #236 (retiring the argparse CLI) — happy to coordinate/rebase around it.
I'm offering to implement this — posting the plan first since it touches the project's spine and you may have opinions on which side's behavior should win where they differ.
Generated with Claude Code
Source: nikopueringer/CorridorKey