Xenova HF staff commited on
Commit
976fba6
1 Parent(s): 158dc2e

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +9 -9
index.js CHANGED
@@ -11,16 +11,16 @@ const example = document.getElementById('example');
11
 
12
  const EXAMPLE_URL = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/city-streets.jpg';
13
 
 
 
14
  // Create a new object detection pipeline
15
  status.textContent = 'Loading model...';
16
  const processor = await AutoProcessor.from_pretrained('Xenova/yolov9-c');
17
 
18
- // Testing
19
- processor.feature_extractor.size = { width: 128, height: 128 }
20
 
21
- const model = await AutoModel.from_pretrained('Xenova/yolov9-c', {
22
- // quantized: false,
23
- });
24
  status.textContent = 'Ready';
25
 
26
  example.addEventListener('click', (e) => {
@@ -71,10 +71,10 @@ function renderBox([xmin, ymin, xmax, ymax, score, id]) {
71
  boxElement.className = 'bounding-box';
72
  Object.assign(boxElement.style, {
73
  borderColor: color,
74
- left: 100 * xmin / 640 + '%',
75
- top: 100 * ymin / 640 + '%',
76
- width: 100 * (xmax - xmin) / 640 + '%',
77
- height: 100 * (ymax - ymin) / 640 + '%',
78
  })
79
 
80
  // Draw label
 
11
 
12
  const EXAMPLE_URL = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/city-streets.jpg';
13
 
14
+ const IMAGE_SIZE = 128;
15
+
16
  // Create a new object detection pipeline
17
  status.textContent = 'Loading model...';
18
  const processor = await AutoProcessor.from_pretrained('Xenova/yolov9-c');
19
 
20
+ // For this demo, we resize the image to IMAGE_SIZE x IMAGE_SIZE
21
+ processor.feature_extractor.size = { width: IMAGE_SIZE, height: IMAGE_SIZE }
22
 
23
+ const model = await AutoModel.from_pretrained('Xenova/yolov9-c');
 
 
24
  status.textContent = 'Ready';
25
 
26
  example.addEventListener('click', (e) => {
 
71
  boxElement.className = 'bounding-box';
72
  Object.assign(boxElement.style, {
73
  borderColor: color,
74
+ left: 100 * xmin / IMAGE_SIZE + '%',
75
+ top: 100 * ymin / IMAGE_SIZE + '%',
76
+ width: 100 * (xmax - xmin) / IMAGE_SIZE + '%',
77
+ height: 100 * (ymax - ymin) / IMAGE_SIZE + '%',
78
  })
79
 
80
  // Draw label