-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
88 lines (79 loc) · 2.1 KB
/
index.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<!DOCTYPE html>
<html>
<head>
<title>Gangrene Detection</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
text-align: center;
}
h1 {
color: #333;
}
form {
margin-top: 20px;
}
input[type="file"] {
margin-bottom: 10px;
}
input[type="submit"] {
padding: 10px 20px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #45a049;
}
#image-preview {
max-width: 400px;
max-height: 400px;
}
</style>
</head>
<body>
<h1>Gangrene Detection</h1>
<form id="upload-form" enctype="multipart/form-data" method="post" action="/predict">
<input type="file" name="file" id="file-input" required>
<input type="submit" value="Predict" id="predict-button" disabled>
</form>
<img id="image-preview" src="" alt="Image Preview">
<p id="prediction-result"></p>
<script>
const form = document.getElementById('upload-form');
const fileInput = document.getElementById('file-input');
const predictButton = document.getElementById('predict-button');
const imagePreview = document.getElementById('image-preview');
const predictionResult = document.getElementById('prediction-result');
fileInput.addEventListener('change', () => {
const file = fileInput.files[0];
if (file) {
const reader = new FileReader();
reader.onload = () => {
imagePreview.src = reader.result;
predictButton.disabled = false;
}
reader.readAsDataURL(file);
}
});
form.addEventListener('submit', (event) => {
event.preventDefault();
const formData = new FormData(event.target);
fetch('/predict', {
method: 'POST',
body: formData
})
.then(response => response.text())
.then(prediction => {
predictionResult.textContent = `Prediction: ${prediction}`;
})
.catch(error => {
console.error('Error:', error);
});
});
</script>
</body>
</html>