pdufour commited on
Commit
4c42c50
1 Parent(s): 828d25e

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +4 -7
index.js CHANGED
@@ -1,5 +1,5 @@
1
  import { env, AutoTokenizer, RawImage, Tensor, getSession } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers';
2
- import { getModelJSON } from "https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.0.2/src/utils/hub.js";
3
  import * as ort from "https://cdn.jsdelivr.net/npm/onnxruntime-web@1.20.0/dist/ort.webgpu.mjs";
4
 
5
  // Since we will download the model from the Hugging Face Hub, we can skip the local model check
@@ -19,12 +19,10 @@ const IMAGE_EMBED_SIZE = WIDTH_FACTOR * HEIGHT_FACTOR;
19
  const MAX_SEQ_LENGTH = 1024;
20
  const ONNX_URL = "http://localhost:3004/onnx";
21
  const BASE_MODEL = "Qwen/Qwen2-VL-2B-Instruct";
22
- const QUANTIZATION = "q4f16";
 
23
  const MAX_SINGLE_CHAT_LENGTH = 10;
24
 
25
- // const ONNX_MODEL_BASE_URL=
26
- console.log(getSession);
27
-
28
  status.textContent = 'Loading model...';
29
  status.textContent = 'Ready';
30
 
@@ -47,7 +45,6 @@ fileUpload.addEventListener('change', function (e) {
47
  reader.readAsDataURL(file);
48
  });
49
 
50
-
51
  async function parse(img, txt) {
52
  imageContainer.innerHTML = '';
53
  imageContainer.style.backgroundImage = `url(${img})`;
@@ -127,7 +124,7 @@ export async function imageTextToText(
127
  const pixel_values = image.unsqueeze(0);
128
 
129
  const ortSessionA = await ort.InferenceSession.create(
130
- `${ONNX_MODEL_BASE_URL}/QwenVL_A${suffix}.onnx`,
131
  { executionProviders: ["webgpu"] }
132
  );
133
 
 
1
  import { env, AutoTokenizer, RawImage, Tensor, getSession } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers';
2
+ import { getModelJSON, getModelFile } from "https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.0.2/src/utils/hub.js";
3
  import * as ort from "https://cdn.jsdelivr.net/npm/onnxruntime-web@1.20.0/dist/ort.webgpu.mjs";
4
 
5
  // Since we will download the model from the Hugging Face Hub, we can skip the local model check
 
19
  const MAX_SEQ_LENGTH = 1024;
20
  const ONNX_URL = "http://localhost:3004/onnx";
21
  const BASE_MODEL = "Qwen/Qwen2-VL-2B-Instruct";
22
+ const ONNX_MODEL = "pdufour/Qwen2-VL-2B-Instruct-ONNX-Q4-F16";
23
+ const QUANT = "q4f16";
24
  const MAX_SINGLE_CHAT_LENGTH = 10;
25
 
 
 
 
26
  status.textContent = 'Loading model...';
27
  status.textContent = 'Ready';
28
 
 
45
  reader.readAsDataURL(file);
46
  });
47
 
 
48
  async function parse(img, txt) {
49
  imageContainer.innerHTML = '';
50
  imageContainer.style.backgroundImage = `url(${img})`;
 
124
  const pixel_values = image.unsqueeze(0);
125
 
126
  const ortSessionA = await ort.InferenceSession.create(
127
+ await getModelFile(ONNX_MODEL, "onnx/QwenVL_A_${QUANT}.onnx"),
128
  { executionProviders: ["webgpu"] }
129
  );
130