[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79657BGN380JWKQ49F3WEFY":3,"skill-same:01M79657BGN380JWKQ49F3WEFY":66},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":26,"commitSha":27,"skillDirectory":28,"forksCount":29,"repositoryHtmlUrl":30,"repositoryHomepageUrl":6,"ownerHtmlUrl":31,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":32,"install":33,"resources":45},"01M79657BGN380JWKQ49F3WEFY","matting-inference",null,"Build, validate, and run the repository's MODNet matting pipeline from a PyTorch checkpoint through fixed-shape ONNX and TensorRT, then blend image, video, camera, and background inputs.","VectorSpaceLab\u002FAREX-Skill","VectorSpaceLab","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F180637102?v=4","01M7538C5WPSJGWF7KHR4EFZ9F","01M7538C6R2GFP53NPXTCZNBRT",351,"MIT","https:\u002F\u002Fgithub.com\u002FVectorSpaceLab\u002FAREX-Skill\u002Fblob\u002Fmain\u002Fskills\u002Frepositories\u002Frepo-skills\u002Ftensorrt-demos\u002Fsub-skills\u002Fmatting-inference\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: \"matting-inference\"\ndescription: \"Build, validate, and run the repository's MODNet matting pipeline\n  from a PyTorch checkpoint through fixed-shape ONNX and TensorRT, then blend\n  image, video, camera, and background inputs.\"\ndisable-model-invocation: true\nmetadata:\n  disco-role: operating\nlicense: MIT\n---\n\n# MODNet Matting Inference\n\nUse this skill when the task is to export MODNet, validate its ONNX graph,\nbuild the repository's TensorRT engine, or run `trt_modnet.py` for image\u002Fvideo\u002F\ncamera matting. The procedures are grounded in this repository at\n`modnet\u002F`, `trt_modnet.py`, `test_modnet.py`, and the MODNet-related files under\n`utils\u002F`.\n\nThis is an operating skill, not a model distribution. The skill does **not**\nbundle the MODNet PyTorch checkpoint, a generated TensorRT engine, or the\nthird-party `modnet\u002Fonnx-tensorrt` submodule. Obtain model weights separately\nunder their upstream license (the README identifies the pretrained MODNet\nweights as CC BY-NC-SA 4.0), and keep generated artifacts outside the skill\nbundle. The repository checkout may contain `modnet\u002Fmodnet.onnx`, but a runtime\nmust not assume that artifact is present in every checkout.\n\n## Fast route\n\nRun commands from the repository root unless a step explicitly says `cd modnet`.\nThe intended fixed-shape route is:\n\n1. Obtain a compatible MODNet checkpoint, preferably the portrait matting\n   checkpoint named in `modnet\u002FREADME.md`.\n2. Export a batch-1 ONNX model with width `512`, height `288`:\n\n   ```bash\n   cd modnet\n   python -m torch2onnx.export --width 512 --height 288 \\\n       \u002Fpath\u002Fto\u002Fmodnet_webcam_portrait_matting.ckpt modnet.onnx\n   cd ..\n   ```\n\n3. Validate the ONNX graph on CPU with ONNX Runtime; see\n   [workflows.md](references\u002Fworkflows.md).\n4. Build an FP16 TensorRT engine with dimensions matching the ONNX export:\n\n   ```bash\n   cd modnet\n   python onnx_to_tensorrt.py --width 512 --height 288 \\\n       modnet.onnx modnet.engine\n   cd ..\n   ```\n\n   The script's CLI defaults are `640x480`, so do not rely on its defaults for\n   the `512x288` export. Also inspect the input name before building: the\n   exporter writes `input` (lowercase), while this historical builder passes\n   `Input` (uppercase) to `profile.set_shape`. If TensorRT rejects `Input` as\n   an unknown profile tensor, make the minimal local source correction to use\n   the actual input name (`input`), then rerun the build. Do not silently use a\n   profile shape or input name that differs from the ONNX graph.\n5. From the repository root, run an input mode such as:\n\n   ```bash\n   python3 trt_modnet.py --image modnet\u002Fimage.jpg\n   ```\n\n   `utils.modnet.TrtMODNet` loads `modnet\u002Fmodnet.engine` by this exact\n   repository-relative path; `trt_modnet.py` has no `--engine` option.\n\n## Pipeline contract\n\n### PyTorch to ONNX\n\n`modnet\u002Ftorch2onnx\u002Fexport.py` constructs `MODNet()` with the MobileNetV2\nbackbone, loads the checkpoint into a CUDA `DataParallel` wrapper, switches to\nevaluation mode, and calls `torch.onnx.export` with opset 11, input name\n`input`, and output name `output`. The exported batch is fixed at 1 and the\nexport dimensions are fixed. The model implementation asserts that its input\nheight and width are divisible by 4; keep that invariant for custom dimensions.\n\nThe documented `512x288` context means **width 512, height 288**, and therefore\nthe tensor shape is `[1, 3, 288, 512]` (NCHW). Do not reverse width and height.\nThe exporter creates its dummy tensor as uniform values in `[-1, 1]` on CUDA;\nit is not a CPU-only exporter. The checkpoint must match this repository's\nMODNet architecture\u002Fstate-dict keys. `backbone.py` has a separate optional\nMobileNetV2 pretrained-checkpoint path, but the export script loads the supplied\nMODNet checkpoint directly and does not invoke that path.\n\n### ONNX validation\n\n`modnet\u002Ftest_onnx.py` is a small visual check. From `modnet\u002F`, it reads\n`image.jpg`, resizes it to `(512, 288)`, converts BGR to RGB, transposes to\nCHW, casts to `float32`, and normalizes with `(pixel - 127.5) \u002F 127.5`. It\ncreates an ONNX Runtime session without requesting CUDA and displays the\nsingle output as a grayscale OpenCV window. The script discovers the graph's\ninput and output names at runtime. It does not save a result or assert a\nmetric, and it requires a GUI; treat a successful session plus a plausible\nmatte as the source-level acceptance signal, not as a benchmark.\n\nFor a headless or auditable check, use ONNX Runtime CPU to reproduce the same\npreprocess, assert that the graph accepts `[1,3,288,512]`, assert one output\nwith a single-channel spatial matte, and record finite output values. Keep this\ncheck separate from TensorRT: CPU ONNX validation proves graph execution and\npre\u002Fpostprocessing, not CUDA\u002FTensorRT parity.\n\n### ONNX to TensorRT\n\n`modnet\u002Fonnx_to_tensorrt.py` requires TensorRT 7 or newer, parses the ONNX graph\nwith the explicit-batch API, forces batch 1, allocates a 1 GiB workspace,\nenables GPU fallback and FP16, and creates a fixed optimization profile. The\nprofile must agree with the graph's actual input tensor name and shape. The\nscript writes a serialized engine only after `build_engine` returns a non-None\nengine.\n\nThe `--int8` and `--dla_core` flags exist in the parser but the implementation\nraises `RuntimeError('INT8 not implemented yet')` or\n`RuntimeError('DLA_core not implemented yet')`; they are not supported paths\nfor MODNet in this repository. Use the default FP16 route. The generated\nengine is hardware\u002Fruntime-specific and must be rebuilt when the TensorRT,\nCUDA, GPU\u002FJetson target, or relevant engine-building inputs change.\n\n#### TensorRT 7.1 versus 7.2+\n\nThe repository README reports that TensorRT 7.1 fails on MODNet's\n`InstanceNormalization` with an error like:\n\n```text\nUNSUPPORTED_NODE: ... InstanceNormalization does not support dynamic inputs!\n```\n\nTensorRT 7.2 fixes the issue for the standard Python builder route. On 7.2 or\nlater, use `modnet\u002Fonnx_to_tensorrt.py` after matching dimensions and correcting\nthe historical profile-name mismatch if needed. On 7.1, the documented\nworkaround is to fetch and build the `onnx-tensorrt` submodule locally, patch\nits old CMake requirement as described in [workflows.md](references\u002Fworkflows.md),\nand invoke its `onnx2trt` binary with `-d 16 -v`. This is a version-bound\nthird-party build, not a bundled dependency; record the exact TensorRT,\nonnx-tensorrt, compiler, and CUDA versions. Do not claim that the workaround\nworks on an untested modern combination.\n\n### TensorRT runtime and matting\n\n`utils\u002Fmodnet.py` implements `TrtMODNet` for TensorRT 7+ and PyCUDA. It\ninitializes built-in TensorRT plugins, deserializes\n`modnet\u002Fmodnet.engine`, and expects exactly two bindings in order: `input` and\n`output`. It requires float input\u002Foutput bindings, input shape `[1,3,H,W]`,\nand output shape `[1,1,H,W]`. The engine's H\u002FW are used as the inference input\nshape; the returned matte is resized back to the original frame's H\u002FW.\n\nEach frame is processed as follows:\n\n1. Resize BGR input to the engine's `(W,H)` with `cv2.INTER_AREA`.\n2. Convert BGR to RGB, transpose HWC to CHW, cast to `float32`.\n3. Normalize each channel with `(x - 127.5) \u002F 127.5`.\n4. Copy the contiguous tensor to a pagelocked CUDA buffer and run\n   `execute_async_v2`.\n5. Reshape the output to the engine output's last two dimensions and resize it\n   to the original frame shape.\n\n`trt_modnet.py` blends the original BGR frame and a background using\n`img * matte + bg * (1 - matte)`. The runtime therefore expects a matte whose\nvalues behave like `[0,1]`; do not convert it to `[0,255]` before blending.\nThe source docstring's phrase “0 or 255 pixels” is stale relative to this\nblend formula. `pycuda.autoinit` creates a CUDA context at import time, so help\nor runtime checks can fail before argument parsing when PyCUDA\u002FCUDA is absent.\n\n## Input, background, demo, and recording behavior\n\n`trt_modnet.py` combines `Camera`, `Background`, `BackgroundBlender`, and an\noptional writer:\n\n- `--image FILE`: read a still image repeatedly. Without `--do_resize`, its\n  native dimensions become the output dimensions.\n- `--video FILE`: read a video. `--video_looping` reopens it at EOF;\n  `--do_resize --width W --height H` resizes frames to the requested output.\n- `--rtsp URI`: open an RTSP H.264 stream through a detected GStreamer decoder;\n  `--rtsp_latency` defaults to 200 ms.\n- `--usb ID`: open `\u002Fdev\u002FvideoID`; the source defaults to a GStreamer USB path.\n- `--gstr TEMPLATE`: format a GStreamer string with `{width}` and `{height}`.\n- `--onboard ID`: select the Jetson onboard camera. The ID is parsed but the\n  legacy pipeline itself does not interpolate it.\n- `--width`\u002F`--height`: default to `640x480`; live sources use these values,\n  while image\u002Fvideo behavior depends on `--do_resize` as above.\n- `--copy_frame`: copy live capture frames before processing. This avoids\n  reusing a capture-owned array when inference or overlays outlive the read.\n- `--background FILE`: a lowercase `.jpg` or `.png` is resized and repeated; a\n  lowercase `.mp4` or `.ts` is read and looped; an empty value produces a black\n  background. Other suffixes raise `ValueError`, and unreadable image\u002Fvideo\n  sources fail during construction or reads.\n- `--demo_mode`: changes the blender only. It cycles every 360 frames through\n  black-background reveal, black background, replacement-background reveal,\n  replacement background, original-background reveal, and original background.\n  The sequence is documented precisely in [api-reference.md](api-reference.md).\n- `--create_video NAME`: writes every blended frame. `utils\u002Fwriter.py` tries a\n  Jetson GStreamer\u002FH.264 transport stream and otherwise uses OpenCV `mp4v`.\n  The implementation appends `.ts` or `.mp4` to `NAME`; pass a basename rather\n  than an already suffixed filename.\n\nThe display loop stops when the window closes, a source returns `None`, or ESC\nis pressed. `F` toggles fullscreen. The writer and camera are released on\nnormal completion; headless operation is not implemented by the demo itself.\n\n## Required checks before handing off a run\n\n- Confirm the checkpoint, ONNX, and engine paths and record their provenance;\n  never infer that a missing artifact can be downloaded automatically.\n- Confirm ONNX input\u002Foutput names and fixed shape. For the documented export,\n  expect `input`, `output`, batch 1, and `[1,3,288,512]` input.\n- Run the CPU ONNX check independently of the GPU engine check.\n- Run the TensorRT builder with a profile name that exists in the parsed graph,\n  dimensions matching the exported graph, and no unsupported `--int8` or\n  `--dla_core` flags.\n- Confirm the deserialized engine has exactly the two expected bindings and\n  that a CUDA inference returns a finite matte at the original frame size.\n- For video\u002Fcamera runs, verify the selected source, background dimensions,\n  writer output suffix, and a clean ESC\u002Fwindow-close shutdown.\n- Use the bundled safe validator before execution when only configuration\n  review is possible:\n\n  ```bash\n  python3 skills\u002Fdisco\u002Ftensorrt-demos\u002Fsub-skills\u002Fmatting-inference\u002Fscripts\u002Fvalidate-matting-config.py \\\n      --onnx modnet\u002Fmodnet.onnx --engine modnet\u002Fmodnet.engine \\\n      --export-width 512 --export-height 288\n  ```\n\nThe validator performs no model import, CUDA initialization, file download,\nsubprocess execution, or file mutation. It checks configuration semantics only.\nFor detailed failure recovery, use [troubleshooting.md](troubleshooting.md).\n\n## Source evidence\n\nThis skill was distilled from `modnet\u002FREADME.md`, the complete\n`modnet\u002Ftorch2onnx\u002F` exporter\u002Fmodel implementation, `modnet\u002Ftest_onnx.py`,\n`modnet\u002Fonnx_to_tensorrt.py`, `trt_modnet.py`, `test_modnet.py`, and the\nMODNet runtime helpers `utils\u002Fmodnet.py`, `utils\u002Fbackground.py`,\n`utils\u002Fwriter.py`, `utils\u002Fcamera.py`, and `utils\u002Fdisplay.py`. Repository-level\nMODNet instructions and compatibility claims were cross-checked against the\nMODNet section of `README.md`. The generated skill intentionally excludes the\nuninitialized `modnet\u002Fonnx-tensorrt` source and all model\u002Fengine binaries.\n","# MODNet Matting Inference\n\nUse this skill when the task is to export MODNet, validate its ONNX graph,\nbuild the repository's TensorRT engine, or run `trt_modnet.py` for image\u002Fvideo\u002F\ncamera matting. The procedures are grounded in this repository at\n`modnet\u002F`, `trt_modnet.py`, `test_modnet.py`, and the MODNet-related files under\n`utils\u002F`.\n\nThis is an operating skill, not a model distribution. The skill does **not**\nbundle the MODNet PyTorch checkpoint, a generated TensorRT engine, or the\nthird-party `modnet\u002Fonnx-tensorrt` submodule. Obtain model weights separately\nunder their upstream license (the README identifies the pretrained MODNet\nweights as CC BY-NC-SA 4.0), and keep generated artifacts outside the skill\nbundle. The repository checkout may contain `modnet\u002Fmodnet.onnx`, but a runtime\nmust not assume that artifact is present in every checkout.\n\n## Fast route\n\nRun commands from the repository root unless a step explicitly says `cd modnet`.\nThe intended fixed-shape route is:\n\n1. Obtain a compatible MODNet checkpoint, preferably the portrait matting\n   checkpoint named in `modnet\u002FREADME.md`.\n2. Export a batch-1 ONNX model with width `512`, height `288`:\n\n   ```bash\n   cd modnet\n   python -m torch2onnx.export --width 512 --height 288 \\\n       \u002Fpath\u002Fto\u002Fmodnet_webcam_portrait_matting.ckpt modnet.onnx\n   cd ..\n   ```\n\n3. Validate the ONNX graph on CPU with ONNX Runtime; see\n   [workflows.md](references\u002Fworkflows.md).\n4. Build an FP16 TensorRT engine with dimensions matching the ONNX export:\n\n   ```bash\n   cd modnet\n   python onnx_to_tensorrt.py --width 512 --height 288 \\\n       modnet.onnx modnet.engine\n   cd ..\n   ```\n\n   The script's CLI defaults are `640x480`, so do not rely on its defaults for\n   the `512x288` export. Also inspect the input name before building: the\n   exporter writes `input` (lowercase), while this historical builder passes\n   `Input` (uppercase) to `profile.set_shape`. If TensorRT rejects `Input` as\n   an unknown profile tensor, make the minimal local source correction to use\n   the actual input name (`input`), then rerun the build. Do not silently use a\n   profile shape or input name that differs from the ONNX graph.\n5. From the repository root, run an input mode such as:\n\n   ```bash\n   python3 trt_modnet.py --image modnet\u002Fimage.jpg\n   ```\n\n   `utils.modnet.TrtMODNet` loads `modnet\u002Fmodnet.engine` by this exact\n   repository-relative path; `trt_modnet.py` has no `--engine` option.\n\n## Pipeline contract\n\n### PyTorch to ONNX\n\n`modnet\u002Ftorch2onnx\u002Fexport.py` constructs `MODNet()` with the MobileNetV2\nbackbone, loads the checkpoint into a CUDA `DataParallel` wrapper, switches to\nevaluation mode, and calls `torch.onnx.export` with opset 11, input name\n`input`, and output name `output`. The exported batch is fixed at 1 and the\nexport dimensions are fixed. The model implementation asserts that its input\nheight and width are divisible by 4; keep that invariant for custom dimensions.\n\nThe documented `512x288` context means **width 512, height 288**, and therefore\nthe tensor shape is `[1, 3, 288, 512]` (NCHW). Do not reverse width and height.\nThe exporter creates its dummy tensor as uniform values in `[-1, 1]` on CUDA;\nit is not a CPU-only exporter. The checkpoint must match this repository's\nMODNet architecture\u002Fstate-dict keys. `backbone.py` has a separate optional\nMobileNetV2 pretrained-checkpoint path, but the export script loads the supplied\nMODNet checkpoint directly and does not invoke that path.\n\n### ONNX validation\n\n`modnet\u002Ftest_onnx.py` is a small visual check. From `modnet\u002F`, it reads\n`image.jpg`, resizes it to `(512, 288)`, converts BGR to RGB, transposes to\nCHW, casts to `float32`, and normalizes with `(pixel - 127.5) \u002F 127.5`. It\ncreates an ONNX Runtime session without requesting CUDA and displays the\nsingle output as a grayscale OpenCV window. The script discovers the graph's\ninput and output names at runtime. It does not save a result or assert a\nmetric, and it requires a GUI; treat a successful session plus a plausible\nmatte as the source-level acceptance signal, not as a benchmark.\n\nFor a headless or auditable check, use ONNX Runtime CPU to reproduce the same\npreprocess, assert that the graph accepts `[1,3,288,512]`, assert one output\nwith a single-channel spatial matte, and record finite output values. Keep this\ncheck separate from TensorRT: CPU ONNX validation proves graph execution and\npre\u002Fpostprocessing, not CUDA\u002FTensorRT parity.\n\n### ONNX to TensorRT\n\n`modnet\u002Fonnx_to_tensorrt.py` requires TensorRT 7 or newer, parses the ONNX graph\nwith the explicit-batch API, forces batch 1, allocates a 1 GiB workspace,\nenables GPU fallback and FP16, and creates a fixed optimization profile. The\nprofile must agree with the graph's actual input tensor name and shape. The\nscript writes a serialized engine only after `build_engine` returns a non-None\nengine.\n\nThe `--int8` and `--dla_core` flags exist in the parser but the implementation\nraises `RuntimeError('INT8 not implemented yet')` or\n`RuntimeError('DLA_core not implemented yet')`; they are not supported paths\nfor MODNet in this repository. Use the default FP16 route. The generated\nengine is hardware\u002Fruntime-specific and must be rebuilt when the TensorRT,\nCUDA, GPU\u002FJetson target, or relevant engine-building inputs change.\n\n#### TensorRT 7.1 versus 7.2+\n\nThe repository README reports that TensorRT 7.1 fails on MODNet's\n`InstanceNormalization` with an error like:\n\n```text\nUNSUPPORTED_NODE: ... InstanceNormalization does not support dynamic inputs!\n```\n\nTensorRT 7.2 fixes the issue for the standard Python builder route. On 7.2 or\nlater, use `modnet\u002Fonnx_to_tensorrt.py` after matching dimensions and correcting\nthe historical profile-name mismatch if needed. On 7.1, the documented\nworkaround is to fetch and build the `onnx-tensorrt` submodule locally, patch\nits old CMake requirement as described in [workflows.md](references\u002Fworkflows.md),\nand invoke its `onnx2trt` binary with `-d 16 -v`. This is a version-bound\nthird-party build, not a bundled dependency; record the exact TensorRT,\nonnx-tensorrt, compiler, and CUDA versions. Do not claim that the workaround\nworks on an untested modern combination.\n\n### TensorRT runtime and matting\n\n`utils\u002Fmodnet.py` implements `TrtMODNet` for TensorRT 7+ and PyCUDA. It\ninitializes built-in TensorRT plugins, deserializes\n`modnet\u002Fmodnet.engine`, and expects exactly two bindings in order: `input` and\n`output`. It requires float input\u002Foutput bindings, input shape `[1,3,H,W]`,\nand output shape `[1,1,H,W]`. The engine's H\u002FW are used as the inference input\nshape; the returned matte is resized back to the original frame's H\u002FW.\n\nEach frame is processed as follows:\n\n1. Resize BGR input to the engine's `(W,H)` with `cv2.INTER_AREA`.\n2. Convert BGR to RGB, transpose HWC to CHW, cast to `float32`.\n3. Normalize each channel with `(x - 127.5) \u002F 127.5`.\n4. Copy the contiguous tensor to a pagelocked CUDA buffer and run\n   `execute_async_v2`.\n5. Reshape the output to the engine output's last two dimensions and resize it\n   to the original frame shape.\n\n`trt_modnet.py` blends the original BGR frame and a background using\n`img * matte + bg * (1 - matte)`. The runtime therefore expects a matte whose\nvalues behave like `[0,1]`; do not convert it to `[0,255]` before blending.\nThe source docstring's phrase “0 or 255 pixels” is stale relative to this\nblend formula. `pycuda.autoinit` creates a CUDA context at import time, so help\nor runtime checks can fail before argument parsing when PyCUDA\u002FCUDA is absent.\n\n## Input, background, demo, and recording behavior\n\n`trt_modnet.py` combines `Camera`, `Background`, `BackgroundBlender`, and an\noptional writer:\n\n- `--image FILE`: read a still image repeatedly. Without `--do_resize`, its\n  native dimensions become the output dimensions.\n- `--video FILE`: read a video. `--video_looping` reopens it at EOF;\n  `--do_resize --width W --height H` resizes frames to the requested output.\n- `--rtsp URI`: open an RTSP H.264 stream through a detected GStreamer decoder;\n  `--rtsp_latency` defaults to 200 ms.\n- `--usb ID`: open `\u002Fdev\u002FvideoID`; the source defaults to a GStreamer USB path.\n- `--gstr TEMPLATE`: format a GStreamer string with `{width}` and `{height}`.\n- `--onboard ID`: select the Jetson onboard camera. The ID is parsed but the\n  legacy pipeline itself does not interpolate it.\n- `--width`\u002F`--height`: default to `640x480`; live sources use these values,\n  while image\u002Fvideo behavior depends on `--do_resize` as above.\n- `--copy_frame`: copy live capture frames before processing. This avoids\n  reusing a capture-owned array when inference or overlays outlive the read.\n- `--background FILE`: a lowercase `.jpg` or `.png` is resized and repeated; a\n  lowercase `.mp4` or `.ts` is read and looped; an empty value produces a black\n  background. Other suffixes raise `ValueError`, and unreadable image\u002Fvideo\n  sources fail during construction or reads.\n- `--demo_mode`: changes the blender only. It cycles every 360 frames through\n  black-background reveal, black background, replacement-background reveal,\n  replacement background, original-background reveal, and original background.\n  The sequence is documented precisely in [api-reference.md](api-reference.md).\n- `--create_video NAME`: writes every blended frame. `utils\u002Fwriter.py` tries a\n  Jetson GStreamer\u002FH.264 transport stream and otherwise uses OpenCV `mp4v`.\n  The implementation appends `.ts` or `.mp4` to `NAME`; pass a basename rather\n  than an already suffixed filename.\n\nThe display loop stops when the window closes, a source returns `None`, or ESC\nis pressed. `F` toggles fullscreen. The writer and camera are released on\nnormal completion; headless operation is not implemented by the demo itself.\n\n## Required checks before handing off a run\n\n- Confirm the checkpoint, ONNX, and engine paths and record their provenance;\n  never infer that a missing artifact can be downloaded automatically.\n- Confirm ONNX input\u002Foutput names and fixed shape. For the documented export,\n  expect `input`, `output`, batch 1, and `[1,3,288,512]` input.\n- Run the CPU ONNX check independently of the GPU engine check.\n- Run the TensorRT builder with a profile name that exists in the parsed graph,\n  dimensions matching the exported graph, and no unsupported `--int8` or\n  `--dla_core` flags.\n- Confirm the deserialized engine has exactly the two expected bindings and\n  that a CUDA inference returns a finite matte at the original frame size.\n- For video\u002Fcamera runs, verify the selected source, background dimensions,\n  writer output suffix, and a clean ESC\u002Fwindow-close shutdown.\n- Use the bundled safe validator before execution when only configuration\n  review is possible:\n\n  ```bash\n  python3 skills\u002Fdisco\u002Ftensorrt-demos\u002Fsub-skills\u002Fmatting-inference\u002Fscripts\u002Fvalidate-matting-config.py \\\n      --onnx modnet\u002Fmodnet.onnx --engine modnet\u002Fmodnet.engine \\\n      --export-width 512 --export-height 288\n  ```\n\nThe validator performs no model import, CUDA initialization, file download,\nsubprocess execution, or file mutation. It checks configuration semantics only.\nFor detailed failure recovery, use [troubleshooting.md](troubleshooting.md).\n\n## Source evidence\n\nThis skill was distilled from `modnet\u002FREADME.md`, the complete\n`modnet\u002Ftorch2onnx\u002F` exporter\u002Fmodel implementation, `modnet\u002Ftest_onnx.py`,\n`modnet\u002Fonnx_to_tensorrt.py`, `trt_modnet.py`, `test_modnet.py`, and the\nMODNet runtime helpers `utils\u002Fmodnet.py`, `utils\u002Fbackground.py`,\n`utils\u002Fwriter.py`, `utils\u002Fcamera.py`, and `utils\u002Fdisplay.py`. Repository-level\nMODNet instructions and compatibility claims were cross-checked against the\nMODNet section of `README.md`. The generated skill intentionally excludes the\nuninitialized `modnet\u002Fonnx-tensorrt` source and all model\u002Fengine binaries.\n",{"name":5,"license":14,"metadata":23,"description":7,"disable-model-invocation":25},{"disco-role":24},"operating",true,"main","ac3fe1afa80fb9a09775ecfb2b6cc3ba850a2db6","skills\u002Frepositories\u002Frepo-skills\u002Ftensorrt-demos\u002Fsub-skills\u002Fmatting-inference",27,"https:\u002F\u002Fgithub.com\u002FVectorSpaceLab\u002FAREX-Skill","https:\u002F\u002Fgithub.com\u002FVectorSpaceLab","2026-09-03 10:25:21",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":25},[35,38,41],{"tool":36,"command":37},"npx","npx skills add VectorSpaceLab\u002FAREX-Skill --skill matting-inference",{"tool":39,"command":40},"bunx","bunx skills add VectorSpaceLab\u002FAREX-Skill --skill matting-inference",{"tool":42,"command":43},"pnpm","pnpm dlx skills add VectorSpaceLab\u002FAREX-Skill --skill matting-inference","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FVectorSpaceLab\u002FAREX-Skill\u002Fblob\u002Fmain\u002Fskills\u002Frepositories\u002Frepo-skills\u002Ftensorrt-demos\u002Fsub-skills\u002Fmatting-inference\u002FSKILL.md",[46,52,56,62],{"path":47,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":50,"sourceHtmlUrl":51},"api-reference.md","REFERENCE","参考文档",8360,"https:\u002F\u002Fgithub.com\u002FVectorSpaceLab\u002FAREX-Skill\u002Fblob\u002Fmain\u002Fskills\u002Frepositories\u002Frepo-skills\u002Ftensorrt-demos\u002Fsub-skills\u002Fmatting-inference\u002Fapi-reference.md",{"path":53,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":54,"sourceHtmlUrl":55},"references\u002Fworkflows.md",12774,"https:\u002F\u002Fgithub.com\u002FVectorSpaceLab\u002FAREX-Skill\u002Fblob\u002Fmain\u002Fskills\u002Frepositories\u002Frepo-skills\u002Ftensorrt-demos\u002Fsub-skills\u002Fmatting-inference\u002Freferences\u002Fworkflows.md",{"path":57,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":60,"sourceHtmlUrl":61},"scripts\u002Fvalidate-matting-config.py","SCRIPT","脚本",6865,"https:\u002F\u002Fgithub.com\u002FVectorSpaceLab\u002FAREX-Skill\u002Fblob\u002Fmain\u002Fskills\u002Frepositories\u002Frepo-skills\u002Ftensorrt-demos\u002Fsub-skills\u002Fmatting-inference\u002Fscripts\u002Fvalidate-matting-config.py",{"path":63,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":64,"sourceHtmlUrl":65},"troubleshooting.md",9402,"https:\u002F\u002Fgithub.com\u002FVectorSpaceLab\u002FAREX-Skill\u002Fblob\u002Fmain\u002Fskills\u002Frepositories\u002Frepo-skills\u002Ftensorrt-demos\u002Fsub-skills\u002Fmatting-inference\u002Ftroubleshooting.md",[67,75,82,89,96,103],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":71,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":18},"01M799NYSH1R3RVAHSM2D88Y84","passnet-triton-opt","Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block\u002Fgrid\u002Fwarp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.","Apache-2.0","https:\u002F\u002Fgithub.com\u002FVectorSpaceLab\u002FAREX-Skill\u002Fblob\u002Fmain\u002Fskills\u002Ftask-oriented\u002FPassNet\u002Fskills\u002Fpassnet-triton-opt\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":71,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":18},"01M799NS5APEC0N1FZ7XZVW6BN","passnet-solve","END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.","https:\u002F\u002Fgithub.com\u002FVectorSpaceLab\u002FAREX-Skill\u002Fblob\u002Fmain\u002Fskills\u002Ftask-oriented\u002FPassNet\u002Fskills\u002Fpassnet-solve\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":71,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":18},"01M799NNY9BKSM21V5R7QVTBJX","passnet-skill","PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under .\u002Fpass_dir\u002F, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.","https:\u002F\u002Fgithub.com\u002FVectorSpaceLab\u002FAREX-Skill\u002Fblob\u002Fmain\u002Fskills\u002Ftask-oriented\u002FPassNet\u002Fskills\u002Fpassnet-skill\u002FSKILL.md",[],[],{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":71,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":18},"01M799NHH6NP7Z1RK77KGXAN6S","passnet-pattern-fusion","Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()\u002Freplacement_args()\u002Freplacement_func() files, when a pass \"failed to match\", or when deciding how to fuse multiple kernels\u002Fops.","https:\u002F\u002Fgithub.com\u002FVectorSpaceLab\u002FAREX-Skill\u002Fblob\u002Fmain\u002Fskills\u002Ftask-oriented\u002FPassNet\u002Fskills\u002Fpassnet-pattern-fusion\u002FSKILL.md",[],[],{"skillNo":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":71,"licenseFileUrl":6,"sourceHtmlUrl":100,"categories":101,"keywords":102,"publishedAt":18},"01M799ND2J4WNC2PGAZ0A06NDF","passnet-orchestrate","Round\u002Fbatch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep\u002Frevert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.","https:\u002F\u002Fgithub.com\u002FVectorSpaceLab\u002FAREX-Skill\u002Fblob\u002Fmain\u002Fskills\u002Ftask-oriented\u002FPassNet\u002Fskills\u002Fpassnet-orchestrate\u002FSKILL.md",[],[],{"skillNo":104,"name":105,"nameZh":6,"description":106,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":71,"licenseFileUrl":6,"sourceHtmlUrl":107,"categories":108,"keywords":109,"publishedAt":18},"01M799N8SBTMY02ZDG2AZF5ZWE","passnet-feedback","Fast, deterministic feedback for PassNet work: pre-flight pattern\u002Fmatch verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).","https:\u002F\u002Fgithub.com\u002FVectorSpaceLab\u002FAREX-Skill\u002Fblob\u002Fmain\u002Fskills\u002Ftask-oriented\u002FPassNet\u002Fskills\u002Fpassnet-feedback\u002FSKILL.md",[],[]]