Skip to content

Conversation

@aleksanderkatan
Copy link
Contributor

@aleksanderkatan aleksanderkatan commented Oct 8, 2025

Changes:

  • update camera-tresholding to unstable API (the file looked almost 1:1 like chroma-keying so I guess why not differentiate it a bit),
  • add background-segmentation example, 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.

@aleksanderkatan aleksanderkatan linked an issue Oct 8, 2025 that may be closed by this pull request
@github-actions
Copy link

github-actions bot commented Oct 8, 2025

pkg.pr.new

packages
Ready to be installed by your favorite package manager ⬇️

https://pkg.pr.new/software-mansion/TypeGPU/typegpu@652673b8caee3967ee097cfa19ca8bdc35dec9d1
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/noise@652673b8caee3967ee097cfa19ca8bdc35dec9d1
https://pkg.pr.new/software-mansion/TypeGPU/unplugin-typegpu@652673b8caee3967ee097cfa19ca8bdc35dec9d1

benchmark
view benchmark

commit
view commit

Copy link

Copilot AI left a 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.

Copy link

Copilot AI left a 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.

Copy link

Copilot AI left a 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.

@aleksanderkatan aleksanderkatan marked this pull request as ready for review November 3, 2025 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: Binary image segmentation example

2 participants