-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.html
67 lines (65 loc) · 2.26 KB
/
server.html
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>EEG Attention Classification</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 1000px;
margin: 0 auto;
padding: 20px;
}
pre {
white-space: pre-wrap;
word-wrap: break-word;
}
#confusionMatrix {
max-width: 100%;
height: auto;
}
</style>
</head>
<body>
<h1>EEG Attention Classification</h1>
<input type="file" id="csvFile" accept=".csv">
<button onclick="uploadFile()">Analyze EEG Data</button>
<div id="result">
<h2>Results</h2>
<h3>Accuracy</h3>
<p id="accuracy"></p>
<h3>Classification Report</h3>
<pre id="classificationReport"></pre>
<h3>Confusion Matrix</h3>
<img id="confusionMatrix" alt="Confusion Matrix">
</div>
<script>
function uploadFile() {
const fileInput = document.getElementById('csvFile');
const file = fileInput.files[0];
const formData = new FormData();
formData.append('file', file);
fetch('http://localhost:5000/predict', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
if (data.accuracy) {
document.getElementById('accuracy').textContent = `${(data.accuracy * 100).toFixed(2)}%`;
document.getElementById('classificationReport').textContent = data.classification_report;
document.getElementById('confusionMatrix').src = 'data:image/png;base64,' + data.confusion_matrix;
document.getElementById('result').style.display = 'block';
} else if (data.error) {
alert('Error: ' + data.error);
}
})
.catch(error => {
console.error('Error:', error);
alert('An error occurred. Please try again.');
});
}
</script>
</body>
</html>