-
-
Notifications
You must be signed in to change notification settings - Fork 27
docs: Binary image segmentation example #1795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
pkg.pr.new packages benchmark commit |
…mentation-example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the camera-thresholding example to use unstable APIs and introduces a new background-segmentation example that uses ONNX Runtime with a UNet2P model for binary image segmentation.
Key changes:
- Refactored camera-thresholding to use chroma key-based color filtering instead of simple greyscale thresholding
- Added background-segmentation example with ONNX model integration, camera feed blurring, and mask-based pixel selection
- Enhanced texture utilities to support video element dimensions
Reviewed Changes
Copilot reviewed 12 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/typegpu/tests/examples/individual/camera-thresholding.test.ts | Updated snapshot to reflect new shader implementation using chroma key filtering |
| packages/typegpu/src/core/texture/textureUtils.ts | Added support for video element dimensions (videoWidth/videoHeight) |
| apps/typegpu-docs/src/examples/image-processing/camera-thresholding/meta.json | Added "experimental" tag to indicate unstable API usage |
| apps/typegpu-docs/src/examples/image-processing/camera-thresholding/index.ts | Converted from WGSL template strings to unstable API, implemented chroma key filtering |
| apps/typegpu-docs/src/examples/image-processing/background-segmentation/shaders.ts | GPU shader implementations for model input preparation, mask generation, blur computation, and masked rendering |
| apps/typegpu-docs/src/examples/image-processing/background-segmentation/schemas.ts | Bind group layouts and constants for background segmentation pipeline |
| apps/typegpu-docs/src/examples/image-processing/background-segmentation/model.ts | ONNX Runtime session preparation for UNet2P model inference |
| apps/typegpu-docs/src/examples/image-processing/background-segmentation/meta.json | Metadata for new background segmentation example |
| apps/typegpu-docs/src/examples/image-processing/background-segmentation/index.ts | Main implementation coordinating camera feed, ONNX inference, blurring, and rendering |
| apps/typegpu-docs/src/examples/image-processing/background-segmentation/index.html | HTML structure and styling for background segmentation example |
| apps/typegpu-docs/package.json | Added onnxruntime-web and lodash dependencies |
| apps/typegpu-docs/astro.config.mjs | Configured build to exclude onnxruntime-web from optimization and bundling |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
apps/typegpu-docs/src/examples/image-processing/background-segmentation/index.ts
Outdated
Show resolved
Hide resolved
apps/typegpu-docs/src/examples/image-processing/background-segmentation/index.ts
Outdated
Show resolved
Hide resolved
apps/typegpu-docs/src/examples/image-processing/background-segmentation/shaders.ts
Show resolved
Hide resolved
…mentation-example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 12 out of 15 changed files in this pull request and generated no new comments.
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 12 out of 15 changed files in this pull request and generated 3 comments.
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Changes:
camera-tresholdingto unstable API (the file looked almost 1:1 likechroma-keyingso I guess why not differentiate it a bit),background-segmentationexample, which uses ONNX runtime with unet2p model. It copies the camera fee, blurs it and selects either blurred or unblurred pixels based on the mask generated by the model.ONNX has some issues with providing it with a device (microsoft/onnxruntime#26107). I monkey-patched some requests, and I clean this up in
cleanUp.ONNX with WebGPU does not yet work on Safari (microsoft/onnxruntime#26480), so I just throw an error.
On my phone, it works in ~1fps and is unusable, but on one of the shared devices I borrowed (Samsung Galaxy X Fold 5) it worked perfectly fine.