jaswanthsanjay88 commited on
Commit
8db276f
·
verified ·
1 Parent(s): d54c514

Upload app.js with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.js +7 -5
app.js CHANGED
@@ -1,7 +1,9 @@
1
  import * as ort from "https://cdn.jsdelivr.net/npm/onnxruntime-web@1.20.1/dist/ort.webgpu.min.js";
2
 
3
- const MODEL_URL = "https://huggingface.co/jaswanthsanjay88/mara-small/resolve/main/model_fp16.onnx";
4
- const TOKENIZER_URL = "https://huggingface.co/jaswanthsanjay88/mara-small/resolve/main/tokenizer.json";
 
 
5
  const MAX_SEQ = 512;
6
  const EOS_ID = 0;
7
 
@@ -110,10 +112,10 @@ async function init() {
110
  try {
111
  tokenizer = await loadTokenizer();
112
  session = await ort.InferenceSession.create(MODEL_URL, {
113
- executionProviders: ["webgpu", "wasm"],
114
  });
115
- provider = session.inputNames && ort.env.webgpu?.available ? "webgpu" : "wasm";
116
- statusEl.innerHTML = `ready · backend: <b>${provider}</b>`;
117
  goBtn.disabled = false;
118
  } catch (e) {
119
  statusEl.textContent = "failed to load model: " + e.message;
 
1
  import * as ort from "https://cdn.jsdelivr.net/npm/onnxruntime-web@1.20.1/dist/ort.webgpu.min.js";
2
 
3
+ const BASE_URL = "https://huggingface.co/jaswanthsanjay88/mara-small/resolve/main/";
4
+ const TOKENIZER_URL = BASE_URL + "tokenizer.json";
5
+ const HAS_WEBGPU = typeof navigator.gpu !== "undefined";
6
+ const MODEL_URL = BASE_URL + (HAS_WEBGPU ? "model_fp16.onnx" : "model_int8.onnx");
7
  const MAX_SEQ = 512;
8
  const EOS_ID = 0;
9
 
 
112
  try {
113
  tokenizer = await loadTokenizer();
114
  session = await ort.InferenceSession.create(MODEL_URL, {
115
+ executionProviders: HAS_WEBGPU ? ["webgpu"] : ["wasm"],
116
  });
117
+ provider = HAS_WEBGPU ? "webgpu (fp16)" : "wasm (int8)";
118
+ statusEl.innerHTML = `ready · backend: <b>${provider}</b> · model: ${HAS_WEBGPU ? "fp16" : "int8"}`;
119
  goBtn.disabled = false;
120
  } catch (e) {
121
  statusEl.textContent = "failed to load model: " + e.message;