add transformers js options
Browse files
app.py
CHANGED
|
@@ -329,6 +329,12 @@ Library import (required): Add the following snippet to index.html to import tra
|
|
| 329 |
import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.7.2';
|
| 330 |
</script>
|
| 331 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 332 |
The index.html should contain the basic HTML structure and link to the CSS and JS files.
|
| 333 |
The index.js should contain all the JavaScript logic including transformers.js integration.
|
| 334 |
The style.css should contain all the styling for the application.
|
|
@@ -464,6 +470,12 @@ Library import (required): Add the following snippet to index.html to import tra
|
|
| 464 |
import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.7.2';
|
| 465 |
</script>
|
| 466 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 467 |
The index.html should contain the basic HTML structure and link to the CSS and JS files.
|
| 468 |
The index.js should contain all the JavaScript logic including transformers.js integration.
|
| 469 |
The style.css should contain all the styling for the application.
|
|
|
|
| 329 |
import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.7.2';
|
| 330 |
</script>
|
| 331 |
|
| 332 |
+
Device Options: By default, transformers.js runs on CPU (via WASM). For better performance, you can run models on GPU using WebGPU:
|
| 333 |
+
- CPU (default): const pipe = await pipeline('task', 'model-name');
|
| 334 |
+
- GPU (WebGPU): const pipe = await pipeline('task', 'model-name', { device: 'webgpu' });
|
| 335 |
+
|
| 336 |
+
Consider providing users with a toggle option to choose between CPU and GPU execution based on their browser's WebGPU support.
|
| 337 |
+
|
| 338 |
The index.html should contain the basic HTML structure and link to the CSS and JS files.
|
| 339 |
The index.js should contain all the JavaScript logic including transformers.js integration.
|
| 340 |
The style.css should contain all the styling for the application.
|
|
|
|
| 470 |
import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.7.2';
|
| 471 |
</script>
|
| 472 |
|
| 473 |
+
Device Options: By default, transformers.js runs on CPU (via WASM). For better performance, you can run models on GPU using WebGPU:
|
| 474 |
+
- CPU (default): const pipe = await pipeline('task', 'model-name');
|
| 475 |
+
- GPU (WebGPU): const pipe = await pipeline('task', 'model-name', { device: 'webgpu' });
|
| 476 |
+
|
| 477 |
+
Consider providing users with a toggle option to choose between CPU and GPU execution based on their browser's WebGPU support.
|
| 478 |
+
|
| 479 |
The index.html should contain the basic HTML structure and link to the CSS and JS files.
|
| 480 |
The index.js should contain all the JavaScript logic including transformers.js integration.
|
| 481 |
The style.css should contain all the styling for the application.
|