yaguilherme commited on
Commit
b2d539d
1 Parent(s): c7b632f

second commit

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. index.js +5 -8
README.md CHANGED
@@ -6,7 +6,7 @@ colorTo: yellow
6
  sdk: static
7
  pinned: false
8
  models:
9
- - Xenova/detr-resnet-50
10
  license: mit
11
  ---
12
 
 
6
  sdk: static
7
  pinned: false
8
  models:
9
+ - Xenova/distilgpt2
10
  license: mit
11
  ---
12
 
index.js CHANGED
@@ -9,16 +9,16 @@ const fileUpload = document.getElementById('upload');
9
  const imageContainer = document.getElementById('container');
10
  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 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) {
@@ -37,12 +37,9 @@ fileUpload.addEventListener('change', function (e) {
37
 
38
 
39
  // Detect objects in the image
40
- async function detect(img) {
41
- imageContainer.innerHTML = '';
42
- imageContainer.style.backgroundImage = `url(${img})`;
43
-
44
  status.textContent = 'Analysing...';
45
- const output = await detector(img, {
46
  threshold: 0.5,
47
  percentage: true,
48
  });
 
9
  const imageContainer = document.getElementById('container');
10
  const example = document.getElementById('example');
11
 
12
+ const EXAMPLE_TEXT = 'Onde surfar com pranchinha hoje no Rio de Janeiro?';
13
 
14
  // Create a new object detection pipeline
15
  status.textContent = 'Loading model...';
16
+ const recommender = await pipeline('text-generation', 'Xenova/distilgpt2');
17
  status.textContent = 'Ready';
18
 
19
  example.addEventListener('click', (e) => {
20
  e.preventDefault();
21
+ detect(EXAMPLE_TEXT);
22
  });
23
 
24
  fileUpload.addEventListener('change', function (e) {
 
37
 
38
 
39
  // Detect objects in the image
40
+ async function detect(text) {
 
 
 
41
  status.textContent = 'Analysing...';
42
+ const output = await recommender(img, {
43
  threshold: 0.5,
44
  percentage: true,
45
  });