huggingface / transformers.js

State-of-the-art Machine Learning for the web. Run 🤗 Transformers directly in your browser, with no need for a server!
https://huggingface.co/docs/transformers.js
Apache License 2.0
11.63k stars 716 forks source link

Chrome on Android crashes when starting Whisper #740

Open flatsiedatsie opened 5 months ago

flatsiedatsie commented 5 months ago

System Info

While it runs fine on desktop, it crashes on mobile.

Pixel 6A Android 14 (6gb ram)

Using Transformers.js V2 (the website is a mix of V2 and V3, but with this test no V3 things (e.g. musicgen) have loaded, running Whisper in a webworker.

The webworker is based on the AutomaticSpeechRecognitionPipelineFactory example.

The model being loaded is Xenova/whisper-base.en. Right before the crash I see the serviceworker confirm that it was downloaded and caching it.

Environment/Platform

Description

Chrome on Android crashed with an "Aw snap" screen. This happens consistently every time.

I managed to connect remote debugging and saw this:

Screenshot 2024-05-07 at 11 01 03

Some code from the worker:

let data = transcriber.tokenizer._decode_asr(chunks_to_process, {
    time_precision: time_precision,
    return_timestamps: true,
    force_full_sequences: false,
});

and

output = await transcriber(audio, {
     // Greedy
      top_k: 0,
     do_sample: false,

     / Sliding window
     chunk_length_s: isDistilWhisper ? 20 : 30,
     stride_length_s: isDistilWhisper ? 3 : 5,

     // Language and task
     language: language,
     task: subtask,

     // Return timestamps
     return_timestamps: true,
     orce_full_sequences: false,

     // Callback functions
     callback_function: callback_function, // after each generation step
     chunk_callback: chunk_callback, // after each chunk is processed
})

Reproduction

I will email you a link so you can try it yourself.

I will also try to create a lower resource version and see if I can find out more.

flatsiedatsie commented 5 months ago

I tested the official whisper example with the same settings, and get the same result. It must be a memory issue, as running the example on the phone withtiny and quant enabled does work.

flatsiedatsie commented 5 months ago

Hmm, still getting errors, even when using tiny+quantization:

whisper_tjs
flatsiedatsie commented 5 months ago

Funny, when searching for the error code the first result is for Transformers.js, and whisper.

https://github.com/xenova/transformers.js/issues/54