-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
199 lines (176 loc) · 6.96 KB
/
index.html
File metadata and controls
199 lines (176 loc) · 6.96 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Skin Cancer Detection</title>
<!-- Add Bootstrap CSS -->
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
<style>
/* Page Background */
body {
background: linear-gradient(to bottom right, #f5f7fa, #c3cfe2);
height: 120vh;
font-family: 'Arial', sans-serif;
color: #333;
}
/* Container Styling */
.container {
background: #fff;
padding: 30px;
margin-bottom: 10px;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
/* Header */
h1 {
font-size: 2rem;
font-weight: bold;
color: #0056b3;
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}
/* Image Preview Styling */
#imagePreview {
max-width: 100%;
max-height: 300px;
margin: 15px auto;
display: none;
border: 2px dashed #0056b3;
border-radius: 10px;
object-fit: contain;
}
/* Button Styling */
.btn-primary {
background-color: #0056b3;
border-color: #0056b3;
transition: all 0.3s ease;
}
.btn-primary:hover {
background-color: #003d80;
border-color: #003d80;
}
/* Dropdown Styling */
.form-control {
border-radius: 5px;
border: 1px solid #ccc;
}
/* Result Section */
#result {
font-size: 1rem;
padding: 10px;
border-radius: 5px;
text-align: center;
transition: all 0.3s ease;
}
.error {
color: #e74c3c;
background-color: #fce8e6;
border: 1px solid #e74c3c;
}
.success {
color: #2ecc71;
background-color: #e9f9ed;
border: 1px solid #2ecc71;
}
/* Footer Styling */
footer {
margin-top: 20px;
text-align: center;
font-size: 0.85rem;
color: #777;
}
</style>
</head>
<body>
<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-md-8 col-lg-6">
<h1 class="text-center mb-4">Skin Cancer Detection</h1>
<!-- File Input -->
<div class="form-group">
<label for="fileInput">Upload an Image:</label>
<input type="file" id="fileInput" class="form-control-file" onchange="previewImage()">
</div>
<!-- Image Preview -->
<img id="imagePreview" src="" alt="Image Preview">
<!-- Model Selection -->
<div class="form-group">
<label for="modelSelect">Select Detection Model:</label>
<select id="modelSelect" class="form-control">
<option value="default">Ensemble (Default)</option>
<option value="resnet">ResNet</option>
<option value="efficientnetb5">EfficientNet-B5</option>
<option value="vgg16">VGG16</option>
<option value="mobilenet">MobileNetV2</option>
<option value="handcraftedcnn">Handcrafted CNN</option> <!-- New option added -->
</select>
</div>
<!-- Upload Button -->
<button class="btn btn-primary btn-block" onclick="uploadImage()">Upload and Predict</button>
<!-- Prediction Result -->
<p id="result" class="text-center mt-3"></p>
</div>
</div>
<footer>
<p>© 2024 Skin Cancer Detection App. All rights reserved.</p>
</footer>
</div>
<!-- Add Bootstrap JS and Popper.js -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.2/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script>
function previewImage() {
const fileInput = document.getElementById('fileInput');
const file = fileInput.files[0];
const imagePreview = document.getElementById('imagePreview');
if (file) {
const reader = new FileReader();
reader.onload = function(e) {
imagePreview.src = e.target.result;
imagePreview.style.display = 'block';
};
reader.readAsDataURL(file);
}
}
async function uploadImage() {
const fileInput = document.getElementById('fileInput');
const modelSelect = document.getElementById('modelSelect');
const file = fileInput.files[0];
const model = modelSelect.value;
if (!file) {
document.getElementById('result').innerText = "Please select a file.";
document.getElementById('result').classList.add('error');
return;
}
const formData = new FormData();
formData.append('file', file);
formData.append('model', model);
try {
const response = await fetch('http://127.0.0.1:5000/predict', {
method: 'POST',
body: formData
});
const result = await response.json();
if (result.prediction) {
document.getElementById('result').innerHTML = `Prediction: ${result.prediction}<br>Confidence: ${result.confidence}`;
if (result.prediction === 'Non-Cancerous') {
document.getElementById('result').classList.add('success');
document.getElementById('result').classList.remove('error');
} else if (result.prediction === 'Cancerous') {
document.getElementById('result').classList.add('error');
document.getElementById('result').classList.remove('success');
}
} else {
document.getElementById('result').innerText = result.error;
document.getElementById('result').classList.add('error');
document.getElementById('result').classList.remove('success');
}
} catch (error) {
document.getElementById('result').innerText = "An error occurred while processing your request.";
document.getElementById('result').classList.add('error');
}
}
</script>
</body>
</html>