Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
Revert "Update Virtual Background Model (#9867)" (#10247)
Avram Tudorb4ba887d9289
diff --git a/react/features/stream-effects/virtual-background/JitsiStreamBackgroundEffect.js b/react/features/stream-effects/virtual-background/JitsiStreamBackgroundEffect.jsindex bbced2be34..64f14650a0 100644--- a/react/features/stream-effects/virtual-background/JitsiStreamBackgroundEffect.js+++ b/react/features/stream-effects/virtual-background/JitsiStreamBackgroundEffect.js@@ -166,10 +166,14 @@ export default class JitsiStreamBackgroundEffect {const outputMemoryOffset = this._model._getOutputMemoryOffset() / 4;for (let i = 0; i < this._segmentationPixelCount; i++) {- const person = this._model.HEAPF32[outputMemoryOffset + i];-+ const background = this._model.HEAPF32[outputMemoryOffset + (i * 2)];+ const person = this._model.HEAPF32[outputMemoryOffset + (i * 2) + 1];+ const shift = Math.max(background, person);+ const backgroundExp = Math.exp(background - shift);+ const personExp = Math.exp(person - shift);+// Sets only the alpha component of each pixel.- this._segmentationMask.data[(i * 4) + 3] = (255 * person);+ this._segmentationMask.data[(i * 4) + 3] = (255 * personExp) / (backgroundExp + personExp);}this._segmentationMaskCtx.putImageData(this._segmentationMask, 0, 0);}diff --git a/react/features/stream-effects/virtual-background/index.js b/react/features/stream-effects/virtual-background/index.jsindex 98429d12f7..fe754dfcb4 100644--- a/react/features/stream-effects/virtual-background/index.js+++ b/react/features/stream-effects/virtual-background/index.js@@ -8,8 +8,8 @@ import JitsiStreamBackgroundEffect from './JitsiStreamBackgroundEffect';import createTFLiteModule from './vendor/tflite/tflite';import createTFLiteSIMDModule from './vendor/tflite/tflite-simd';const models = {- model_landscape: 'libs/selfie_segmentation_landscape.tflite'-+ model96: 'libs/segm_lite_v681.tflite',+ model144: 'libs/segm_full_v679.tflite'};let tflite;@@ -17,7 +17,11 @@ let wasmCheck;let isWasmDisabled = false;const segmentationDimensions = {- model_landscape: {+ model96: {+ height: 96,+ width: 160+ },+ model144: {height: 144,width: 256}@@ -72,7 +76,7 @@ export async function createVirtualBackgroundEffect(virtualBackground: Object, d}const modelBufferOffset = tflite._getModelBufferMemoryOffset();- const modelResponse = await fetch(models.model_landscape);+ const modelResponse = await fetch(wasmCheck.feature.simd ? models.model144 : models.model96);if (!modelResponse.ok) {throw new Error('Failed to download tflite model!');@@ -85,12 +89,9 @@ export async function createVirtualBackgroundEffect(virtualBackground: Object, dtflite._loadModel(model.byteLength);const options = {- ...segmentationDimensions.model_landscape,+ ...wasmCheck.feature.simd ? segmentationDimensions.model144 : segmentationDimensions.model96,virtualBackground- };---+ };return new JitsiStreamBackgroundEffect(tflite, options);}diff --git a/react/features/stream-effects/virtual-background/vendor/models/segm_full_v679.tflite b/react/features/stream-effects/virtual-background/vendor/models/segm_full_v679.tflitenew file mode 100644index 0000000000..1f56ae7cd6Binary files /dev/null and b/react/features/stream-effects/virtual-background/vendor/models/segm_full_v679.tflite differdiff --git a/react/features/stream-effects/virtual-background/vendor/models/segm_lite_v681.tflite b/react/features/stream-effects/virtual-background/vendor/models/segm_lite_v681.tflitenew file mode 100644index 0000000000..593b591b6aBinary files /dev/null and b/react/features/stream-effects/virtual-background/vendor/models/segm_lite_v681.tflite differdiff --git a/react/features/stream-effects/virtual-background/vendor/models/selfie_segmentation.tflite b/react/features/stream-effects/virtual-background/vendor/models/selfie_segmentation.tflitedeleted file mode 100755index 374c0720da..0000000000Binary files a/react/features/stream-effects/virtual-background/vendor/models/selfie_segmentation.tflite and /dev/null differdiff --git a/react/features/stream-effects/virtual-background/vendor/models/selfie_segmentation_landscape.tflite b/react/features/stream-effects/virtual-background/vendor/models/selfie_segmentation_landscape.tflitedeleted file mode 100755index 4ea3f8a104..0000000000Binary files a/react/features/stream-effects/virtual-background/vendor/models/selfie_segmentation_landscape.tflite and /dev/null differ