RecapAnon commited on
Commit ·
e4af149
1
Parent(s): debe7aa
Load model and processor in parallel and fix progress_callback glitching.
Browse files
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
|
| 27 |
}
|
| 28 |
|
| 29 |
-
this.processor = await
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 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 |
|