Code Monkey home page Code Monkey logo

virtual-background's Introduction

Virtual Background

Background blur function using media-pipe's selfie-segmentation model. Based on volcomix/virtual-background.

Try it live here!

Performance

Here are the performance observed for the whole rendering pipelines, including inference and post-processing, when using the device camera on smartphone Pixel 3 (Chrome).

Model Input resolution Backend Pipeline FPS
Meet 256x144 WebAssembly Canvas 2D + CPU 14
Meet 256x144 WebAssembly WebGL 2 16
Meet 256x144 WebAssembly SIMD Canvas 2D + CPU 26
Meet 256x144 WebAssembly SIMD WebGL 2 31
Meet 160x96 WebAssembly Canvas 2D + CPU 29
Meet 160x96 WebAssembly WebGL 2 35
Meet 160x96 WebAssembly SIMD Canvas 2D + CPU 48
Meet 160x96 WebAssembly SIMD WebGL 2 60

Possible improvements

  • Rely on alpha channel to save texture fetches from the segmentation mask.
  • Blur the background image outside of the rendering loop and use it for light wrapping instead of the original background image. This should produce better rendering results for large light wrapping masks.
  • Optimize joint bilateral filter shader to prevent unnecessary variables, calculations and costly functions like exp.
  • Try separable approximation for joint bilateral filter.
  • Compute everything on lower source resolution (scaling down at the beginning of the pipeline).
  • Build TFLite and XNNPACK with multithreading support. Few configuration examples are in TensorFlow.js WASM backend.
  • Detect WASM features to load automatically the right TFLite WASM runtime. Inspirations could be taken from TensorFlow.js WASM backend which is based on GoogleChromeLabs/wasm-feature-detect.
  • Experiment with DeepLabv3+ and maybe retrain MobileNetv3-small model directly.

Related work

You can learn more about a pre-trained TensorFlow.js model in the BodyPix repository.

Here is a technical overview of background features in Google Meet which relies on:

Running locally

In the project directory, you can run:

yarn start

Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits.
You will also see any lint errors in the console.

yarn test

Launches the test runner in the interactive watch mode.
See the section about running tests for more information.

yarn build

Builds the app for production to the build folder.
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.
Your app is ready to be deployed!

See the section about deployment for more information.

Building TensorFlow Lite tool

Docker is required to build TensorFlow Lite inference tool locally.

yarn build:tflite

Builds WASM functions that can infer Meet and ML Kit segmentation models. The TFLite tool is built both with and without SIMD support.

virtual-background's People

Contributors

volcomix avatar jpodwys avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.