Skip to content

Commit

Permalink
upgrage to transformers v3alpha17 which fixes chromium 129+ modnet crash
Browse files Browse the repository at this point in the history
  • Loading branch information
eyaler committed Sep 27, 2024
1 parent 8906e00 commit 5e20a75
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ WebGPU ([TensorFlow.js](https://www.tensorflow.org/js), [ONNX Runtime Web](https
WebGL ([Three.js](https://threejs.org/), [SwissGL](https://google.github.io/swissgl/)), and VanillaJS.

Known issues:
1. Modnet crashes using Transformers.js v3-alpha on Chromium 129+: https://github.com/xenova/transformers.js/issues/943, https://issues.chromium.org/issues/368997517 (currently reverted to v2 with a significant slowdown)
2. Resolution of captured media is doubled for smaller frames: https://github.com/screen-share/element-capture/issues/44
1. Resolution of captured media is doubled for smaller frames: https://github.com/screen-share/element-capture/issues/44

<br>

Expand Down
6 changes: 2 additions & 4 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ import {
} from 'https://cdn.jsdelivr.net/npm/@mediapipe/[email protected]/vision_bundle.mjs'
const mediapipe_wasm_url = 'https://cdn.jsdelivr.net/npm/@mediapipe/[email protected]/wasm'

import {AutoModel, AutoProcessor, RawImage, env as transformersEnv} from 'https://cdn.jsdelivr.net/npm/@xenova/[email protected]/dist/transformers.min.js'
// import {AutoModel, AutoProcessor, RawImage, env as transformersEnv} from 'https://cdn.jsdelivr.net/npm/@huggingface/[email protected]/dist/transformers.min.js'
// Note modnet on transformers v3 is 10x faster on chromium 128 but crashed on 129+. See: https://github.com/xenova/transformers.js/issues/943, https://issues.chromium.org/issues/368997517
import {AutoModel, AutoProcessor, RawImage, env as transformersEnv} from 'https://cdn.jsdelivr.net/npm/@huggingface/[email protected]/dist/transformers.min.js'

import 'https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js'
import 'https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf-backend-webgpu.min.js'
Expand Down Expand Up @@ -100,7 +98,7 @@ document.addEventListener('keydown', e => {
function loop_effects() {
if (!loop_mode || !capture_started)
return
const effects = [...effect.querySelectorAll('option:not([disabled]):not([label="meta" i] > *)')].filter(e => !transformersEnv.version.startsWith('2.') || !e.value.includes('transformers')).map(e => e.value)
const effects = [...effect.querySelectorAll('option:not([disabled]):not([label="meta" i] > *)')].map(e => e.value)
effect.value = effects[(effects.indexOf(effect.value)+(loop_mode == 'random' ? Math.random()*(effects.length-1) + 1 | 0 : 1)) % effects.length]
setTimeout(loop_effects, loop_secs * 1000)
}
Expand Down

0 comments on commit 5e20a75

Please sign in to comment.