prateekbh commited on
Commit
22c1987
1 Parent(s): e681aef

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +3 -9
index.js CHANGED
@@ -13,14 +13,9 @@ const EXAMPLE_URL = 'https://huggingface.co/datasets/Xenova/transformers.js-docs
13
 
14
  // Create a new object detection pipeline
15
  status.textContent = 'Loading model...';
16
- const detector = await pipeline('object-detection', 'Xenova/detr-resnet-50');
17
  status.textContent = 'Ready';
18
 
19
- example.addEventListener('click', (e) => {
20
- e.preventDefault();
21
- detect(EXAMPLE_URL);
22
- });
23
-
24
  fileUpload.addEventListener('change', function (e) {
25
  const file = e.target.files[0];
26
  if (!file) {
@@ -28,11 +23,10 @@ fileUpload.addEventListener('change', function (e) {
28
  }
29
 
30
  const reader = new FileReader();
31
-
32
  // Set up a callback when the file is loaded
33
  reader.onload = e2 => detect(e2.target.result);
34
-
35
  reader.readAsDataURL(file);
 
36
  });
37
 
38
 
@@ -47,7 +41,7 @@ async function detect(img) {
47
  percentage: true,
48
  });
49
  status.textContent = '';
50
- output.forEach(renderBox);
51
  }
52
 
53
  // Render a bounding box and label on the image
 
13
 
14
  // Create a new object detection pipeline
15
  status.textContent = 'Loading model...';
16
+ const detector = await pipeline('image-to-image', 'briaai/RMBG-1.4');
17
  status.textContent = 'Ready';
18
 
 
 
 
 
 
19
  fileUpload.addEventListener('change', function (e) {
20
  const file = e.target.files[0];
21
  if (!file) {
 
23
  }
24
 
25
  const reader = new FileReader();
 
26
  // Set up a callback when the file is loaded
27
  reader.onload = e2 => detect(e2.target.result);
 
28
  reader.readAsDataURL(file);
29
+ console.log("hi")
30
  });
31
 
32
 
 
41
  percentage: true,
42
  });
43
  status.textContent = '';
44
+ // output.forEach(renderBox);
45
  }
46
 
47
  // Render a bounding box and label on the image