Skip to content

Commit

Permalink
Switched to ORT files for the web to save space
Browse files Browse the repository at this point in the history
  • Loading branch information
Pete Warden authored and petewarden committed Dec 2, 2024
1 parent d2da699 commit a1d77cc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions demo/moonshine-web/downloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ var models = [
]

var layers = [
"preprocess.onnx",
"encode.onnx",
"uncached_decode.onnx",
"cached_decode.onnx"
"preprocess.ort",
"encode.ort",
"uncached_decode.ort",
"cached_decode.ort"
]

console.log("Downloading Moonshine ONNX models from HuggingFace...")
Expand All @@ -24,7 +24,7 @@ models.forEach(model => {
fs.mkdirSync(dir, { recursive: true });
}
layers.forEach(layer => {
hub.downloadFile({ repo, path: "onnx/" + model + "/" + layer }).then((file) => {
hub.downloadFile({ repo, path: "ort/" + model + "/" + layer }).then((file) => {
file.arrayBuffer().then((buffer) => {
fs.writeFile(dir + "/" + layer, Buffer.from(buffer), () => {
console.log("\tDownloaded " + model + "/" + layer + " successfully.")
Expand Down
8 changes: 4 additions & 4 deletions demo/moonshine-web/src/moonshine.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ export default class Moonshine {
const sessionOption = { executionProviders: ['wasm', 'cpu'] };

this.model.preprocess = await ort.InferenceSession.create(
"moonshine/" + this.model_name + "/preprocess.onnx", sessionOption)
"moonshine/" + this.model_name + "/preprocess.ort", sessionOption)
console.log("preprocess loaded")

this.model.encode = await ort.InferenceSession.create(
"moonshine/" + this.model_name + "/encode.onnx", sessionOption)
"moonshine/" + this.model_name + "/encode.ort", sessionOption)
console.log("encode loaded")

this.model.uncached_decode = await ort.InferenceSession.create(
"moonshine/" + this.model_name + "/uncached_decode.onnx", sessionOption)
"moonshine/" + this.model_name + "/uncached_decode.ort", sessionOption)
console.log("uncached_decode loaded")

this.model.cached_decode = await ort.InferenceSession.create(
"moonshine/" + this.model_name + "/cached_decode.onnx", sessionOption)
"moonshine/" + this.model_name + "/cached_decode.ort", sessionOption)
console.log("cached_decode loaded")
console.log(this.model_name + " loaded")
}
Expand Down

0 comments on commit a1d77cc

Please sign in to comment.