finetune runtime: note on Blob import (HF serves .js as non-JS MIME)
Browse files
setup_53_2d/finetune/cellmap_tfjs_train.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
| 3 |
// (finetune/initializers.json gives the byte offset of every initializer), and writes trained weights back into
|
| 4 |
// the .onnx bytes in place, so the result is served by onnxruntime-web exactly as before.
|
| 5 |
//
|
|
|
|
| 6 |
// const g = await (await fetch(base + "finetune/train_graph.json")).json();
|
| 7 |
// const offs = (await (await fetch(base + "finetune/initializers.json")).json())[onnxFile];
|
| 8 |
// const onnxBytes = new Uint8Array(await (await fetch(base + onnxFile)).arrayBuffer());
|
|
|
|
| 3 |
// (finetune/initializers.json gives the byte offset of every initializer), and writes trained weights back into
|
| 4 |
// the .onnx bytes in place, so the result is served by onnxruntime-web exactly as before.
|
| 5 |
//
|
| 6 |
+
// (served from Hugging Face this file has no JavaScript MIME type: fetch it and import() a Blob URL, or bundle it)
|
| 7 |
// const g = await (await fetch(base + "finetune/train_graph.json")).json();
|
| 8 |
// const offs = (await (await fetch(base + "finetune/initializers.json")).json())[onnxFile];
|
| 9 |
// const onnxBytes = new Uint8Array(await (await fetch(base + onnxFile)).arrayBuffer());
|
setup_53_2d/finetune/finetune_spike.html
CHANGED
|
@@ -14,7 +14,9 @@ const model = q.get("model") || "setup_53_2d", sizes = (q.get("sizes") || "300,5
|
|
| 14 |
const repo = q.get("repo") || "https://huggingface.co/cellmap/onnx-web-models/resolve/main/";
|
| 15 |
const base = repo + model + "/";
|
| 16 |
const log = s => { document.getElementById("log").textContent += "\n" + s; console.log(s); };
|
| 17 |
-
|
|
|
|
|
|
|
| 18 |
await tf.setBackend("webgpu"); await tf.ready();
|
| 19 |
const man = await (await fetch(base + "manifest.json")).json();
|
| 20 |
const graph = await (await fetch(base + "finetune/train_graph.json")).json();
|
|
|
|
| 14 |
const repo = q.get("repo") || "https://huggingface.co/cellmap/onnx-web-models/resolve/main/";
|
| 15 |
const base = repo + model + "/";
|
| 16 |
const log = s => { document.getElementById("log").textContent += "\n" + s; console.log(s); };
|
| 17 |
+
// HF serves .js without a JavaScript MIME type, so import it from a Blob
|
| 18 |
+
const rt = await import(URL.createObjectURL(new Blob([await (await fetch(base + "finetune/cellmap_tfjs_train.js")).text()],
|
| 19 |
+
{ type: "text/javascript" })));
|
| 20 |
await tf.setBackend("webgpu"); await tf.ready();
|
| 21 |
const man = await (await fetch(base + "manifest.json")).json();
|
| 22 |
const graph = await (await fetch(base + "finetune/train_graph.json")).json();
|
setup_54_2d/finetune/cellmap_tfjs_train.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
| 3 |
// (finetune/initializers.json gives the byte offset of every initializer), and writes trained weights back into
|
| 4 |
// the .onnx bytes in place, so the result is served by onnxruntime-web exactly as before.
|
| 5 |
//
|
|
|
|
| 6 |
// const g = await (await fetch(base + "finetune/train_graph.json")).json();
|
| 7 |
// const offs = (await (await fetch(base + "finetune/initializers.json")).json())[onnxFile];
|
| 8 |
// const onnxBytes = new Uint8Array(await (await fetch(base + onnxFile)).arrayBuffer());
|
|
|
|
| 3 |
// (finetune/initializers.json gives the byte offset of every initializer), and writes trained weights back into
|
| 4 |
// the .onnx bytes in place, so the result is served by onnxruntime-web exactly as before.
|
| 5 |
//
|
| 6 |
+
// (served from Hugging Face this file has no JavaScript MIME type: fetch it and import() a Blob URL, or bundle it)
|
| 7 |
// const g = await (await fetch(base + "finetune/train_graph.json")).json();
|
| 8 |
// const offs = (await (await fetch(base + "finetune/initializers.json")).json())[onnxFile];
|
| 9 |
// const onnxBytes = new Uint8Array(await (await fetch(base + onnxFile)).arrayBuffer());
|
setup_54_2d/finetune/finetune_spike.html
CHANGED
|
@@ -14,7 +14,9 @@ const model = q.get("model") || "setup_53_2d", sizes = (q.get("sizes") || "300,5
|
|
| 14 |
const repo = q.get("repo") || "https://huggingface.co/cellmap/onnx-web-models/resolve/main/";
|
| 15 |
const base = repo + model + "/";
|
| 16 |
const log = s => { document.getElementById("log").textContent += "\n" + s; console.log(s); };
|
| 17 |
-
|
|
|
|
|
|
|
| 18 |
await tf.setBackend("webgpu"); await tf.ready();
|
| 19 |
const man = await (await fetch(base + "manifest.json")).json();
|
| 20 |
const graph = await (await fetch(base + "finetune/train_graph.json")).json();
|
|
|
|
| 14 |
const repo = q.get("repo") || "https://huggingface.co/cellmap/onnx-web-models/resolve/main/";
|
| 15 |
const base = repo + model + "/";
|
| 16 |
const log = s => { document.getElementById("log").textContent += "\n" + s; console.log(s); };
|
| 17 |
+
// HF serves .js without a JavaScript MIME type, so import it from a Blob
|
| 18 |
+
const rt = await import(URL.createObjectURL(new Blob([await (await fetch(base + "finetune/cellmap_tfjs_train.js")).text()],
|
| 19 |
+
{ type: "text/javascript" })));
|
| 20 |
await tf.setBackend("webgpu"); await tf.ready();
|
| 21 |
const man = await (await fetch(base + "manifest.json")).json();
|
| 22 |
const graph = await (await fetch(base + "finetune/train_graph.json")).json();
|