Skip to content

Commit 0fb805e

Browse files
authored
Merge pull request #1216 from thewtex/demo-app-viewer-version
demo app viewer version
2 parents 0648e1a + 8707607 commit 0fb805e

File tree

5 files changed

+187
-133
lines changed

5 files changed

+187
-133
lines changed

packages/core/typescript/demo-app/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
"author": "",
2121
"license": "Apache-2.0",
2222
"dependencies": {
23-
"@itk-viewer/element": "^0.3.0",
24-
"@itk-viewer/io": "^0.1.8",
25-
"@shoelace-style/shoelace": "^2.12.0",
23+
"@itk-viewer/element": "^0.6.6",
24+
"@itk-viewer/io": "^0.4.3",
25+
"@shoelace-style/shoelace": "^2.16.0",
2626
"itk-wasm": "workspace:^",
27-
"lit": "^3.1.2"
27+
"lit": "^3.2.0"
2828
},
2929
"repository": {
3030
"type": "git",
Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,46 @@
1-
export default async function downsampleLoadSampleInputs (model, preRun=false) {
2-
const downsampleButton = document.querySelector('#downsampleBinShrinkInputs sl-button[name=input-file-button]')
1+
export default async function downsampleLoadSampleInputs(
2+
model,
3+
preRun = false,
4+
) {
5+
const downsampleButton = document.querySelector(
6+
"#downsampleBinShrinkInputs sl-button[name=input-file-button]",
7+
);
38
if (!preRun) {
4-
downsampleButton.loading = true
9+
downsampleButton.loading = true;
510
}
611

7-
const fileName = "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 = "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);
1219

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]);
1522

1623
if (!preRun) {
17-
const downsampleElement = document.getElementById('downsampleBinShrink-input-details')
18-
downsampleElement.innerHTML = `<pre>${globalThis.escapeHtml(inputFile.path)}</pre>`
19-
downsampleElement.disabled = false
24+
const downsampleElement = document.getElementById(
25+
"downsampleBinShrink-input-details",
26+
);
27+
downsampleElement.setImage(image);
28+
downsampleElement.disabled = false;
2029

21-
const shrinkFactorsElement = document.querySelector('#downsampleBinShrinkInputs sl-input[name=shrink-factors]')
22-
shrinkFactorsElement.value = JSON.stringify(model.options.get('shrinkFactors'))
30+
const shrinkFactorsElement = document.querySelector(
31+
"#downsampleBinShrinkInputs sl-input[name=shrink-factors]",
32+
);
33+
shrinkFactorsElement.value = JSON.stringify(
34+
model.options.get("shrinkFactors"),
35+
);
2336

24-
downsampleButton.loading = false
37+
downsampleButton.loading = false;
2538
}
2639

27-
return model
40+
return model;
2841
}
2942

3043
// Use this function to run the pipeline when this tab group is select.
3144
// This will load the web worker if it is not already loaded, download the wasm module, and allocate memory in the wasm model.
3245
// 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;
Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,46 @@
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+
);
38
if (!preRun) {
4-
downsampleButton.loading = true
9+
downsampleButton.loading = true;
510
}
611

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);
1219

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]);
1522

1623
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;
2029

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+
);
2336

24-
downsampleButton.loading = false
37+
downsampleButton.loading = false;
2538
}
2639

27-
return model
40+
return model;
2841
}
2942

3043
// Use this function to run the pipeline when this tab group is select.
3144
// This will load the web worker if it is not already loaded, download the wasm module, and allocate memory in the wasm model.
3245
// 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;
Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,46 @@
1-
export default async function downsampleLoadSampleInputs (model, preRun=false) {
2-
const downsampleButton = document.querySelector('#downsampleInputs sl-button[name=input-file-button]')
1+
export default async function downsampleLoadSampleInputs(
2+
model,
3+
preRun = false,
4+
) {
5+
const downsampleButton = document.querySelector(
6+
"#downsampleInputs sl-button[name=input-file-button]",
7+
);
38
if (!preRun) {
4-
downsampleButton.loading = true
9+
downsampleButton.loading = true;
510
}
611

7-
const fileName = "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 = "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);
1219

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]);
1522

1623
if (!preRun) {
17-
const downsampleElement = document.getElementById('downsample-input-details')
18-
downsampleElement.innerHTML = `<pre>${globalThis.escapeHtml(inputFile.path)}</pre>`
19-
downsampleElement.disabled = false
24+
const downsampleElement = document.getElementById(
25+
"downsample-input-details",
26+
);
27+
downsampleElement.setImage(image);
28+
downsampleElement.disabled = false;
2029

21-
const shrinkFactorsElement = document.querySelector('#downsampleInputs sl-input[name=shrink-factors]')
22-
shrinkFactorsElement.value = JSON.stringify(model.options.get('shrinkFactors'))
30+
const shrinkFactorsElement = document.querySelector(
31+
"#downsampleInputs sl-input[name=shrink-factors]",
32+
);
33+
shrinkFactorsElement.value = JSON.stringify(
34+
model.options.get("shrinkFactors"),
35+
);
2336

24-
downsampleButton.loading = false
37+
downsampleButton.loading = false;
2538
}
2639

27-
return model
40+
return model;
2841
}
2942

3043
// Use this function to run the pipeline when this tab group is select.
3144
// This will load the web worker if it is not already loaded, download the wasm module, and allocate memory in the wasm model.
3245
// 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

Comments
 (0)