Update transformers library to latest version across all worker scripts and force fallback to WASM
Browse files
public/workers/feature-extraction.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
/* eslint-disable no-restricted-globals */
|
2 |
-
import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@
|
3 |
|
4 |
class MyFeatureExtractionPipeline {
|
5 |
static task = 'feature-extraction'
|
@@ -8,12 +8,14 @@ class MyFeatureExtractionPipeline {
|
|
8 |
static async getInstance(model, dtype = 'fp32', progress_callback = null) {
|
9 |
try {
|
10 |
// Try WebGPU first
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
17 |
} catch (webgpuError) {
|
18 |
// Fallback to WASM if WebGPU fails
|
19 |
if (progress_callback) {
|
|
|
1 |
/* eslint-disable no-restricted-globals */
|
2 |
+
import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@latest'
|
3 |
|
4 |
class MyFeatureExtractionPipeline {
|
5 |
static task = 'feature-extraction'
|
|
|
8 |
static async getInstance(model, dtype = 'fp32', progress_callback = null) {
|
9 |
try {
|
10 |
// Try WebGPU first
|
11 |
+
throw Error('onnxruntime-web failed for feature-extraction with transformers 3.7.1')
|
12 |
+
|
13 |
+
// this.instance = await pipeline(this.task, model, {
|
14 |
+
// dtype,
|
15 |
+
// device: 'webgpu',
|
16 |
+
// progress_callback,
|
17 |
+
// })
|
18 |
+
// return this.instance
|
19 |
} catch (webgpuError) {
|
20 |
// Fallback to WASM if WebGPU fails
|
21 |
if (progress_callback) {
|
public/workers/image-classification.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
/* eslint-disable no-restricted-globals */
|
2 |
-
import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@
|
3 |
|
4 |
class MyImageClassificationPipeline {
|
5 |
static task = 'image-classification'
|
@@ -19,11 +19,13 @@ class MyImageClassificationPipeline {
|
|
19 |
if (!this.instance) {
|
20 |
try {
|
21 |
// Try WebGPU first
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
27 |
} catch (webgpuError) {
|
28 |
// Fallback to WASM if WebGPU fails
|
29 |
if (progress_callback) {
|
|
|
1 |
/* eslint-disable no-restricted-globals */
|
2 |
+
import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@latest'
|
3 |
|
4 |
class MyImageClassificationPipeline {
|
5 |
static task = 'image-classification'
|
|
|
19 |
if (!this.instance) {
|
20 |
try {
|
21 |
// Try WebGPU first
|
22 |
+
throw Error('onnxruntime-web failed for image-classification with transformers 3.7.1')
|
23 |
+
|
24 |
+
// this.instance = await pipeline(this.task, model, {
|
25 |
+
// dtype,
|
26 |
+
// device: 'webgpu',
|
27 |
+
// progress_callback
|
28 |
+
// })
|
29 |
} catch (webgpuError) {
|
30 |
// Fallback to WASM if WebGPU fails
|
31 |
if (progress_callback) {
|
public/workers/text-classification.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
/* eslint-disable no-restricted-globals */
|
2 |
-
import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@
|
3 |
|
4 |
class MyTextClassificationPipeline {
|
5 |
static task = 'text-classification'
|
|
|
1 |
/* eslint-disable no-restricted-globals */
|
2 |
+
import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@latest'
|
3 |
|
4 |
class MyTextClassificationPipeline {
|
5 |
static task = 'text-classification'
|
public/workers/text-generation.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
/* eslint-disable no-restricted-globals */
|
2 |
-
import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@
|
3 |
|
4 |
class MyTextGenerationPipeline {
|
5 |
static task = 'text-generation'
|
|
|
1 |
/* eslint-disable no-restricted-globals */
|
2 |
+
import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@latest'
|
3 |
|
4 |
class MyTextGenerationPipeline {
|
5 |
static task = 'text-generation'
|
public/workers/zero-shot-classification.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
/* eslint-disable no-restricted-globals */
|
2 |
-
import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@
|
3 |
|
4 |
class MyZeroShotClassificationPipeline {
|
5 |
static task = 'zero-shot-classification'
|
|
|
1 |
/* eslint-disable no-restricted-globals */
|
2 |
+
import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@latest'
|
3 |
|
4 |
class MyZeroShotClassificationPipeline {
|
5 |
static task = 'zero-shot-classification'
|