|
1 |
| -export default async function downsampleLoadSampleInputs (model, preRun=false) { |
2 |
| - const downsampleButton = document.querySelector('#downsampleLabelImageInputs sl-button[name=input-file-button]') |
| 1 | +export default async function downsampleLoadSampleInputs( |
| 2 | + model, |
| 3 | + preRun = false, |
| 4 | +) { |
| 5 | + const downsampleButton = document.querySelector( |
| 6 | + "#downsampleLabelImageInputs sl-button[name=input-file-button]", |
| 7 | + ); |
3 | 8 | if (!preRun) {
|
4 |
| - downsampleButton.loading = true |
| 9 | + downsampleButton.loading = true; |
5 | 10 | }
|
6 | 11 |
|
7 |
| - const fileName = "2th_cthead1.png" |
8 |
| - const response = await fetch(`https://bafybeih4fck4ndvsvgo6774xy5w7ip3bzcvh7x7e527m4yvazgrxdzayua.ipfs.w3s.link/ipfs/bafybeih4fck4ndvsvgo6774xy5w7ip3bzcvh7x7e527m4yvazgrxdzayua/input/${fileName}`) |
9 |
| - const data = new Uint8Array(await response.arrayBuffer()) |
10 |
| - const inputFile = { data, path: fileName } |
11 |
| - const { image } = await globalThis.readImage(inputFile) |
| 12 | + const fileName = "2th_cthead1.png"; |
| 13 | + const response = await fetch( |
| 14 | + `https://bafybeih4fck4ndvsvgo6774xy5w7ip3bzcvh7x7e527m4yvazgrxdzayua.ipfs.w3s.link/ipfs/bafybeih4fck4ndvsvgo6774xy5w7ip3bzcvh7x7e527m4yvazgrxdzayua/input/${fileName}`, |
| 15 | + ); |
| 16 | + const data = new Uint8Array(await response.arrayBuffer()); |
| 17 | + const inputFile = { data, path: fileName }; |
| 18 | + const { image } = await globalThis.readImage(inputFile); |
12 | 19 |
|
13 |
| - model.inputs.set('input', image) |
14 |
| - model.options.set('shrinkFactors', [2, 2]) |
| 20 | + model.inputs.set("input", image); |
| 21 | + model.options.set("shrinkFactors", [2, 2]); |
15 | 22 |
|
16 | 23 | if (!preRun) {
|
17 |
| - const downsampleElement = document.getElementById('downsampleLabelImage-input-details') |
18 |
| - downsampleElement.innerHTML = `<pre>${globalThis.escapeHtml(inputFile.path)}</pre>` |
19 |
| - downsampleElement.disabled = false |
| 24 | + const downsampleElement = document.getElementById( |
| 25 | + "downsampleLabelImage-input-details", |
| 26 | + ); |
| 27 | + downsampleElement.setImage(image); |
| 28 | + downsampleElement.disabled = false; |
20 | 29 |
|
21 |
| - const shrinkFactorsElement = document.querySelector('#downsampleLabelImageInputs sl-input[name=shrink-factors]') |
22 |
| - shrinkFactorsElement.value = JSON.stringify(model.options.get('shrinkFactors')) |
| 30 | + const shrinkFactorsElement = document.querySelector( |
| 31 | + "#downsampleLabelImageInputs sl-input[name=shrink-factors]", |
| 32 | + ); |
| 33 | + shrinkFactorsElement.value = JSON.stringify( |
| 34 | + model.options.get("shrinkFactors"), |
| 35 | + ); |
23 | 36 |
|
24 |
| - downsampleButton.loading = false |
| 37 | + downsampleButton.loading = false; |
25 | 38 | }
|
26 | 39 |
|
27 |
| - return model |
| 40 | + return model; |
28 | 41 | }
|
29 | 42 |
|
30 | 43 | // Use this function to run the pipeline when this tab group is select.
|
31 | 44 | // This will load the web worker if it is not already loaded, download the wasm module, and allocate memory in the wasm model.
|
32 | 45 | // Set this to `false` if sample inputs are very large or sample pipeline computation is long.
|
33 |
| -export const usePreRun = true |
| 46 | +export const usePreRun = true; |
0 commit comments