-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
37 lines (30 loc) · 1.09 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
document.getElementById('uploadBtn').addEventListener('click', async () => {
const fileInput = document.getElementById('fileInput');
const file = fileInput.files[0];
if (!file) {
alert('Please select an image file.');
return;
}
const formData = new FormData();
formData.append('file', file);
try {
const response = await fetch('/process', {
method: 'POST',
body: formData
});
const result = await response.json();
if (result.combined_mask) {
document.getElementById('combinedMask').src = result.combined_mask;
}
const individualMasksContainer = document.getElementById('individualMasks');
individualMasksContainer.innerHTML = '';
result.individual_masks.forEach(maskUrl => {
const img = document.createElement('img');
img.src = maskUrl;
img.alt = 'Individual Mask';
individualMasksContainer.appendChild(img);
});
} catch (error) {
console.error('Error:', error);
}
});