Yang Gu commited on
Commit
27da4cd
1 Parent(s): 3b919a3

Adjust model path

Browse files
Files changed (2) hide show
  1. demo/ort-phi2/index.html +6 -5
  2. util.js +8 -0
demo/ort-phi2/index.html CHANGED
@@ -6,7 +6,8 @@
6
  </head>
7
 
8
  <body>
9
- <script src="https://cdn.jsdelivr.net/npm/onnxruntime-web@dev/dist/ort.webgpu.min.js"> </script>
 
10
  <!-- <script src="https://wp-27.sh.intel.com/workspace/project/onnxruntime/js/web/dist/ort.webgpu.min.js"> </script> -->
11
 
12
  <script type="module">
@@ -79,15 +80,15 @@
79
  this.profiler = options.profiler;
80
  this.trace = options.trace;
81
 
82
- const model_path = (local) ? "https://wp-27.sh.intel.com/workspace/project/models/" + model.path : "https://huggingface.co/" + model.path + "/resolve/main";
83
 
84
  log(`loading... ${model.name}, ${provider}`);
85
- const json_bytes = await fetchAndCache(model_path + "/config.json");
86
  let textDecoder = new TextDecoder();
87
  const model_config = JSON.parse(textDecoder.decode(json_bytes));
88
 
89
- const model_bytes = await fetchAndCache(model_path + "/phi2-int4.onnx");
90
- const externaldata = (model.externaldata) ? await fetchAndCache(model_path + '/onnx/decoder_model_merged.onnx.data') : false;
91
  let modelSize = model_bytes.byteLength;
92
  if (externaldata) {
93
  modelSize += externaldata.byteLength;
 
6
  </head>
7
 
8
  <body>
9
+ <script src="../../util.js"></script>
10
+ <script src="https://cdn.jsdelivr.net/npm/onnxruntime-web@dev/dist/ort.webgpu.min.js"></script>
11
  <!-- <script src="https://wp-27.sh.intel.com/workspace/project/onnxruntime/js/web/dist/ort.webgpu.min.js"> </script> -->
12
 
13
  <script type="module">
 
80
  this.profiler = options.profiler;
81
  this.trace = options.trace;
82
 
83
+ const modelPath = getModelsPath() + model.path;
84
 
85
  log(`loading... ${model.name}, ${provider}`);
86
+ const json_bytes = await fetchAndCache(modelPath + "/config.json");
87
  let textDecoder = new TextDecoder();
88
  const model_config = JSON.parse(textDecoder.decode(json_bytes));
89
 
90
+ const model_bytes = await fetchAndCache(modelPath + "/phi2-int4.onnx");
91
+ const externaldata = (model.externaldata) ? await fetchAndCache(modelPath + '/phi2-int4.onnx.data') : false;
92
  let modelSize = model_bytes.byteLength;
93
  if (externaldata) {
94
  modelSize += externaldata.byteLength;
util.js CHANGED
@@ -74,3 +74,11 @@ async function readResponse(name, response, progressCallback) {
74
  await read();
75
  return buffer;
76
  }
 
 
 
 
 
 
 
 
 
74
  await read();
75
  return buffer;
76
  }
77
+
78
+ function getModelsPath() {
79
+ if (window.location.href.includes('intel')) {
80
+ return "https://wp-27.sh.intel.com/workspace/project/models/";
81
+ } else {
82
+ return "https://huggingface.co/webai-community/models/resolve/main/";
83
+ }
84
+ }