Spaces:
Sleeping
Sleeping
fixed download options
Browse files- index.html +25 -3
index.html
CHANGED
|
@@ -488,11 +488,33 @@
|
|
| 488 |
}
|
| 489 |
}
|
| 490 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 491 |
downloadMask() {
|
| 492 |
-
if (!this.predictedMask) return;
|
|
|
|
| 493 |
const link = document.createElement('a');
|
| 494 |
-
|
| 495 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 496 |
link.click();
|
| 497 |
}
|
| 498 |
}
|
|
|
|
| 488 |
}
|
| 489 |
}
|
| 490 |
|
| 491 |
+
// downloadMask() {
|
| 492 |
+
// if (!this.predictedMask) return;
|
| 493 |
+
// const link = document.createElement('a');
|
| 494 |
+
// link.download = 'binary_mask.png';
|
| 495 |
+
// link.href = this.predictedMask.src;
|
| 496 |
+
// link.click();
|
| 497 |
+
// }
|
| 498 |
+
|
| 499 |
downloadMask() {
|
| 500 |
+
if (!this.predictedMask) return; // No mask, nothing to download
|
| 501 |
+
|
| 502 |
const link = document.createElement('a');
|
| 503 |
+
let filename = 'segmentation_result.png';
|
| 504 |
+
|
| 505 |
+
// Determine filename based on current view
|
| 506 |
+
if (this.currentView === 'filled') {
|
| 507 |
+
filename = 'filled_mask.png';
|
| 508 |
+
} else if (this.currentView === 'outline') {
|
| 509 |
+
filename = 'outline_mask.png';
|
| 510 |
+
} else if (this.currentView === 'binary') {
|
| 511 |
+
filename = 'binary_mask.png';
|
| 512 |
+
}
|
| 513 |
+
|
| 514 |
+
// Get the image data from the outputCanvas (which holds the current view)
|
| 515 |
+
link.download = filename;
|
| 516 |
+
link.href = this.outputCanvas.toDataURL('image/png'); // Gets the current content of the outputCanvas
|
| 517 |
+
|
| 518 |
link.click();
|
| 519 |
}
|
| 520 |
}
|