Skip to content

Commit e33a92f

Browse files
committed
feat: better clearing and loading
1 parent c3562db commit e33a92f

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

mnist/mnist.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,26 @@ function displayResults(probabilities, container) {
4747
// Attach
4848
async function attach(canvas, classify, clear, results, model_file) {
4949

50+
// Disable buttons while loading
51+
classify.disabled = true
52+
clear.disabled = true
53+
54+
// Display loading text
55+
results.innerText = 'Loading model...'
56+
5057
// Load the model
5158
const session = await ort.InferenceSession.create(model_file);
5259

60+
// Clear loading text
61+
results.innerText = ''
62+
63+
// Enable buttons again
64+
classify.disabled = false
65+
clear.disabled = false
66+
5367
// Get canvas context
5468
const ctx = canvas.getContext('2d');
5569

56-
5770
// Is drawing global
5871
let isDrawing = false;
5972

@@ -82,6 +95,7 @@ async function attach(canvas, classify, clear, results, model_file) {
8295
// Function to clear canvas
8396
function clearCanvas() {
8497
ctx.clearRect(0, 0, canvas.width, canvas.height);
98+
results.innerText = ''
8599
}
86100

87101
// Event listeners for drawing

0 commit comments

Comments
 (0)