Tobias Cornille commited on
Commit
e14316a
·
1 Parent(s): b317c94

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +5 -5
index.js CHANGED
@@ -24,18 +24,18 @@ example.addEventListener('click', (e) => {
24
  detect(EXAMPLE_URL);
25
  });
26
 
27
- const reader = new FileReader();
28
  fileUpload.addEventListener('change', function (e) {
29
  const file = e.target.files[0];
30
  if (!file) {
31
  return;
32
  }
33
 
 
34
 
35
  // Set up a callback when the file is loaded
36
  reader.onload = function(e2) {
37
  img = e2.target.result;
38
- detect(e2.target.result);
39
  }
40
 
41
  reader.readAsDataURL(file);
@@ -44,15 +44,15 @@ fileUpload.addEventListener('change', function (e) {
44
 
45
  labels.addEventListener('blur', (e) => {
46
  parsedLabels = e.target.value.split(",");
47
- console.warn(parsedLabels, reader);
48
  if (img) {
49
  status.textContent = 'Analysing...';
50
- detect(img, parsedLabels);
51
  }
52
  });
53
 
54
  // Detect objects in the image
55
- async function detect(img) {
56
  console.warn(parsedLabels);
57
  imageContainer.innerHTML = '';
58
  imageContainer.style.backgroundImage = `url(${img})`;
 
24
  detect(EXAMPLE_URL);
25
  });
26
 
 
27
  fileUpload.addEventListener('change', function (e) {
28
  const file = e.target.files[0];
29
  if (!file) {
30
  return;
31
  }
32
 
33
+ const reader = new FileReader();
34
 
35
  // Set up a callback when the file is loaded
36
  reader.onload = function(e2) {
37
  img = e2.target.result;
38
+ detect();
39
  }
40
 
41
  reader.readAsDataURL(file);
 
44
 
45
  labels.addEventListener('blur', (e) => {
46
  parsedLabels = e.target.value.split(",");
47
+ console.warn(img);
48
  if (img) {
49
  status.textContent = 'Analysing...';
50
+ detect();
51
  }
52
  });
53
 
54
  // Detect objects in the image
55
+ async function detect() {
56
  console.warn(parsedLabels);
57
  imageContainer.innerHTML = '';
58
  imageContainer.style.backgroundImage = `url(${img})`;