mirror of
https://github.com/suitenumerique/meet.git
synced 2026-08-26 02:06:53 +00:00
♻️(frontend) inline MediaPipe WASM modules to avoid loading from remote
Copy the MediaPipe WASM modules into the frontend build output and serve them locally, instead of loading them from the Google CDN at runtime. Mediapipe was a transitive dependency, add it explicitly. Requested by some members of the community. It closes #1168
This commit is contained in:
committed by
aleb_the_flash
parent
8118ef0612
commit
581e115c03
@@ -22,6 +22,7 @@ and this project adheres to
|
|||||||
- 🚸(frontend) initialize the join input name with the persisted full name
|
- 🚸(frontend) initialize the join input name with the persisted full name
|
||||||
- ♻️(frontend) refactor background processors to use the new API
|
- ♻️(frontend) refactor background processors to use the new API
|
||||||
- ♻️(frontend) inline model weights to avoid loading them from remote
|
- ♻️(frontend) inline model weights to avoid loading them from remote
|
||||||
|
- ♻️(frontend) inline MediaPipe WASM modules to avoid loading from remote
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|||||||
Generated
+1
@@ -15,6 +15,7 @@
|
|||||||
"@livekit/components-react": "2.9.21",
|
"@livekit/components-react": "2.9.21",
|
||||||
"@livekit/components-styles": "1.2.0",
|
"@livekit/components-styles": "1.2.0",
|
||||||
"@livekit/track-processors": "0.7.2",
|
"@livekit/track-processors": "0.7.2",
|
||||||
|
"@mediapipe/tasks-vision": "0.10.14",
|
||||||
"@pandacss/preset-panda": "1.11.3",
|
"@pandacss/preset-panda": "1.11.3",
|
||||||
"@react-types/overlays": "3.10.0",
|
"@react-types/overlays": "3.10.0",
|
||||||
"@remixicon/react": "4.9.0",
|
"@remixicon/react": "4.9.0",
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
"@livekit/components-react": "2.9.21",
|
"@livekit/components-react": "2.9.21",
|
||||||
"@livekit/components-styles": "1.2.0",
|
"@livekit/components-styles": "1.2.0",
|
||||||
"@livekit/track-processors": "0.7.2",
|
"@livekit/track-processors": "0.7.2",
|
||||||
|
"@mediapipe/tasks-vision": "0.10.14",
|
||||||
"@pandacss/preset-panda": "1.11.3",
|
"@pandacss/preset-panda": "1.11.3",
|
||||||
"@react-types/overlays": "3.10.0",
|
"@react-types/overlays": "3.10.0",
|
||||||
"@remixicon/react": "4.9.0",
|
"@remixicon/react": "4.9.0",
|
||||||
|
|||||||
+2
-3
@@ -16,6 +16,7 @@ import {
|
|||||||
SELFIE_SEGMENTER_MODEL_PATH,
|
SELFIE_SEGMENTER_MODEL_PATH,
|
||||||
type ProcessorConfig,
|
type ProcessorConfig,
|
||||||
type ProcessorType,
|
type ProcessorType,
|
||||||
|
MEDIAPIPE_PATH_WASM,
|
||||||
} from '.'
|
} from '.'
|
||||||
|
|
||||||
const PROCESSING_WIDTH = 256
|
const PROCESSING_WIDTH = 256
|
||||||
@@ -154,9 +155,7 @@ export class BackgroundCustomProcessor implements BackgroundProcessorInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async initSegmenter() {
|
async initSegmenter() {
|
||||||
const vision = await FilesetResolver.forVisionTasks(
|
const vision = await FilesetResolver.forVisionTasks(MEDIAPIPE_PATH_WASM)
|
||||||
'https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision/wasm'
|
|
||||||
)
|
|
||||||
this.imageSegmenter = await ImageSegmenter.createFromOptions(vision, {
|
this.imageSegmenter = await ImageSegmenter.createFromOptions(vision, {
|
||||||
baseOptions: {
|
baseOptions: {
|
||||||
modelAssetPath: SELFIE_SEGMENTER_MODEL_PATH,
|
modelAssetPath: SELFIE_SEGMENTER_MODEL_PATH,
|
||||||
|
|||||||
@@ -11,7 +11,11 @@ import {
|
|||||||
TIMEOUT_TICK,
|
TIMEOUT_TICK,
|
||||||
timerWorkerScript,
|
timerWorkerScript,
|
||||||
} from './TimerWorker'
|
} from './TimerWorker'
|
||||||
import { FACE_LANDMARKS_MODEL_PATH, ProcessorType } from '.'
|
import {
|
||||||
|
FACE_LANDMARKS_MODEL_PATH,
|
||||||
|
ProcessorType,
|
||||||
|
MEDIAPIPE_PATH_WASM,
|
||||||
|
} from '.'
|
||||||
|
|
||||||
const PROCESSING_WIDTH = 256 * 3
|
const PROCESSING_WIDTH = 256 * 3
|
||||||
const PROCESSING_HEIGHT = 144 * 3
|
const PROCESSING_HEIGHT = 144 * 3
|
||||||
@@ -128,9 +132,7 @@ export class FaceLandmarksProcessor implements TrackProcessor<Track.Kind> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async initFaceLandmarker() {
|
async initFaceLandmarker() {
|
||||||
const vision = await FilesetResolver.forVisionTasks(
|
const vision = await FilesetResolver.forVisionTasks(MEDIAPIPE_PATH_WASM)
|
||||||
'https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision/wasm'
|
|
||||||
)
|
|
||||||
this.faceLandmarker = await FaceLandmarker.createFromOptions(vision, {
|
this.faceLandmarker = await FaceLandmarker.createFromOptions(vision, {
|
||||||
baseOptions: {
|
baseOptions: {
|
||||||
modelAssetPath: FACE_LANDMARKS_MODEL_PATH,
|
modelAssetPath: FACE_LANDMARKS_MODEL_PATH,
|
||||||
|
|||||||
+3
@@ -7,6 +7,7 @@ import {
|
|||||||
type ProcessorConfig,
|
type ProcessorConfig,
|
||||||
BackgroundProcessorInterface,
|
BackgroundProcessorInterface,
|
||||||
ProcessorType,
|
ProcessorType,
|
||||||
|
MEDIAPIPE_PATH_WASM,
|
||||||
SELFIE_SEGMENTER_MODEL_PATH,
|
SELFIE_SEGMENTER_MODEL_PATH,
|
||||||
} from '.'
|
} from '.'
|
||||||
|
|
||||||
@@ -24,6 +25,7 @@ export class UnifiedBackgroundTrackProcessor implements BackgroundProcessorInter
|
|||||||
mode: 'virtual-background',
|
mode: 'virtual-background',
|
||||||
imagePath: opts.imagePath,
|
imagePath: opts.imagePath,
|
||||||
assetPaths: {
|
assetPaths: {
|
||||||
|
tasksVisionFileSet: MEDIAPIPE_PATH_WASM,
|
||||||
modelAssetPath: SELFIE_SEGMENTER_MODEL_PATH,
|
modelAssetPath: SELFIE_SEGMENTER_MODEL_PATH,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -33,6 +35,7 @@ export class UnifiedBackgroundTrackProcessor implements BackgroundProcessorInter
|
|||||||
mode: 'background-blur',
|
mode: 'background-blur',
|
||||||
blurRadius: opts.blurRadius,
|
blurRadius: opts.blurRadius,
|
||||||
assetPaths: {
|
assetPaths: {
|
||||||
|
tasksVisionFileSet: MEDIAPIPE_PATH_WASM,
|
||||||
modelAssetPath: SELFIE_SEGMENTER_MODEL_PATH,
|
modelAssetPath: SELFIE_SEGMENTER_MODEL_PATH,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ export const SELFIE_SEGMENTER_MODEL_PATH =
|
|||||||
export const FACE_LANDMARKS_MODEL_PATH =
|
export const FACE_LANDMARKS_MODEL_PATH =
|
||||||
'/assets/mediapipe/models/face_landmarker.task'
|
'/assets/mediapipe/models/face_landmarker.task'
|
||||||
|
|
||||||
|
export const MEDIAPIPE_PATH_WASM = '/assets/mediapipe/wasm'
|
||||||
|
|
||||||
export enum ProcessorType {
|
export enum ProcessorType {
|
||||||
BLUR = 'blur',
|
BLUR = 'blur',
|
||||||
VIRTUAL = 'virtual',
|
VIRTUAL = 'virtual',
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { defineConfig, loadEnv } from 'vite'
|
|||||||
import react from '@vitejs/plugin-react'
|
import react from '@vitejs/plugin-react'
|
||||||
import { visualizer } from 'rollup-plugin-visualizer'
|
import { visualizer } from 'rollup-plugin-visualizer'
|
||||||
import svgr from 'vite-plugin-svgr'
|
import svgr from 'vite-plugin-svgr'
|
||||||
|
import { viteStaticCopy } from 'vite-plugin-static-copy'
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig(({ mode }) => {
|
export default defineConfig(({ mode }) => {
|
||||||
@@ -18,6 +19,15 @@ export default defineConfig(({ mode }) => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
viteStaticCopy({
|
||||||
|
targets: [
|
||||||
|
{
|
||||||
|
src: 'node_modules/@mediapipe/tasks-vision/wasm/*',
|
||||||
|
dest: 'assets/mediapipe/wasm',
|
||||||
|
rename: { stripBase: 4 },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
env.VITE_ANALYZE === 'true' &&
|
env.VITE_ANALYZE === 'true' &&
|
||||||
visualizer({
|
visualizer({
|
||||||
open: true,
|
open: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user