RecapAnon commited on
Commit
e4af149
·
1 Parent(s): debe7aa

Load model and processor in parallel and fix progress_callback glitching.

Browse files
Files changed (1) hide show
  1. index.js +9 -12
index.js CHANGED
@@ -23,20 +23,17 @@ class TextGenerationPipeline {
23
  model_id = "onnx-community/gemma-4-E2B-it-ONNX",
24
  ) {
25
  if (this.processor && this.model) {
26
- return [this.processor, this.model];
27
  }
28
 
29
- this.processor = await AutoProcessor.from_pretrained(model_id, {
30
- progress_callback,
31
- });
32
-
33
- this.model = await Gemma4ForConditionalGeneration.from_pretrained(model_id, {
34
- dtype: "q4f16",
35
- device: "webgpu",
36
- progress_callback,
37
- });
38
-
39
- return [this.processor, this.model];
40
  }
41
  }
42
 
 
23
  model_id = "onnx-community/gemma-4-E2B-it-ONNX",
24
  ) {
25
  if (this.processor && this.model) {
26
+ return;
27
  }
28
 
29
+ [this.model, this.processor] = await Promise.all([
30
+ Gemma4ForConditionalGeneration.from_pretrained(model_id, {
31
+ dtype: "q4f16",
32
+ device: "webgpu",
33
+ progress_callback,
34
+ }),
35
+ AutoProcessor.from_pretrained(model_id),
36
+ ]);
 
 
 
37
  }
38
  }
39